]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/combobox.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/combobox.cpp
3 // Purpose: wxComboBox class
4 // Author: David Webster
7 // Copyright: (c) David Webster
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
16 #include "wx/combobox.h"
19 #include "wx/settings.h"
22 #include "wx/clipbrd.h"
23 #include "wx/os2/private.h"
25 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
27 MRESULT EXPENTRY
wxComboEditWndProc( HWND hWnd
33 // The pointer to standard wnd proc
35 static WXFARPROC gfnWndprocEdit
= (WXFARPROC
)NULL
;
37 bool wxComboBox::OS2Command( WXUINT uParam
, WXWORD
WXUNUSED(wId
) )
39 long lSel
= GetSelection();
47 wxCommandEvent
vEvent( wxEVT_COMBOBOX
, GetId() );
50 vEvent
.SetEventObject(this);
51 vEvent
.SetString(GetStringSelection());
53 ProcessCommand(vEvent
);
59 wxCommandEvent
vEvent( wxEVT_TEXT
, GetId() );
64 sValue
= GetStringSelection();
65 vEvent
.SetString(sValue
);
66 vEvent
.SetEventObject(this);
67 ProcessCommand(vEvent
);
72 // There is no return value for the CBN_ notifications, so always return
73 // false from here to pass the message to DefWindowProc()
76 } // end of wxComboBox::OS2Command
78 bool wxComboBox::Create(
81 , const wxString
& rsValue
84 , const wxArrayString
& asChoices
86 , const wxValidator
& rValidator
87 , const wxString
& rsName
90 wxCArrayString
chs(asChoices
);
92 return Create(pParent
, vId
, rsValue
, rPos
, rSize
, chs
.GetCount(),
93 chs
.GetStrings(), lStyle
, rValidator
, rsName
);
96 bool wxComboBox::Create(
99 , const wxString
& rsValue
100 , const wxPoint
& rPos
101 , const wxSize
& rSize
103 , const wxString asChoices
[]
105 , const wxValidator
& rValidator
106 , const wxString
& rsName
111 if (!CreateControl( pParent
122 // Get the right style
126 lSstyle
= WS_TABSTOP
|
129 // clipping siblings does not yet work
130 // if (lStyle & wxCLIP_SIBLINGS )
131 // lSstyle |= WS_CLIPSIBLINGS;
132 if (lStyle
& wxCB_READONLY
)
133 lSstyle
|= CBS_DROPDOWNLIST
;
134 else if (lStyle
& wxCB_SIMPLE
)
135 lSstyle
|= CBS_SIMPLE
; // A list (shown always) and edit control
137 lSstyle
|= CBS_DROPDOWN
;
140 if (!OS2CreateControl( wxT("COMBOBOX")
146 // A choice/combobox normally has a white background (or other, depending
147 // on global settings) rather than inheriting the parent's background colour.
149 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
));
151 for (int i
= 0; i
< n
; i
++)
153 Append(asChoices
[i
]);
162 // Set height to use with sizers i.e. without the dropdown listbox
163 wxFont vFont
= GetFont();
165 wxGetCharSize( GetHWND(), NULL
, &nEditHeight
, &vFont
);
166 nEditHeight
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(nEditHeight
);
167 SetInitialSize(wxSize(-1,nEditHeight
+4)); // +2x2 for the border
169 if (!rsValue
.empty())
173 gfnWndprocEdit
= (WXFARPROC
)::WinSubclassWindow( (HWND
)GetHwnd()
174 ,(PFNWP
)wxComboEditWndProc
176 ::WinSetWindowULong(GetHwnd(), QWL_USER
, (ULONG
)this);
179 } // end of wxComboBox::Create
181 wxString
wxComboBox::GetValue() const
183 return HasFlag(wxCB_READONLY
) ? GetStringSelection()
184 : wxTextEntry::GetValue();
187 void wxComboBox::SetValue(const wxString
& value
)
189 if ( HasFlag(wxCB_READONLY
) )
190 SetStringSelection(value
);
192 wxTextEntry::SetValue(value
);
195 void wxComboBox::Clear()
198 if ( !HasFlag(wxCB_READONLY
) )
199 wxTextEntry::Clear();
202 bool wxComboBox::IsEditable() const
204 return !HasFlag(wxCB_READONLY
) && wxTextEntry::IsEditable();
207 bool wxComboBox::ProcessEditMsg(
216 vFlag
= SHORT1FROMMP(wParam
);
220 return (HandleChar( wParam
226 return (HandleKeyDown( wParam
231 return (HandleKeyUp( wParam
238 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
239 return(HandleSetFocus((WXHWND
)(HWND
)wParam
));
241 return(HandleKillFocus((WXHWND
)(HWND
)wParam
));
244 } // end of wxComboBox::ProcessEditMsg
246 MRESULT EXPENTRY
wxComboEditWndProc(
256 // Forward some messages to the combobox
261 wxComboBox
* pCombo
= (wxComboBox
*)::WinQueryWindowULong( hWnd
265 if (pCombo
->ProcessEditMsg( uMessage
274 // TODO: Deal with tooltips here
277 return (gfnWndprocEdit(hWnd
, (ULONG
)uMessage
, (MPARAM
)wParam
, (MPARAM
)lParam
));
278 } // end of wxComboEditWndProc