]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/univ/control.cpp | |
3 | // Purpose: universal wxControl: adds handling of mnemonics | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 14.08.00 | |
7 | // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com) | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // ============================================================================ | |
12 | // declarations | |
13 | // ============================================================================ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/wxprec.h" | |
20 | ||
21 | #ifdef __BORLANDC__ | |
22 | #pragma hdrstop | |
23 | #endif | |
24 | ||
25 | #if wxUSE_CONTROLS | |
26 | ||
27 | #include "wx/control.h" | |
28 | ||
29 | #ifndef WX_PRECOMP | |
30 | #include "wx/app.h" | |
31 | #include "wx/dcclient.h" | |
32 | #endif | |
33 | ||
34 | #include "wx/univ/renderer.h" | |
35 | #include "wx/univ/inphand.h" | |
36 | #include "wx/univ/theme.h" | |
37 | ||
38 | // ============================================================================ | |
39 | // implementation | |
40 | // ============================================================================ | |
41 | ||
42 | IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow) | |
43 | ||
44 | BEGIN_EVENT_TABLE(wxControl, wxControlBase) | |
45 | WX_EVENT_TABLE_INPUT_CONSUMER(wxControl) | |
46 | END_EVENT_TABLE() | |
47 | ||
48 | WX_FORWARD_TO_INPUT_CONSUMER(wxControl) | |
49 | ||
50 | // ---------------------------------------------------------------------------- | |
51 | // creation | |
52 | // ---------------------------------------------------------------------------- | |
53 | ||
54 | void wxControl::Init() | |
55 | { | |
56 | m_indexAccel = -1; | |
57 | } | |
58 | ||
59 | bool wxControl::Create(wxWindow *parent, | |
60 | wxWindowID id, | |
61 | const wxPoint& pos, | |
62 | const wxSize& size, | |
63 | long style, | |
64 | const wxValidator& validator, | |
65 | const wxString& name) | |
66 | { | |
67 | if ( !wxControlBase::Create(parent, id, pos, size, style, validator, name) ) | |
68 | { | |
69 | // underlying window creation failed? | |
70 | return false; | |
71 | } | |
72 | ||
73 | return true; | |
74 | } | |
75 | ||
76 | // ---------------------------------------------------------------------------- | |
77 | // mnemonics handling | |
78 | // ---------------------------------------------------------------------------- | |
79 | ||
80 | void wxControl::SetLabel(const wxString& label) | |
81 | { | |
82 | // save original label | |
83 | wxControlBase::SetLabel(label); | |
84 | ||
85 | UnivDoSetLabel(label); | |
86 | } | |
87 | ||
88 | void wxControl::UnivDoSetLabel(const wxString& label) | |
89 | { | |
90 | wxString labelOld = m_label; | |
91 | m_indexAccel = FindAccelIndex(label, &m_label); | |
92 | ||
93 | if ( m_label != labelOld ) | |
94 | { | |
95 | Refresh(); | |
96 | } | |
97 | } | |
98 | ||
99 | #endif // wxUSE_CONTROLS |