Logo Search packages:      
Sourcecode: codeblocks version File versions  Download package

wxWindow * wxPropertyGrid::GenerateEditorTextCtrl ( const wxPoint &  pos,
const wxSize &  sz,
const wxString &  value,
wxWindow *  secondary,
int  extraStyle = 0,
int  maxLen = 0 
)

Shortcut for creating text editor widget.

Parameters:
posSame as pos given for CreateEditor.
szSame as sz given for CreateEditor.
valueInitial text for wxTextCtrl.
secondaryIf right-side control, such as button, also created, then create it first and pass it as this parameter.
extraStyleExtra style flags to pass for wxTextCtrl.
Remarks:
Note that this should generally be called only by new classes derived from wxPGProperty.

Definition at line 4878 of file propgrid.cpp.

References FixPosForTextCtrl(), and wxPG_PROP_READONLY.

{
    int tcFlags = wxTE_PROCESS_ENTER | extraStyle;

      if ( m_selected->HasFlag(wxPG_PROP_READONLY) )
            tcFlags |= wxTE_READONLY;

    wxPoint p(pos.x,pos.y);
    wxSize s(sz.x,sz.y);

   // Need to reduce width of text control on Mac
#if defined(__WXMAC__)
   s.x -= 8;
#endif

     // Take button into acccount
    if ( secondary )
    {
        s.x -= (secondary->GetSize().x + wxPG_TEXTCTRL_AND_BUTTON_SPACING);
        m_iFlags &= ~(wxPG_FL_PRIMARY_FILLS_ENTIRE);
    }

    // If the height is significantly higher, then use border, and fill the rect exactly.
    bool hasSpecialSize = false;

    if ( (sz.y - m_lineHeight) > 5 )
        hasSpecialSize = true;

#if wxPG_NAT_TEXTCTRL_BORDER_ANY

    // Create clipper window
    wxPGClipperWindow* wnd = new wxPGClipperWindow();
#if defined(__WXMSW__)
    wnd->Hide();
#endif
    wnd->Create(this,wxPG_SUBID1,p,s);

    // This generates rect of the control inside the clipper window
    if ( !hasSpecialSize )
        wnd->GetControlRect(wxPG_NAT_TEXTCTRL_BORDER_X, wxPG_NAT_TEXTCTRL_BORDER_Y, p, s);
    else
        wnd->GetControlRect(0, 0, p, s);

    wxWindow* ctrlParent = wnd;

#else

    wxWindow* ctrlParent = this;

    if ( !hasSpecialSize )
        tcFlags |= wxNO_BORDER;

#endif

    wxTextCtrl* tc = new wxTextCtrl();

#if defined(__WXMSW__) && !wxPG_NAT_TEXTCTRL_BORDER_ANY
    tc->Hide();
#endif
    tc->Create(ctrlParent,wxPG_SUBID1,value, p, s,tcFlags);

#if wxPG_NAT_TEXTCTRL_BORDER_ANY
    wxWindow* ed = wnd;
    wnd->SetControl(tc);
#else
    wxWindow* ed = tc;
#endif

    // Center the control vertically
    if ( !hasSpecialSize )
        FixPosForTextCtrl(ed);

#ifdef __WXMSW__
    ed->Show();
    if ( secondary )
        secondary->Show();
#endif

    // Set maximum length
    if ( maxLen > 0 )
        tc->SetMaxLength( maxLen );

    return (wxWindow*) ed;
}

Here is the call graph for this function:


Generated by  Doxygen 1.6.0   Back to index