]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/control.cpp
Removed duplicate WM line from motif/frame.cpp
[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/defs.h"
15
16 #if wxUSE_CONTROLS
17
18 #include "wx/control.h"
19
20 #include <gtk/gtk.h>
21
22 //-----------------------------------------------------------------------------
23 // wxControl
24 //-----------------------------------------------------------------------------
25
26 IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow)
27
28 wxControl::wxControl()
29 {
30 m_needParent = TRUE;
31 }
32
33 bool wxControl::Create( wxWindow *parent,
34 wxWindowID id,
35 const wxPoint &pos,
36 const wxSize &size,
37 long style,
38 const wxValidator& validator,
39 const wxString &name )
40 {
41 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
42
43 #if wxUSE_VALIDATORS
44 SetValidator(validator);
45 #endif
46
47 return ret;
48 }
49
50 void wxControl::SetLabel( const wxString &label )
51 {
52 m_label.Empty();
53 for ( const wxChar *pc = label; *pc != wxT('\0'); pc++ )
54 {
55 if ( *pc == wxT('&') )
56 {
57 pc++; // skip it
58 #if 0 // it would be unused anyhow for now - kbd interface not done yet
59 if ( *pc != wxT('&') ) m_chAccel = *pc;
60 #endif
61 }
62 m_label << *pc;
63 }
64 }
65
66 wxString wxControl::GetLabel() const
67 {
68 return m_label;
69 }
70
71
72 wxSize wxControl::DoGetBestSize() const
73 {
74 // Do not return any arbitrary default value...
75 wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") );
76
77 GtkRequisition req;
78 req.width = 2;
79 req.height = 2;
80 (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
81 (m_widget, &req );
82
83 return wxSize(req.width, req.height);
84 }
85
86 #endif // wxUSE_CONTROLS
87