Compilation fix,
[wxWidgets.git] / src / gtk / control.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: control.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Vadim Zeitlin
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "control.h"
12 #endif
13
14 #include "wx/control.h"
15
16 #include <gtk/gtk.h>
17
18 //-----------------------------------------------------------------------------
19 // wxControl
20 //-----------------------------------------------------------------------------
21
22 IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow)
23
24 wxControl::wxControl()
25 {
26 m_needParent = TRUE;
27 }
28
29 bool wxControl::Create( wxWindow *parent,
30 wxWindowID id,
31 const wxPoint &pos,
32 const wxSize &size,
33 long style,
34 #if wxUSE_VALIDATORS
35 const wxValidator& validator,
36 #endif
37 const wxString &name )
38 {
39 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
40
41 #if wxUSE_VALIDATORS
42 SetValidator(validator);
43 #endif
44
45 return ret;
46 }
47
48 void wxControl::SetLabel( const wxString &label )
49 {
50 m_label.Empty();
51 for ( const wxChar *pc = label; *pc != wxT('\0'); pc++ )
52 {
53 if ( *pc == wxT('&') )
54 {
55 pc++; // skip it
56 #if 0 // it would be unused anyhow for now - kbd interface not done yet
57 if ( *pc != wxT('&') ) m_chAccel = *pc;
58 #endif
59 }
60 m_label << *pc;
61 }
62 }
63
64 wxString wxControl::GetLabel() const
65 {
66 return m_label;
67 }
68
69
70 wxSize wxControl::DoGetBestSize() const
71 {
72 // Do not return any arbitrary default value...
73 wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") );
74
75 GtkRequisition req;
76 req.width = 2;
77 req.height = 2;
78 (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request )
79 (m_widget, &req );
80
81 return wxSize(req.width, req.height);
82 }
83