Layouts and maps - susy

I have a project which has different layouts at various breakpoints and I'm struggling a little to get the maps part to work. I've set up an example at http://sassmeister.com/gist/ef02247af9f901fb3897
You'll see i have two maps and each has different grid settings and debug colours. But I have a few issues:
Grid colours aren't changing. They aren't even shown for the first map (which should be yellow and then red for the wider grid).
Although the grid columns change, i don't think the column widths or the gutter widths are correct. As an example column ONE seems to be bigger than the grid fifth column when it should be just a bit shorter and the margin doesn't seem to be wider either. Could this just be the grid background not being accurate enough?
When I reach the 975 breakpoint the gutter should get larger than what was defined in tablet map but it doesn't appear to be.
Any ideas as to what is needed to get the correct map to run at different breakpoints. Do I need to clear / reset the map at various breakpoints?
Thanks

I'm not sure what's going on with the grid-image colors. That seems like a bug. Can you file an issue on GitHub?
The other two problems are related to how you apply your grid settings. As far as Susy is concerned, your grids are only being used for the containers (where you pass them in explicitly). Susy doesn't know anything about the DOM or nesting of elements, so those grid settings aren't "passed on" to the children in any real way.
There are a few ways to tell the span mixins what grid settings to use. you can pass them in explicitly e.g. #include span(last 7 of $tablet);, or you could use the with-layout mixin to wrap a whole group:
#include breakpoint(760px) {
#include with-layout($tablet) {
#include container;
.column1 {
#include span(5);
}
.column2 {
#include span(last 7);
}
}
}
Or you can use susy-breakpoint, which is a shortcut for exactly that:
#include susy-breakpoint(760px, $tablet) {
#include container;
.column1 {
#include span(5);
}
.column2 {
#include span(last 7);
}
}
I'm not adding context to the containers or the spans, because Susy will assume the default global context, which is being set by with-layout and susy-breakpoint in these examples.

Related

Column-Packed RowColumn Class for Motif Library (C)?

I recently asked this question: Horizontally-Drawn RowColumn Class for Motif Library (C)?
In my previous question, I was having trouble getting the xmRowColumnWidgetClass to draw horizontally (row-by-row) instead of vertically (column-by-column). After playing around with it, figured out how to switch to horizontal drawing with the following snippet:
XmNorientation, XmHORIZONTAL,
So the code that creates the xmRowColumnWidgetClass instance now looks like this:
rowColumn = XtVaCreateManagedWidget("rowcolumn",
xmRowColumnWidgetClass,
parentWidget,
XmNnumColumns, 3,
XmNorientation, XmHORIZONTAL,
XmNpacking, XmPACK_COLUMN,
XmNspacing, 6,
NULL);
However, my new problem is that for some reason the XmNnumColumns field is now referring to the number of rows, rather than the actual number of columns. Before adding the XmNorientation, XmHORIZONTAL part, the xmRowColumnWidgetClass instance was drawing the objects from left-to-right but it stayed to 3 columns like it was supposed to. Now, it is staying to 3 rows, occasionally creating a horizontal scrollbar which I do not want. I only want vertical scrolling.
So I need the children of the xmRowColumnWidgetClass instance to be drawn horizontally from top to bottom, but I need it to only put a maximum of 3 per row and thus keep it confined within a certain width.
I tried playing around with the XmNnumColumns field, but things that worked with more children did not work for less children, and vice versa. Sometimes it made it 4 or 5 columns rather than 3, and sometimes it made it 2 columns with the 3rd column completely empty. I encountered many issues like this even when experimenting with things like using XmNpacking, XmPACK_TIGHT rather than XmNpacking, XmPACK_COLUMN and other stuff.
If someone is able to find the official documentation of the xmRowColumnWidgetClass and link it, that would be be greatly appreciated.
To anybody familiar with this library:
How do I create a xmRowColumnWidgetClass instance that draws horizontally (row-by-row) while keeping it to a certain number of columns?
It should be able to handle any number of children and add as many rows as it needs to in order to keep it as exactly 3 columns.
Another group of examples of this library:
https://github.com/spartrekus/Motif-C-Examples
https://github.com/spartrekus/Motif-C-Examples/blob/master/rowcol.c
XmRowColumn was designed to implement the top menubar and all the other menu classes... You are searching for a grid like widget, and so you have to use XmForm read the related question for that.
In short: try the WtTable widget
Longer explanation follows:
The behaviour of XmRowColumn regarding "columns" becoming "rows" when you choose a horizontal configuration is very unfortunate. The alternative of using XmForm instead of XmRowColumn for this purpose is feasible, but however it requires manually setting the children constraints, and even then, it's quite possible that you won't be able to achieve the automatic sizing implemented in XmRowColumn.
By searching today, I found the WtTable widget and it works fine for my purposes. It's "almost" as automatic as XmRowColumn and it doesn't require to set any constraints manually. I tried it in my Motif code, and works fine.
Note however that I said "almost" as automatic. The "almost" is because you need to specify the number of columns and rows, and you need to specify the column and row for each child widget. However, all of this can be automated: you can create a convenience function that internally manages counters for columns and rows, so that you pass a widget to such function and it puts it in the cell it belongs automatically: you can even make that function create a new row in the WtTable when it's needed.

Setting the size of a GTKEventBox

I've got a GtkHBox with 2 items. Inside that, on the left, I have a GtkHBox with 4 items. The first two are GtkEventBox's, followed by a GtkHScale and finally a GtkLabel.
The two GtkEventBox's each contain a GtkVBox with two items, an image and a label (using the GtkEventBox so that I can catch click events on the image). Unfortunately, I can't seem to figure out how to set the width for them. Currently, it looks like this:
But I want the Select and Pan sections to be much narrower. Any suggestions?
Make sure to pack the event boxes into your GtkHBox with the expand and fill parameters set to false.

GTK TextView - creating a static display format

I am trying to simulate a piece of hardware, and this hardware has a static ribbon display.
to do this, I'd like to use a TextView. My display has 10 rows, with 25 columns. So I figured that a TextView should be easy enough.
basically, I would like to be able to say "insert/replace string S at row X, starting at column Y". i may need to only update a specific row, or even a single column within a row.
I have not been successful at getting this to work though. the best I have been able to do is to fill the TextView with 10 lines of 25 spaces when i create it, and then use the get_iter_at_line_offset to get the iterator of a line, and then push the new text onto that line.
but this will start appending text to the line, rather than replacing the existing one.
I need both row and column control (i.e. need to be able to set text at a specific (X,Y) coordinate).
I'm assuming this is somehow possible using marks.
Can anyone give me a quick example of how i can do this? Unfortunately, there isn't a whole lot of documentation on this sort of thing.
You'll have to get an iter at a specific line, row X, and then use the iterator's forward_chars() method to move forward Y characters. Then delete the number of characters you are replacing, and finally insert the text you want to insert. You can do it all with iterators, I think - iterators are invalidated when you change the buffer, but when you delete text, one of your iterators is revalidated to point to the place where the text was.
If you're targetting GTK+ 3.x, you should really look into using Cairo. Since you don't actually need a text buffer, it seems like overkill and a bit of a mis-alignment to use the GtkTextView.
Look at the very basic introduction on how to draw with Cairo in GTK+. Then look at the text-rendering Cairo APIs, that should be enough to get you started.

FOP: fo:block width attribute ignored?

I'm managing to generate a PDF with one line-chart from google-chart, but the quality of the generated columns titles doesn't fit our needs, so I want to generate by myself.
This task should be done using [fo:table] but I'm not able to positionate succesfully the titles (widths and margins/paddings).
In sum up, I want to put the titles using [fo:block] setting the width attribute plus a negative margin (i.e. width="1.5cm" margin-top="-2em"), but the width doesn't take effect.
Do you know how to do it?
Thanks.
The "width" property doesn't apply to fo:block (see http://www.w3.org/TR/xsl11/#fo_block). If you want to redefine the width, you need to use an fo:block-container (http://www.w3.org/TR/xsl11/#fo_block-container) or another element that generates a so-called reference area. It's a bit difficult to understand what exactly your expected layout is. Maybe you can also experiment with using "start-indent" and "end-indent" properties to indirectly influence the actual width of an fo:block. HTH
Finally I have not been able to do that, because [fo:inline] tries to gather all the available space.
One trick is to put margins (left or right) to the 90% or more to fill that gap, but I then have no clue the previous [fo:inline] text was rendered in one, two or more lines.
The only way I found to generate the column's titles is using [fo:table] plus adding margins (left & right) to each cell.
PS: I use FOP-0.95
For FOP you may use tables to set width instead of applying it directly on block.

multiple CComboBox sharing the same data

I have a MFC dialog with 32 CComboBoxes on it that all have the same data in the listbox. Its taking a while to come up, and it looks like part of the delay is the time I need to spend using InsertString() to add all the data to the 32 controls. How can I subclass CComboBox so that the 32 instances share the same data?
Turn off window redrawing when filling the combos. e.g.:
m_wndCombo.SetRedraw(FALSE);
// Fill combo here
...
m_wndCombo.SetRedraw(TRUE);
m_wndCombo.Invalidate();
This might help.
The first thing I would try is calling "InitStorage" to preallocate the internal memory for the strings.
From MSDN:
// Initialize the storage of the combo box to be 256 strings with
// about 10 characters per string, performance improvement.
int n = pmyComboBox->InitStorage(256, 10);
In addition to what has already been said, you might also turn off sorting in your combo box and presort the data before you insert it.
One way along the lines of your request would be to go owner drawn - you will be writing a fair chunk of code, but you won't have to add the data to all of them.
"CComboBox::DrawItem"
Support.microsoft have this article on subclassing a Combo box which might also be of interest
"How to subclass CListBox and Cedit inside of CComboBox"
Really one has to ask if it is worth the effort, and alot of that depends things like
number of entries in the list
number of times the dialog will show
variability of the combo content
optomising elsewhere
not drawing until the screen is complete
only building the dialog once and re showing it.
using the one combo but showing it in different locations at different times