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