]> git.saurik.com Git - wxWidgets.git/blob - src/os2/tabctrl.cpp
WinCE fixes.
[wxWidgets.git] / src / os2 / tabctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tabctrl.cpp
3 // Purpose: wxTabCtrl
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/17/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/wx.h"
17 #endif
18
19 #include "malloc.h"
20
21 #define INCL_PM
22 #include <os2.h>
23
24 //#include "wx/msw/dib.h"
25 #include "wx/os2/tabctrl.h"
26 #include "wx/app.h"
27 #include "wx/os2/private.h"
28 #include "wx/generic/imaglist.h"
29
30 IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
31
32 BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
33 END_EVENT_TABLE()
34
35 wxTabCtrl::wxTabCtrl()
36 {
37 m_imageList = NULL;
38 }
39
40 bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
41 long style, const wxString& name)
42 {
43 m_imageList = NULL;
44
45 m_backgroundColour = *wxWHITE; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
46 // GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
47 m_foregroundColour = *wxBLACK ;
48
49 SetName(name);
50
51 int x = pos.x;
52 int y = pos.y;
53 int width = size.x;
54 int height = size.y;
55
56 m_windowStyle = style;
57
58 SetFont(* (wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL)));
59
60 SetParent(parent);
61
62 if (width <= 0)
63 width = 100;
64 if (height <= 0)
65 height = 30;
66 if (x < 0)
67 x = 0;
68 if (y < 0)
69 y = 0;
70
71 m_windowId = (id < 0 ? NewControlId() : id);
72
73 // Create the toolbar control.
74 HWND hWndTabCtrl = 0;
75 // TODO: create tab control
76
77 m_hWnd = (WXHWND) hWndTabCtrl;
78 if (parent) parent->AddChild(this);
79
80 SubclassWin((WXHWND) hWndTabCtrl);
81
82 return FALSE;
83 }
84
85 wxTabCtrl::~wxTabCtrl()
86 {
87 UnsubclassWin();
88 }
89
90 bool wxTabCtrl::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
91 {
92 wxTabEvent event(wxEVT_NULL, m_windowId);
93 wxEventType eventType = wxEVT_NULL;
94 // TODO:
95 /*
96 NMHDR* hdr1 = (NMHDR*) lParam;
97 switch ( hdr1->code )
98 {
99 case TCN_SELCHANGE:
100 eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
101 break;
102
103 case TCN_SELCHANGING:
104 eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
105 break;
106
107 case TTN_NEEDTEXT:
108 {
109 // TODO
110 // if (tool->m_shortHelpString != "")
111 // ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
112 }
113
114 default :
115 return wxControl::OS2OnNotify(idCtrl, lParam, result);
116 }
117 */
118 event.SetEventObject( this );
119 event.SetEventType(eventType);
120 event.SetInt(idCtrl) ;
121
122 return ProcessEvent(event);
123 }
124
125 // Responds to colour changes, and passes event on to children.
126 void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent& event)
127 {
128 // TODO:
129 /*
130 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
131 GetGValue(GetSysColor(COLOR_BTNFACE)),
132 GetBValue(GetSysColor(COLOR_BTNFACE)));
133
134 Refresh();
135 */
136 // Propagate the event to the non-top-level children
137 wxWindow::OnSysColourChanged(event);
138 }
139
140
141 // Delete all items
142 bool wxTabCtrl::DeleteAllItems()
143 {
144 // TODO
145 return FALSE;
146 }
147
148 // Delete an item
149 bool wxTabCtrl::DeleteItem(int item)
150 {
151 // TODO
152 return FALSE;
153 }
154
155 // Get the selection
156 int wxTabCtrl::GetSelection() const
157 {
158 // TODO
159 return 0;
160 }
161
162 // Get the tab with the current keyboard focus
163 int wxTabCtrl::GetCurFocus() const
164 {
165 // TODO
166 return 0;
167 }
168
169 // Get the associated image list
170 wxImageList* wxTabCtrl::GetImageList() const
171 {
172 return m_imageList;
173 }
174
175 // Get the number of items
176 int wxTabCtrl::GetItemCount() const
177 {
178 // TODO
179 return 0;
180 }
181
182 // Get the rect corresponding to the tab
183 bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const
184 {
185 // TODO
186 return FALSE;
187 }
188
189 // Get the number of rows
190 int wxTabCtrl::GetRowCount() const
191 {
192 // TODO
193 return 0;
194 }
195
196 // Get the item text
197 wxString wxTabCtrl::GetItemText(int item) const
198 {
199 // TODO
200 return wxString("");
201 }
202
203 // Get the item image
204 int wxTabCtrl::GetItemImage(int item) const
205 {
206 // TODO
207 return 0;
208 }
209
210 // Get the item data
211 void* wxTabCtrl::GetItemData(int item) const
212 {
213 // TODO
214 return NULL;
215 }
216
217 // Hit test
218 int wxTabCtrl::HitTest(const wxPoint& pt, long& flags)
219 {
220 // TODO
221 return 0;
222 }
223
224 // Insert an item
225 bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data)
226 {
227 // TODO
228 return FALSE;
229 }
230
231 // Set the selection
232 int wxTabCtrl::SetSelection(int item)
233 {
234 // TODO
235 return 0;
236 }
237
238 // Set the image list
239 void wxTabCtrl::SetImageList(wxImageList* imageList)
240 {
241 // TODO
242 }
243
244 // Set the text for an item
245 bool wxTabCtrl::SetItemText(int item, const wxString& text)
246 {
247 // TODO
248 return FALSE;
249 }
250
251 // Set the image for an item
252 bool wxTabCtrl::SetItemImage(int item, int image)
253 {
254 // TODO
255 return FALSE;
256 }
257
258 // Set the data for an item
259 bool wxTabCtrl::SetItemData(int item, void* data)
260 {
261 // TODO
262 return FALSE;
263 }
264
265 // Set the size for a fixed-width tab control
266 void wxTabCtrl::SetItemSize(const wxSize& size)
267 {
268 // TODO
269 }
270
271 // Set the padding between tabs
272 void wxTabCtrl::SetPadding(const wxSize& padding)
273 {
274 // TODO
275 }
276
277 #if 0
278 // These are the default colors used to map the bitmap colors
279 // to the current system colors
280
281 #define BGR_BUTTONTEXT (RGB(000,000,000)) // black
282 #define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
283 #define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
284 #define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
285 #define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
286 #define BGR_BACKGROUND (RGB(255,000,255)) // magenta
287
288 void wxMapBitmap(HBITMAP hBitmap, int width, int height)
289 {
290 COLORMAP ColorMap[] = {
291 {BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
292 {BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
293 {BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
294 {BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
295 {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
296 {BGR_BACKGROUND, COLOR_WINDOW} // magenta
297 };
298
299 int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
300 int n;
301 for ( n = 0; n < NUM_MAPS; n++)
302 {
303 ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
304 }
305
306 HBITMAP hbmOld;
307 HDC hdcMem = CreateCompatibleDC(NULL);
308
309 if (hdcMem)
310 {
311 hbmOld = SelectObject(hdcMem, hBitmap);
312
313 int i, j, k;
314 for ( i = 0; i < width; i++)
315 {
316 for ( j = 0; j < height; j++)
317 {
318 COLORREF pixel = ::GetPixel(hdcMem, i, j);
319 /*
320 BYTE red = GetRValue(pixel);
321 BYTE green = GetGValue(pixel);
322 BYTE blue = GetBValue(pixel);
323 */
324
325 for ( k = 0; k < NUM_MAPS; k ++)
326 {
327 if ( ColorMap[k].from == pixel )
328 {
329 /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
330 break;
331 }
332 }
333 }
334 }
335
336
337 SelectObject(hdcMem, hbmOld);
338 DeleteObject(hdcMem);
339 }
340
341 }
342 #endif
343
344 // Tab event
345 IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
346
347 wxTabEvent::wxTabEvent(wxEventType commandType, int id):
348 wxCommandEvent(commandType, id)
349 {
350 }
351
352