]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/combobox.cpp
2e3d4f6371dcf84aada86ada6b489385ce381b1f
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/combobox.cpp
3 // Purpose: wxComboBox class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
17 #include "wx/combobox.h"
20 #include "wx/settings.h"
23 #include "wx/clipbrd.h"
24 #include "wx/os2/private.h"
26 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
28 MRESULT EXPENTRY
wxComboEditWndProc( HWND hWnd
34 // The pointer to standard wnd proc
36 static WXFARPROC gfnWndprocEdit
= (WXFARPROC
)NULL
;
38 bool wxComboBox::OS2Command( WXUINT uParam
, WXWORD
WXUNUSED(wId
) )
40 long lSel
= GetSelection();
48 wxCommandEvent
vEvent( wxEVT_COMBOBOX
, GetId() );
51 vEvent
.SetEventObject(this);
52 vEvent
.SetString(GetStringSelection());
54 ProcessCommand(vEvent
);
60 wxCommandEvent
vEvent( wxEVT_TEXT
, GetId() );
65 sValue
= GetStringSelection();
66 vEvent
.SetString(sValue
);
67 vEvent
.SetEventObject(this);
68 ProcessCommand(vEvent
);
73 // There is no return value for the CBN_ notifications, so always return
74 // false from here to pass the message to DefWindowProc()
77 } // end of wxComboBox::OS2Command
79 bool wxComboBox::Create(
82 , const wxString
& rsValue
85 , const wxArrayString
& asChoices
87 , const wxValidator
& rValidator
88 , const wxString
& rsName
91 wxCArrayString
chs(asChoices
);
93 return Create(pParent
, vId
, rsValue
, rPos
, rSize
, chs
.GetCount(),
94 chs
.GetStrings(), lStyle
, rValidator
, rsName
);
97 bool wxComboBox::Create(
100 , const wxString
& rsValue
101 , const wxPoint
& rPos
102 , const wxSize
& rSize
104 , const wxString asChoices
[]
106 , const wxValidator
& rValidator
107 , const wxString
& rsName
112 if (!CreateControl( pParent
123 // Get the right style
127 lSstyle
= WS_TABSTOP
|
130 // clipping siblings does not yet work
131 // if (lStyle & wxCLIP_SIBLINGS )
132 // lSstyle |= WS_CLIPSIBLINGS;
133 if (lStyle
& wxCB_READONLY
)
134 lSstyle
|= CBS_DROPDOWNLIST
;
135 else if (lStyle
& wxCB_SIMPLE
)
136 lSstyle
|= CBS_SIMPLE
; // A list (shown always) and edit control
138 lSstyle
|= CBS_DROPDOWN
;
141 if (!OS2CreateControl( wxT("COMBOBOX")
147 // A choice/combobox normally has a white background (or other, depending
148 // on global settings) rather than inheriting the parent's background colour.
150 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW
));
152 for (int i
= 0; i
< n
; i
++)
154 Append(asChoices
[i
]);
163 // Set height to use with sizers i.e. without the dropdown listbox
164 wxFont vFont
= GetFont();
166 wxGetCharSize( GetHWND(), NULL
, &nEditHeight
, &vFont
);
167 nEditHeight
= EDIT_HEIGHT_FROM_CHAR_HEIGHT(nEditHeight
);
168 SetInitialSize(wxSize(-1,nEditHeight
+4)); // +2x2 for the border
170 if (!rsValue
.empty())
174 gfnWndprocEdit
= (WXFARPROC
)::WinSubclassWindow( (HWND
)GetHwnd()
175 ,(PFNWP
)wxComboEditWndProc
177 ::WinSetWindowULong(GetHwnd(), QWL_USER
, (ULONG
)this);
180 } // end of wxComboBox::Create
182 wxString
wxComboBox::GetValue() const
184 return HasFlag(wxCB_READONLY
) ? GetStringSelection()
185 : wxTextEntry::GetValue();
188 void wxComboBox::SetValue(const wxString
& value
)
190 if ( HasFlag(wxCB_READONLY
) )
191 SetStringSelection(value
);
193 wxTextEntry::SetValue(value
);
196 void wxComboBox::Clear()
199 if ( !HasFlag(wxCB_READONLY
) )
200 wxTextEntry::Clear();
203 bool wxComboBox::IsEditable() const
205 return !HasFlag(wxCB_READONLY
) && wxTextEntry::IsEditable();
208 bool wxComboBox::ProcessEditMsg(
217 vFlag
= SHORT1FROMMP(wParam
);
221 return (HandleChar( wParam
227 return (HandleKeyDown( wParam
232 return (HandleKeyUp( wParam
239 if (SHORT1FROMMP((MPARAM
)lParam
) == TRUE
)
240 return(HandleSetFocus((WXHWND
)(HWND
)wParam
));
242 return(HandleKillFocus((WXHWND
)(HWND
)wParam
));
245 } // end of wxComboBox::ProcessEditMsg
247 MRESULT EXPENTRY
wxComboEditWndProc(
257 // Forward some messages to the combobox
262 wxComboBox
* pCombo
= (wxComboBox
*)::WinQueryWindowULong( hWnd
266 if (pCombo
->ProcessEditMsg( uMessage
275 // TODO: Deal with tooltips here
278 return (gfnWndprocEdit(hWnd
, (ULONG
)uMessage
, (MPARAM
)wParam
, (MPARAM
)lParam
));
279 } // end of wxComboEditWndProc