]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: control.cpp | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
dbf858b5 | 5 | // Id: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Vadim Zeitlin |
32c77a71 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
10 | #ifdef __GNUG__ | |
11 | #pragma implementation "control.h" | |
12 | #endif | |
13 | ||
14 | #include "wx/control.h" | |
15 | ||
071a2d78 | 16 | #include <gtk/gtk.h> |
034be888 | 17 | |
c801d85f KB |
18 | //----------------------------------------------------------------------------- |
19 | // wxControl | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
9abe166a | 22 | IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow) |
c801d85f | 23 | |
31528cd3 | 24 | wxControl::wxControl() |
c801d85f | 25 | { |
b292e2f5 | 26 | m_needParent = TRUE; |
6de97a3b | 27 | } |
c801d85f | 28 | |
04165bec | 29 | bool wxControl::Create( wxWindow *parent, |
31528cd3 VZ |
30 | wxWindowID id, |
31 | const wxPoint &pos, | |
32 | const wxSize &size, | |
33 | long style, | |
8d772832 | 34 | #if wxUSE_VALIDATORS |
8d772832 | 35 | const wxValidator& validator, |
04165bec RR |
36 | #endif |
37 | const wxString &name ) | |
8d772832 | 38 | { |
04165bec RR |
39 | bool ret = wxWindow::Create(parent, id, pos, size, style, name); |
40 | ||
41 | #if wxUSE_VALIDATORS | |
8d772832 | 42 | SetValidator(validator); |
8d772832 RD |
43 | #endif |
44 | ||
04165bec RR |
45 | return ret; |
46 | } | |
47 | ||
c801d85f KB |
48 | void wxControl::SetLabel( const wxString &label ) |
49 | { | |
d9ea011f | 50 | m_label.Empty(); |
223d09f6 | 51 | for ( const wxChar *pc = label; *pc != wxT('\0'); pc++ ) |
b292e2f5 | 52 | { |
223d09f6 | 53 | if ( *pc == wxT('&') ) |
31528cd3 | 54 | { |
b292e2f5 | 55 | pc++; // skip it |
32c77a71 | 56 | #if 0 // it would be unused anyhow for now - kbd interface not done yet |
223d09f6 | 57 | if ( *pc != wxT('&') ) m_chAccel = *pc; |
32c77a71 | 58 | #endif |
b292e2f5 RR |
59 | } |
60 | m_label << *pc; | |
32c77a71 | 61 | } |
6de97a3b | 62 | } |
c801d85f | 63 | |
9abe166a | 64 | wxString wxControl::GetLabel() const |
c801d85f | 65 | { |
b292e2f5 | 66 | return m_label; |
6de97a3b | 67 | } |
c801d85f KB |
68 | |
69 | ||
f68586e5 VZ |
70 | wxSize wxControl::DoGetBestSize() const |
71 | { | |
0279e844 RR |
72 | // Do not return any arbitrary default value... |
73 | wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") ); | |
74 | ||
f68586e5 | 75 | GtkRequisition req; |
33720b2d RR |
76 | req.width = 2; |
77 | req.height = 2; | |
f68586e5 VZ |
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 |