]>
git.saurik.com Git - wxWidgets.git/blob - src/univ/control.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/univ/control.cpp
3 // Purpose: universal wxControl: adds handling of mnemonics
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #include "wx/wxprec.h"
30 #include "wx/control.h"
31 #include "wx/dcclient.h"
34 #include "wx/univ/renderer.h"
35 #include "wx/univ/inphand.h"
36 #include "wx/univ/theme.h"
38 // ============================================================================
40 // ============================================================================
42 IMPLEMENT_DYNAMIC_CLASS(wxControl
, wxWindow
)
44 BEGIN_EVENT_TABLE(wxControl
, wxControlBase
)
45 WX_EVENT_TABLE_INPUT_CONSUMER(wxControl
)
48 WX_FORWARD_TO_INPUT_CONSUMER(wxControl
)
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
54 void wxControl::Init()
58 m_inputHandler
= (wxInputHandler
*)NULL
;
61 bool wxControl::Create(wxWindow
*parent
,
66 const wxValidator
& validator
,
69 if ( !wxControlBase::Create(parent
, id
, pos
, size
, style
, validator
, name
) )
71 // underlying window creation failed?
78 // ----------------------------------------------------------------------------
80 // ----------------------------------------------------------------------------
83 int wxControl::FindAccelIndex(const wxString
& label
, wxString
*labelOnly
)
85 // the character following MNEMONIC_PREFIX is the accelerator for this
86 // control unless it is MNEMONIC_PREFIX too - this allows to insert
87 // literal MNEMONIC_PREFIX chars into the label
88 static const wxChar MNEMONIC_PREFIX
= _T('&');
93 labelOnly
->Alloc(label
.length());
97 for ( const wxChar
*pc
= label
; *pc
!= wxT('\0'); pc
++ )
99 if ( *pc
== MNEMONIC_PREFIX
)
102 if ( *pc
!= MNEMONIC_PREFIX
)
104 if ( indexAccel
== -1 )
106 // remember it (-1 is for MNEMONIC_PREFIX itself
107 indexAccel
= pc
- label
.c_str() - 1;
111 wxFAIL_MSG(_T("duplicate accel char in control label"));
125 void wxControl::SetLabel(const wxString
& label
)
127 wxString labelOld
= m_label
;
128 m_indexAccel
= FindAccelIndex(label
, &m_label
);
130 if ( m_label
!= labelOld
)
136 wxString
wxControl::GetLabel() const
141 #endif // wxUSE_CONTROLS