How to add separator to layout - layout

I want to add vseparator to layout in GTK 2.0.
It's like the toolbar.
Here's part of code:
GtkWidget *layout, vsparator;
layout = gtk_layout_new(NULL, NULL);
vseparator = gtk_separator_menu_item_new();
gtk_layout_put(GTK_LAYOUT(layout), vseparator, 150, 0);
But, I don't understand why it is not being displayed. Why?

The separator menu item is not displayed if there are no menu items on either side of it. It doesn't make sense to use a separator menu item outside of a menu anyway.
Use GtkVSeparator instead.

Related

Hide Controls At Design-Time [duplicate]

I need to handle multiple panels, containing variuous data masks. Each panel shall be visible using a TreeView control.
At this time, I handle the panels visibility manually, by making the selected one visible and bring it on top.
Actually this is not much confortable, especially in the UI designer, since when I add a brand new panel I have to resize every panel and then design it...
A good solution would be using a TabControl, and each panel is contained in a TabPage. But I cannot find any way to hide the TabControl buttons, since I already have a TreeView for selecting items.
Another solution would be an ipotethic "StackPanelControl", where the Panels are arranged using a stack, but I couldn't find it anywhere.
What's the best solution to handle this kind of UI?
You need a wee bit of Win32 API magic. The tab control sends the TCM_ADJUSTRECT message to allow the app to adjust the tab size. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form.
You'll get the tabs at design time so you can easily switch between pages. The tabs are hidden at runtime, use the SelectedIndex or SelectedTab property to switch between "views".
using System;
using System.Windows.Forms;
class StackPanel : TabControl {
protected override void WndProc(ref Message m) {
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328 && !DesignMode) m.Result = (IntPtr)1;
else base.WndProc(ref m);
}
}
A good solution would be using a TabControl, and each panel is contained in a TabPage.
But I cannot find any way to hide the TabControl buttons, since I already have a
TreeView for selecting items.
For the above,
You need to set the following properties of TabControl.
tabControl.Multiline = true;
tabControl.Appearance = TabAppearance.Buttons;
tabControl.ItemSize = new System.Drawing.Size(0, 1);
tabControl.SizeMode = TabSizeMode.Fixed;
tabControl.TabStop = false;

JavaFx 2.0 Menu

I want to have a menu for my program. And I like the standard Menu look and all, but I want to place a "logout-button" on the far right side of the menu-bar.. is it possible to place it there WITHOUT having to fill up the whole menu-bar with entries?
Sincerely
Yes you can. Use the HBox#setHgrow();. This javadoc page also has an example how to use it in "Optional Layout Constraints" section. Following is taken from javadoc.
For example, if an hbox needs the TextField to be allocated all extra space:
HBox hbox = new HBox();
TextField field = new TextField();
HBox.setHgrow(field, Priority.ALWAYS);
hbox.getChildren().addAll(new Label("Search:"), field, new Button("Go"));
Briefly speaking, set Priority.ALWAYS for the button (or any control) just before the "logout-button" in a HBox. More advanced example is here: Using Built-In Layout Panes : Example 1-4

LWUIT scroll jumping issue

I need to show the only component on the form - HTMLComponent. Reaching the bottom of the form/component while vertical scrolling scroll bar jumps back to the top of the form. I need to prevent this.
I've tried to turn on/off scrolling on the form and HTMLComponent but anyway if there's a scroll bar - it will return to the top from the bottom. Also I've tried border and box layouts and additional container for HTMLComponent - no use.
Any ideas how to prevent such scrolling issue?
Try this (it works for me - LWUIT 1.5):
htmlComponent.getComponentForm().setCyclicFocus(false);
If you get a NullPointerException, call it after adding to the HtmlComponent to a form.
If you want to get rid of the bottom/top jump scroll, you can use
form.setCyclicFocus(false)
You should stick with border layout and place the HTML component in the center for this particular use case. You can disable form scrolling since the HTML component is indeed scrollable by default:
form.setScrollable(false);
HTMLComponent is itself scrollable
to prevent scrolling
setScrollable(false);
for horizontal scroll off
setScrollableX(false);
hope this will solve your issue
...or, you can paste this code on your Form class
public void keyPressed(int keyCode) {
int tecla = Display.getInstance().getGameAction(keyCode);
if(tecla == 8){
//if hit ENTER or principal key in mobile keyboard
}else if(tecla == 6){//down key
if(this.list_component_name.getSelectedIndex() < this.list_component_name.size() - 1)
this.list_component_name.setSelectedIndex(this.lista_bodegas.getSelectedIndex() + 1);
}else if(tecla == 1){//up key
if(this.list_component_name.getSelectedIndex() > 0)
this.list_component_name.setSelectedIndex(this.list_component_name.getSelectedIndex() - 1);
}
}
That's also work for me
form.serScrollable(false) or form.setCyclicFocus(false) didn't work for me.
I have a form and just a single HTMLComponent in it.
The problem is in HTMLComponent itself and disabling focus of the form won't affect it.
You can try with making the whole component focusable which might help in scrolling in a proper way. Along with this you should add your html component in Boderlayout.center of form and make form scrollable true and cyclic focus false.
In LWUITImplementation we have function getDragPathTime(). This javaDoc about this function:
/**
* Indicates what drag points are valid for the drag speed calculation.
* Points that are older then the current time - the path time are ignored
*
* #return the relevance time per point
*/
I also was problem especially in devices with OS S-60 Nokia. Lists was jumped from buttom to top. i solved this problem by change the return value. I change the value to 600( from 200). this occurs to fewer sampling and prevent the "jump".

MFC Combo-Box Control is not showing the full list of items when I click the drop-down menu

I'm coding an app in MSVS 2008, which has a ComboBox control which I initialize thru the code as below:
static char* OptionString[4] = {"Opt1",
"Opt2",
"Opt3",
"Opt4"};
BOOL CMyAppDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_Option.AddString(OptionString[0]);
m_Option.AddString(OptionString[1]);
m_Option.AddString(OptionString[2]);
m_Option.AddString(OptionString[3]);
m_Option.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
}
In the above code, m_Option is the Control variable for the ComboBox Control.
Now, when I build the app and click the down-arrow, the drop-down box shows the first option ONLY(since I've selected that thru my code). But, if i press down-arrow key on keyboard, it cycles thru the options in the order I've inserted, but never does it show more than 1 option in the box. So, In case an user wants to select option3, he has to cycle through options 1 and 2 !! Though once I select any option using the keyboard, the appropriate event handlers are fired, I'm miffed by this behaviour , as is understandable.
I'm listing the properties of the combo-box control as well - only the properties that are true(rest are set to false):
Type - Dropdown
Vertical Scrollbar
Visible Tabstop
This has bugged me for weeks now. Can anyone pls enlighten me ?
In the dialog layout designer, while designing the dialog, click the "down arrow" on the combobox. You can then drag down on the bottom of the combobox's outline to increase its height.
You need to increase the height of the drop down of combo box in designer.
Through the designer by default you can just resize the ComboBox width. If you want to resize the Drop Down List height you need to click on the dropdown arrow on the right, then you'll be able to resize the dropped control height. This seems so easy but if no-one tells you it's anything but intuitive.
Hope you understood my point.
Another method to set height of the drop down of combo box is to manualy edit rc file.
You can set 5th parameter which is responsible for height of the drop down (72 in this example).
COMBOBOX IDC_COMBOBOX1,17,35,157,72,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
We can programmatically modify dropdown height as:
CRect rctCmbCountry, rctDropDownCountry;
m_Cmb_Country.GetClientRect(&rctCmbCountry);
m_Cmb_Country.GetDroppedControlRect(&rctDropDownCountry);
itemHeight = m_Cmb_UI_Country.GetItemHeight(-1);
m_Cmb_UI_Country.GetParent()->ScreenToClient(&rctDropDownCountry);
rctDropDownCountry.bottom = rctDropDownCountry.top + rctCmbCountry.Height() + itemHeight * iNoOfITemToShowInComboDropDown;
m_Cmb_UI_Country.MoveWindow(&rctDropDownCountry);
reference: http://codetechnic.blogspot.com/2012/04/vc-mfc-how-to-set-combobox-dropdown.html#:~:text=1)%20Designer%20%2D%20through%20the%20designer,you%20it's%20anything%20but%20intuitive.
I also was suffered by this problem and finally I found the solution for my MFC applications. The problem is that I did not apply the manifest version 6 to my applications. To solve this problem, I added the code to mark the manifest as following:
ifdef _UNICODE
if defined _M_IX86
pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
elif defined _M_X64
pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
else
pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
endif
endif
It worked well.
You can refer to the link [here] (http://msdn.microsoft.com/en-us/library/windows/desktop/bb773175%28v=vs.85%29.aspx) for more details.
Hope it helps.

How do I make MFC checkbox read-only but keep text enabled?

It seems that disabling a checkbox through the Disabled property also grays out the caption. Does anyone know how to keep the caption enabled but disable input?
EDIT
Based on Paul's idea, I've done the following (now that I figured out that the static label and checkbox has a transparent property).
Added a couple checkboxes.
Set the checkbox captions to nothing.
Set checkbox transparent property to true.
Add a couple labels beside checkbox.
Change transparent property of labels to true.
Expand the checkboxes to encompass the label (so clicking on the label will trigger the check box to change).
But, this gives me very weird results. When I expand the checkbox over the label, it covers the label even though both are transparent. Again, I'm new to MFC (I'm a C# guy) so maybe I'm missing something.
Just override the onClick event and toggle the checkbox back to the way it was before.
void CMyDialog::OnBnClickedMyCheckBox()
{
m_myCheckBox.SetCheck(!m_myCheckBox.GetCheck());
}
Just make use of the Auto property, and leave it unchecked.
When clicking on it, it will not toggle any more, so basically it will be read-only, but still work fine as output.
Check Box Properties: Styles Auto Creates a check box that, when
selected, automatically toggles between checked and unchecked states.
You must set this property to True if you are using a group of check
boxes with Dialog Data Exchange.
Type: Bool, Default: True.
The quick and simple workaround is to not use the checkbox' text member (set it to ""), size down the checkbox to just the click-able square and simply place a label next to the checkbox.
To get a little fancier you could create a custom control that hosts a checkbox and a label which would enable reuse. It wold also be easier way to make the custom checkbox behave as expected for the end user e.g. being able to set the checkbox to selected or unselected when the label gets clicked as well as the checkbox itself. (The simple solution would not automatically relate the label and the checkbox. You could code that within the form but that might get ugly fast if you tend to reuse the paradigm.)
You could also look around for a 3rd-party checkbox control (there are numerous MFC UI libraries out there) but that might be overkill.
See this pseudo-layout:
You have this: (lone check box control)
[x "checkbox text"]
Lay it out like this: (label control aligned right next to the checkbox)
[x][label: "label text"]
Handle the clicked event of the label with something like:
void OnLabelClick(...) {
if (checkBox.Enabled)
checkBox.Checked = !checkBox.Checked;
}
You could un-select the box in the on-click function unless another condition exists.
void SetCheckBoxReadOnly(CButton* i_checkBox, bool i_readOnly)
{
if (!i_checkBox)
{
return;
}
// Clear/set "Auto" property
if (i_readOnly)
{
i_checkBox->ModifyStyle(BS_AUTOCHECKBOX, BS_CHECKBOX);
}
else
{
i_checkBox->ModifyStyle(BS_CHECKBOX, BS_AUTOCHECKBOX);
}
// Set a grey background for check square - looks like disabled :)
i_checkBox->SetState(i_readOnly ? TRUE : FALSE);
}

Resources