views:

22

answers:

1

Question

I'm trying to create a basic wxWidgets program with a text entry box, in the constructor there is a variable wxTextCtrlNameStr - in researching I can't seem to find wxTextCtrlNameStr? any help?

Given Code documentation:

wxTextCtrl(wxWindow* parent, wxWindowID id, const wxString& value = "", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr)

My Code:

MainFrame::MainFrame(const wxString& title)
       : wxFrame(NULL, wxID_ANY, title)
{
 wxButton * Centigrade = new wxButton(this, 
                                      BUTTON_CENTIGRADE, 
                                      _T("to Centigrade"), 
                                      wxPoint(20, 20), 
                                      wxDefaultSize, 
                                      0);
 wxButton * Fahrenheit = new wxButton(this, 
                                      BUTTON_FAHRENHEIT, 
                                      _T("to Fahrenheit"), 
                                      wxPoint(20, 40), 
                                      wxDefaultSize, 
                                      0);

 F_txt = new wxTextCtrl(this, 
         TXT_F_Main, 
         "0", 
         wxDefaultPosition, 
         wxDefaultSize, 
         wxDefaultValidator, 
         wxTextCtrlNameStr);  /***********************************************/
 C_txt = new wxTextCtrl(this, 
         TXT_C_Main, 
         "0", 
         wxDefaultPosition, 
         wxDefaultSize, 
         wxDefaultValidator, 
         wxTextCtrlNameStr);  /***********************************************/

... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... 
+1  A: 

It's the name of the window. By default wxTextCtrlNameStr might be simply "text".

You probably don't need it, but it gives you an alternative way to identify widgets.

For example it allows you to find a Window or Widget if you know the name it was given when created: wxWindow::FindWindowByName

Note that the argument has a default. If you are not going to use window names, just don't pass anything, as you don't pass the name to wxButton constructor (defaults to "button").

UncleBens
so basically it's an overloaded method? are all/most of the wxWidgets like this?
Wallter
It is a function/constructor with default arguments. Yes, all widgets have defaults for most things. For example, in your code where you create buttons with `wxDefaultSize` and 0 for styles, you could just omit these parameters and get the exact same result.
UncleBens