]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/control.cpp
correcting a missing redraw area on certain resize operations when window has a border
[wxWidgets.git] / src / gtk / control.cpp
CommitLineData
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
14f355c2 10#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
11#pragma implementation "control.h"
12#endif
13
14f355c2
VS
14// For compilers that support precompilation, includes "wx.h".
15#include "wx/wxprec.h"
16
1e6feb95
VZ
17#include "wx/defs.h"
18
19#if wxUSE_CONTROLS
20
c801d85f
KB
21#include "wx/control.h"
22
071a2d78 23#include <gtk/gtk.h>
034be888 24
c801d85f
KB
25//-----------------------------------------------------------------------------
26// wxControl
27//-----------------------------------------------------------------------------
28
9abe166a 29IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow)
c801d85f 30
31528cd3 31wxControl::wxControl()
c801d85f 32{
b292e2f5 33 m_needParent = TRUE;
6de97a3b 34}
c801d85f 35
04165bec 36bool wxControl::Create( wxWindow *parent,
31528cd3
VZ
37 wxWindowID id,
38 const wxPoint &pos,
39 const wxSize &size,
40 long style,
8d772832 41 const wxValidator& validator,
04165bec 42 const wxString &name )
8d772832 43{
04165bec
RR
44 bool ret = wxWindow::Create(parent, id, pos, size, style, name);
45
46#if wxUSE_VALIDATORS
8d772832 47 SetValidator(validator);
8d772832
RD
48#endif
49
04165bec
RR
50 return ret;
51}
52
c801d85f
KB
53void wxControl::SetLabel( const wxString &label )
54{
d9ea011f 55 m_label.Empty();
223d09f6 56 for ( const wxChar *pc = label; *pc != wxT('\0'); pc++ )
b292e2f5 57 {
223d09f6 58 if ( *pc == wxT('&') )
31528cd3 59 {
b292e2f5 60 pc++; // skip it
32c77a71 61#if 0 // it would be unused anyhow for now - kbd interface not done yet
223d09f6 62 if ( *pc != wxT('&') ) m_chAccel = *pc;
32c77a71 63#endif
b292e2f5
RR
64 }
65 m_label << *pc;
32c77a71 66 }
6de97a3b 67}
c801d85f 68
9abe166a 69wxString wxControl::GetLabel() const
c801d85f 70{
b292e2f5 71 return m_label;
6de97a3b 72}
c801d85f
KB
73
74
f68586e5
VZ
75wxSize wxControl::DoGetBestSize() const
76{
0279e844
RR
77 // Do not return any arbitrary default value...
78 wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") );
79
f68586e5 80 GtkRequisition req;
33720b2d
RR
81 req.width = 2;
82 req.height = 2;
2afa14f2 83 (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request )
f68586e5
VZ
84 (m_widget, &req );
85
86 return wxSize(req.width, req.height);
87}
88
393cbb8f 89#ifdef __WXGTK20__
eaafd2f8
VS
90wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const
91{
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.
94 wxString label2;
95 for (size_t i = 0; i < label.Len(); i++)
96 {
97 if (label.GetChar(i) == wxT('&'))
98 {
99 //Mnemonic escape sequence "&&" is a literal "&" in the output.
100 if (label.GetChar(i + 1) == wxT('&'))
101 {
102 label2 << wxT('&');
103 i++;
104 }
105 //Handle special case of "&_" (i.e. "_" is the mnemonic).
106 //FIXME - Is it possible to use "_" as a GTK mnemonic? Just use a
107 //dash for now.
108 else if (label.GetChar(i + 1) == wxT('_'))
109 {
110 label2 << wxT("_-");
111 i++;
112 }
113 //Replace WX mnemonic indicator "&" with GTK indicator "_".
114 else
115 {
116 label2 << wxT('_');
117 }
118 }
119 else if (label.GetChar(i) == wxT('_'))
120 {
121 //Escape any underlines in the string so GTK doesn't use them.
122 label2 << wxT("__");
123 }
124 else
125 {
126 label2 << label.GetChar(i);
127 }
128 }
129 return label2;
130}
393cbb8f 131#endif
eaafd2f8 132
1e6feb95
VZ
133#endif // wxUSE_CONTROLS
134