Get space in combo-box after populate model in GTK C - c

I have code where I populate combo box models by text but first time I see strange behavior.
I use Blade GUI editir to create *.ui file where i generate single empty combobox.
After, I fetch combo from methods and modify/fill my combo.
This is my snippets of code:
GtkWidget *combo_screen_share;
GtkTreeModel *model;
// here I get empty combobox
combo_screen_share=myprog_gtk_get_widget(call_view,"window_screen_stream");
GtkCellRenderer *renderer=gtk_cell_renderer_text_new();
model=GTK_TREE_MODEL((store=gtk_list_store_new(1,G_TYPE_STRING)));
int i;
for(i=0; i<200; i++){
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,"Full Screen",-1);
}
gtk_combo_box_set_model(GTK_COMBO_BOX(combo_screen_share),model);
g_object_unref(G_OBJECT(model));
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_screen_share),renderer,FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_screen_share),renderer,"text",0,NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_screen_share),0);
// bind 'onChange' with other method as callback
g_signal_connect(G_OBJECT(combo_screen_share),"changed",(GCallback)gtk_combo_box_new_with_model,NULL);
It should create 200 rows of "Full Screen" string.
However when I click on combobox, I get empty half screen as gap/space and only after all my 200 items.
If I run the loop for 100, space is going to be smaller.
Did someone meet the same thing and know how to fix it?
Thank you,

What you're seeing isn't a "bug" exactly, it's just the way Gtk does combo boxes and you'll have to live with it.
Try another app if you don't believe me --
Open a Gtk app (I used The Gimp)
Find a combo box with several options
Drag the window so that the combo box is near the bottom of the screen
Click on it
When the combo box appears it will have a big empty space at the top, just like yours.
I don't believe there's a fix without patching Gtk itself. For more discussion/rants on this issue see this Launchpad bug and this Gnome Buzilla bug.

Related

Adding a tab in a GTK-Notebook when using Glade

I have written a C-program and am studying GTK and Glade to build a GUI and now I am stuck for at least two days:
I need a notebook with one tab. In this tab is a button, if clicked a new tab is added.
I found: 'gtk_notebook_append_page(notebook_pointer, tab_content_pointer, label)' but whatever I do it doesn't work. Especially I am not sure what to take as tab_content. I get one out of three error messages: it complains that it is top level and can't get a parent or it has already a parent or the new tab just can't be inserted.
Does anyone know what to take in glade to be used as tab_content? Or knows an example where I could learn that?
Or do I need to dump glade and write everything in C-code? I found examples for that.
Thanks for your help.
Draw a notebook with Glade. If you right - click on the tab you want to change, you can delete its contents. (A tab can contain a single widget, though you can put in a HBox or a Grid to combine several).
Once deleted, you can insert any other widget there. Here is an example:
A window with a notebook. First tab contents deleted
Inserted a Box, but by default it's vertical, so...
I changed the property to horizontal
I inserted an image widget in the first space, and a checkbutton in the second. (Change the computer's theme to make is a little more visible.
If you want to add pages from you C-code you can do that too, just get a reference to the notebook, and then modify the tab contents.
As a note, I'd recommend looking at using Python as manager of your GUI. Managing GUIs in Gtk and C - using Glade or not - is tedious. There are several example on the net about how to do that:
-Using Python GTK GUI front end with C++ backend
-How to use GTK+ 3 in Python to manage your whole application
This code adds a new tab perfectly here:
notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook1"));
if (!notebook) {
g_critical ("Widget \"%s\" is missing in file %s.",
TOP_WINDOW, "notebook1");
}
tab_label = gtk_label_new ("New page's tab");
page_contents = gtk_label_new ("New page's contents");
gtk_notebook_append_page(notebook, page_contents, tab_label);
Note that you have to put "notebook1" in the ID field of the notebook's widget in Glade.

Combo box in a MFC application

My question is about combo boxes in Windows MFC applications.
The dropdown part of the combo box contains items composed of a bitmap and a string.
Sometimes, the strings are too long and I have to adjust the width of the dropdown part of the combo box using the CComboBox::SetDroppedWidth() method.
My problem is that when the combo box is near the right edge of the computer screen, the right part of the dropdown is hidden (see image_1 and image_2 below).
I would like it to behave like in Excel (see image_3 below) meaning I would like the dropdown list to be shifted accordingly so that all its items can be seen without being cropped.
How can this be achieved?
image_1: right part of the dropdown is NOT hidden
image_2: near the computer right edge, the right part of the dropdown is hidden
image_3: Excel combo box
=================================================================
EDIT 1
=================================================================
EDIT 2
Ok. I forgot to mention that m_cbXmodels is a CComboBoxEx object. This is why the handles are NULL. I could get the handles via GetComboBoxCtrl()...
Handle the CBN_DROPDOWN notification.
Get the handle for the list control with GetComboBoxInfo.
Now use MoveWindow to adjust the window as needed.
Getting the current screen size is available with MonitorFromWindow. See rcWork member in MONITORINFO. You just need to adjust the left and right coordinates.
EDIT: As you can read in the comments: My Approach with CBN_DROPDOWN is to early Thanks to zett42). It is not possible to resize the combo box list part here.
But it is possible to post a user defined message to the same window and to reposition the window than.

How could I interactively create an invoice and preview it on WPF?

I'm creating a trial project wherein my window has two grids, left grid is sort of a table that has labels and textboxes each row and asks for a specific part of the invoice like item, name, address stuff like that and the right grid is to show a preview of the invoice that the left side is creating.
I thought about using a document viewer on the right side but I thought that anything I open there would be static and if I put values on the textboxes on the left grid, it wouldn't matter since I opened a standalone document to view on the right grid.
I thought about just creating a table out of the right grid and have the default values and populate the other ones when a user types something on the textbox and make it function as the preview but then I don't know how would I go about and printing it and also, it has about 45 rows which I couldn't fit in the grid without it being unreadable (because I had to cram 45 rows of data inside that small grid)
So is there a tool in the toolbox that could potentially create a interact-able grid? I tried the grid control but I can't seem to only make it show 4 columns because that's all I need, I don't want it to show E and the rest of the alphabet because I want it to resize accordingly with only 4 columns to make it more readable.
Oh and I also have devexpress installed so you guys could also recommend something I can use from there. Thank You.
I think this is the best solution since it does what I wanted it to do.
I created a scroll view and placed a grid inside it then set the length accordingly to show it in a reasonable size and let the scroll bar do its magic for me to see the rest of the grid without compromises of the content's size.

How can I neatly line up right-aligned check boxes with with other controls?

The Visual Studio WinForms designer lets you snap together text boxes, list boxes, buttons, and so forth reasonably well. However, a check box with CheckAlign=MiddleRight does not work quite like the others, because it has two components: the built-in label, and the check box itself. If you line up the text with other labels, the check box is left floating and will not automatically line up. You can turn off AutoSize and attempt to size the CheckBox control so the check box lines up, but this is touchy and will be thrown off by custom font sizes.
In this example, I've almost lined up the check box with the other controls, but not quite:
If I had several check boxes it would be a real headache, as with AutoSize turned off the position of the check box is relative to the end of the text, so each control has to be individually sized pixel by pixel.
What's the best way to line up check boxes with other controls?
One workaround is to not include text with the CheckBox and instead have a separate Label control. However, by doing so you lose the ability to click on the label to toggle the check box. On a high-resolution screen, clicking a 10x10 pixel is finicky, a poor UX experience. You could add an OnClick event to the label, of course, but that seems like solving the wrong problem.
Here's an example of someone else with the same issue: in the preferences panel in Oracle SQL Developer, when there's a mix of properties the check boxes are handled with separate labels and boxes:
Personally, i avoid that issue by not having the CheckBoxes aligned to the right:
rather than having the caption on the left.

wpf Richtextbox selected text distorted

I am experimenting with the WPF RichTextBox and it shows some text in my application. I notice that When I select some text in that RichTextBox, the selected text gets distorted and the text below to that also gets distorted as shown below.
After I deselect that and scroll it comes back to normal.Is there anyway to avoid this distortion?
Now I solved this problem by myself. I just added the following single line of code in my application and make it works. We need to disable hardware acceleration in screen settings using this.
RenderOptions.ProcessRenderMode = System.Windows.Interop.RenderMode.SoftwareOnly;
This helped me a lot to fix my issue and it works for me.

Resources