]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/control.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Vadim Zeitlin
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "control.h"
18 #include "wx/control.h"
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 IMPLEMENT_DYNAMIC_CLASS(wxControl
, wxWindow
)
28 wxControl::wxControl()
33 bool wxControl::Create( wxWindow
*parent
,
38 const wxValidator
& validator
,
39 const wxString
&name
)
41 bool ret
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
44 SetValidator(validator
);
50 void wxControl::SetLabel( const wxString
&label
)
53 for ( const wxChar
*pc
= label
; *pc
!= wxT('\0'); pc
++ )
55 if ( *pc
== wxT('&') )
58 #if 0 // it would be unused anyhow for now - kbd interface not done yet
59 if ( *pc
!= wxT('&') ) m_chAccel
= *pc
;
66 wxString
wxControl::GetLabel() const
72 wxSize
wxControl::DoGetBestSize() const
74 // Do not return any arbitrary default value...
75 wxASSERT_MSG( m_widget
, wxT("DoGetBestSize called before creation") );
80 (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget
) )->size_request
)
83 return wxSize(req
.width
, req
.height
);
87 wxString
wxControl::PrepareLabelMnemonics( const wxString
&label
) const
89 //Format mnemonics properly for GTK2. This can be called from GTK1.x, but
90 //it's not very useful because mnemonics don't exist prior to GTK2.
92 for (size_t i
= 0; i
< label
.Len(); i
++)
94 if (label
.GetChar(i
) == wxT('&'))
96 //Mnemonic escape sequence "&&" is a literal "&" in the output.
97 if (label
.GetChar(i
+ 1) == wxT('&'))
102 //Handle special case of "&_" (i.e. "_" is the mnemonic).
103 //FIXME - Is it possible to use "_" as a GTK mnemonic? Just use a
105 else if (label
.GetChar(i
+ 1) == wxT('_'))
110 //Replace WX mnemonic indicator "&" with GTK indicator "_".
116 else if (label
.GetChar(i
) == wxT('_'))
118 //Escape any underlines in the string so GTK doesn't use them.
123 label2
<< label
.GetChar(i
);
130 #endif // wxUSE_CONTROLS