]>
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 /////////////////////////////////////////////////////////////////////////////
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "control.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
21 #include "wx/control.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 IMPLEMENT_DYNAMIC_CLASS(wxControl
, wxWindow
)
31 wxControl::wxControl()
36 bool wxControl::Create( wxWindow
*parent
,
41 const wxValidator
& validator
,
42 const wxString
&name
)
44 bool ret
= wxWindow::Create(parent
, id
, pos
, size
, style
, name
);
47 SetValidator(validator
);
53 void wxControl::SetLabel( const wxString
&label
)
56 for ( const wxChar
*pc
= label
; *pc
!= wxT('\0'); pc
++ )
58 if ( *pc
== wxT('&') )
61 #if 0 // it would be unused anyhow for now - kbd interface not done yet
62 if ( *pc
!= wxT('&') ) m_chAccel
= *pc
;
69 wxString
wxControl::GetLabel() const
75 wxSize
wxControl::DoGetBestSize() const
77 // Do not return any arbitrary default value...
78 wxASSERT_MSG( m_widget
, wxT("DoGetBestSize called before creation") );
83 (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget
) )->size_request
)
86 return wxSize(req
.width
, req
.height
);
90 wxString
wxControl::PrepareLabelMnemonics( const wxString
&label
) const
92 //Format mnemonics properly for GTK2. This can be called from GTK1.x, but
93 //it's not very useful because mnemonics don't exist prior to GTK2.
95 for (size_t i
= 0; i
< label
.Len(); i
++)
97 if (label
.GetChar(i
) == wxT('&'))
99 //Mnemonic escape sequence "&&" is a literal "&" in the output.
100 if (label
.GetChar(i
+ 1) == wxT('&'))
105 //Handle special case of "&_" (i.e. "_" is the mnemonic).
106 //FIXME - Is it possible to use "_" as a GTK mnemonic? Just use a
108 else if (label
.GetChar(i
+ 1) == wxT('_'))
113 //Replace WX mnemonic indicator "&" with GTK indicator "_".
119 else if (label
.GetChar(i
) == wxT('_'))
121 //Escape any underlines in the string so GTK doesn't use them.
126 label2
<< label
.GetChar(i
);
133 #endif // wxUSE_CONTROLS