I have a drop down menu "menu" for which I want to add a check item which should be checked by default.
How can I do the same in wxwidgets in C++?
check_option = menu->AppendCheckItem(CHECK_ID, wxT("Check"));
From the discussion,
In wxwidgets we don't have a one liner way to do the same. There is no other arguments that AppendCheckItem accepts. Hence we need to call the check function to do the same.
check_option->Check(true);
Related
I am learning Qt (in C++) and I have a question regarding the QDateEdit.
I want to be able to type after selecting the text in my QDateEdit. By default you cannot type if you select the whole date. I am sure there is an easy way to do that. How can I change the behaviour to start at the beginning of my QDateEdit instead of doing nothing?
Thanks in advance
In case anyone else has the same problem, the solution is rather simple.
Currently I am using the QDateTimeEdit.
You can override the "keyPressed" method, check for "ctrl+a" and use the "setSelectedSection" method with "sectionAt(0)" which allows the user to start typing at the beginning of the QDateTimeEdit.
In QT I have an item named tr("&Output") (where the & indicates a short-cut).
Now I want to use the same text without the shortcut - i.e. just "Output" translated to what-ever language, and I could not find this in the documentation.
Added: The reason for doing this is to tell the user to select a menu entry in this case "Output". So if the translation gets out of sync we might have a menu entry "Ausgabe" and telling the user to press "Ausgang", which isn't good. It could be that there is a completely different way of resolving this.
Obviously I can do tr("Output") - but that creates the need for additional translation, and the risk that they are inconsistent.
I can also do tr("&Output").replace("&", "") - but it seems like a hack. (And would need additional code to handle actual "&" in the text.)
I assume Qt has some internal mechanism for this, but is there a standardized way of accessing it?
I was reading the GTK+ 3 reference about the function gtk_button_new_from_stock. There is this part:
gtk_button_new_from_stock has been deprecated since version 3.10 and
should not be used in newly-written code. Use
gtk_button_new_with_label() instead.
Then, I read the reference about gtk_button_new_with_label(), but there is no word about the possibility of creating a button from stock.
I've tried using
gtk_button_new_with_label("gtk-media-play");
but I only get a button with the label gtk-media-play.
Any way, when I use
gtk_button_new_from_stock("gtk-media-play");
I obtain what I want but I have also a lot of warnings about deprecation.
How do I use the suggested function gtk_button_new_with_label in order to obtain a button with stock image?
How can I solve this situation without using deprecated functions?
Stock items in general have been deprecated. You probably want new_from_icon_name() instead (I think the documentation should actually refer to that). There's a standard for icon names.
I often invoke functions from my menu
Many have double entries:
- one for normal substitution
- one for subsitution with confirmation dialog (gc)
p.e.:
vnoreme 20.900 &Edit.Delete\ All\ but\ 1st\ Doubles\ :<C-U>call <SID>DeleteD("'<,'>","confirm-no")<CR>
vnoreme 20.901 &Edit.Delete\ All\ but\ 1st\ Doubles\ (gc)\ :<C-U>call <SID>DeleteD("'<,'>","confirm-yes")<CR>
Is there no better way then the one I use above to indicate a confirmation dialog?
(and to avoid all these double entries)
P.e. when a function invokes an inputdialog box, I would like to have a checkbox added where I can indicate (checking it) to add a dialog confirmation after every substitution, but unfortunately they don't exist and there is no way (as in autohotkey) to create an inputdialog GUI myself.
Well, you could change your Delete() function to ask you, whether you'd like to have each substitution being confirmed. Something like this:
fu! Delete(range)
let confirm = confirm("confirm each change?", "&yes\n&no", 1)
let cmd=printf("%ss/foobar/foobaz/g%s", a:range, confirm ? 'c' : '')
exe cmd
endfu
(this is just an example, you probably want to change at least the search and replace criteria)
Or, if you are using a simple substitution, learn to use the :ex command :promptrepl,
e.g. :promptrepl foobar will open a search/replace dialog where the search field will be set to 'foobar' and you only need to enter the replacement part and hit the buttons you like.
I have been staring at this documentation for 5 hours now. I simply cant connect the steps. If you guys can enlighten me of the stuff.
Here is the site:
http://msdn.microsoft.com/EN-US/library/bb983718(VS.110).aspx
So my problem are the following:
-at number 5, it asked me to "Set these parameters as follows:", it didnt even mention anything about where? Where to implement the constructor, and why are we using CMFCToolbarComboBoxButton? when it already asked me at step 4 to derive a clas called CFindComboButton. Shouldnt I be making a contstructor for that one instead?
-at number 4(sorry about the non organized numbering of problems), what I did is use the add class (not the class wizard), and then I picked MFC Class. I then enter the supposedly CFindComboButton and Base class as CMFCToolBarComboBoxButton. Did I do something wrong on this one? Do I have to do anything for the ID ID_EDIT_FIND_COMBO?
-When I register the ID_EDIT_FIND_COMBO at the String Table, I dont exactly know what I did. Did I just register an id for future implementation? or is it something else?
-So I cant do step 5, I skipped to step 6. All it ask me is to look for the CreateCombo method athe the override section of properties at CFindComboButton. Well I can only find 3 override. None of them are CreateCombo method. Well from there, you can tell that I'm lost.
I'm a noob at mfc so you might wanna take that in consideration.
Even though your question is a bit jump-led up, let me try and answer so that it works for you.
Create two class - one derived from CComboBox (call it CFindComboBox) and another from CMFCToolBarComboBoxButton (call it CFindComboBoxButton). First class will implement the Combobox that will be shown when you click the drop down button in the toolbar. This drop down button is implemented by CFindComboBoxButton. Hope this is clear.
Now define the constructor for the CFindComboBoxButton as CFindComboBoxButton(UNIT nID, int nImage, DWORD dwStyles) using three parameters as explained below:
Command ID of the button which will be ID_EDIT_FIND_COMBO (or anything you want to define it as). This will get defined in the String Table. Just add a new entry in String Table with ID_EDIT_FIND_COMBO as ID and a placeholder string. Don't omit the string value else the ID will not get defined. The string value can be anything as it wont be used anywhere.
Second parameter will just be a call to CCommandManager::GetCmdImage(ID_EDIT_FIND). This will return the default image used to show the drop down for combobox. In case you want to use your own custom image you can create one and instead pass the ID of that.
Third parameter is the styles you want to use. They are defined at http://msdn.microsoft.com/EN-US/library/7h63bxbe(v=vs.110).aspx but you can use the default value (CBS_DROPDOWNLIST) to start with.
Override the CreateCombo method of CMFCToolBarComboBoxButton and add its implementation to CFindComboBoxButton. In this method create and return a pointer to CFindComboBox (CComboBox derived class).
I hope this clears all the confusion and you should be on your way to have a custom Combobox embedded inside a toolbar.
take a look at the VisualStudioDemo Sample:
http://msdn.microsoft.com/en-us/library/bb983983%28v=vs.90%29.aspx
you can find the CFindComboButton implementation there