]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/control.cpp
Corrected some things in, and some thing revealed by
[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 wxControl::wxControl( wxWindow *parent,
30 wxWindowID id,
31 const wxPoint &pos,
32 const wxSize &size,
33 long style,
34 const wxString &name )
35 {
36 (void)Create(parent, id, pos, size, style, name);
37 }
38
39 #if wxUSE_VALIDATORS
40 wxControl::wxControl( wxWindow *parent,
41 wxWindowID id,
42 const wxPoint &pos,
43 const wxSize &size,
44 long style,
45 const wxValidator& validator,
46 const wxString &name)
47 {
48 (void)Create(parent, id, pos, size, style, name);
49 SetValidator(validator);
50 }
51 #endif
52
53 void wxControl::SetLabel( const wxString &label )
54 {
55 m_label.Empty();
56 for ( const wxChar *pc = label; *pc != wxT('\0'); pc++ )
57 {
58 if ( *pc == wxT('&') )
59 {
60 pc++; // skip it
61 #if 0 // it would be unused anyhow for now - kbd interface not done yet
62 if ( *pc != wxT('&') ) m_chAccel = *pc;
63 #endif
64 }
65 m_label << *pc;
66 }
67 }
68
69 wxString wxControl::GetLabel() const
70 {
71 return m_label;
72 }
73
74
75 wxSize wxControl::DoGetBestSize() const
76 {
77 // Do not return any arbitrary default value...
78 wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") );
79
80 GtkRequisition req;
81 req.width = 2;
82 req.height = 2;
83 (* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request )
84 (m_widget, &req );
85
86 return wxSize(req.width, req.height);
87 }
88