]> git.saurik.com Git - wxWidgets.git/blob - src/os2/tabctrl.cpp
added wxUSE_PRINTF_POS_PARAMS which can be used to force the use of built-in printf...
[wxWidgets.git] / src / os2 / tabctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/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 #if wxUSE_TAB_DIALOG
16
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #include "wx/app.h"
20 #endif
21
22 #include "malloc.h"
23
24 #define INCL_PM
25 #include <os2.h>
26
27 //#include "wx/msw/dib.h"
28 #include "wx/os2/tabctrl.h"
29 #include "wx/os2/private.h"
30 #include "wx/generic/imaglist.h"
31
32 IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
33
34 BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
35 END_EVENT_TABLE()
36
37 wxTabCtrl::wxTabCtrl()
38 {
39 m_imageList = NULL;
40 }
41
42 bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
43 long style, const wxString& name)
44 {
45 m_imageList = NULL;
46
47 m_backgroundColour = *wxWHITE; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
48 // GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
49 m_foregroundColour = *wxBLACK ;
50
51 SetName(name);
52
53 int x = pos.x;
54 int y = pos.y;
55 int width = size.x;
56 int height = size.y;
57
58 m_windowStyle = style;
59
60 SetFont(* (wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL)));
61
62 SetParent(parent);
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 // Create the toolbar control.
76 HWND hWndTabCtrl = 0;
77 // TODO: create tab control
78
79 m_hWnd = (WXHWND) hWndTabCtrl;
80 if (parent) parent->AddChild(this);
81
82 SubclassWin((WXHWND) hWndTabCtrl);
83
84 return false;
85 }
86
87 wxTabCtrl::~wxTabCtrl()
88 {
89 UnsubclassWin();
90 }
91
92 bool wxTabCtrl::OS2OnNotify(int idCtrl,
93 WXLPARAM WXUNUSED(lParam),
94 WXLPARAM *WXUNUSED(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 WXUNUSED(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 WXUNUSED(item),
188 wxRect& WXUNUSED(wxrect)) const
189 {
190 // TODO
191 return false;
192 }
193
194 // Get the number of rows
195 int wxTabCtrl::GetRowCount() const
196 {
197 // TODO
198 return 0;
199 }
200
201 // Get the item text
202 wxString wxTabCtrl::GetItemText(int WXUNUSED(item)) const
203 {
204 // TODO
205 return wxEmptyString;
206 }
207
208 // Get the item image
209 int wxTabCtrl::GetItemImage(int WXUNUSED(item)) const
210 {
211 // TODO
212 return 0;
213 }
214
215 // Get the item data
216 void* wxTabCtrl::GetItemData(int WXUNUSED(item)) const
217 {
218 // TODO
219 return NULL;
220 }
221
222 // Hit test
223 int wxTabCtrl::HitTest(const wxPoint& WXUNUSED(pt), long& WXUNUSED(flags))
224 {
225 // TODO
226 return 0;
227 }
228
229 // Insert an item
230 bool wxTabCtrl::InsertItem(int WXUNUSED(item),
231 const wxString& WXUNUSED(text),
232 int WXUNUSED(imageId),
233 void* WXUNUSED(data))
234 {
235 // TODO
236 return false;
237 }
238
239 // Set the selection
240 int wxTabCtrl::SetSelection(int WXUNUSED(item))
241 {
242 // TODO
243 return 0;
244 }
245
246 // Set the image list
247 void wxTabCtrl::SetImageList(wxImageList* WXUNUSED(imageList))
248 {
249 // TODO
250 }
251
252 // Set the text for an item
253 bool wxTabCtrl::SetItemText(int WXUNUSED(item), const wxString& WXUNUSED(text))
254 {
255 // TODO
256 return false;
257 }
258
259 // Set the image for an item
260 bool wxTabCtrl::SetItemImage(int WXUNUSED(item), int WXUNUSED(image))
261 {
262 // TODO
263 return false;
264 }
265
266 // Set the data for an item
267 bool wxTabCtrl::SetItemData(int WXUNUSED(item), void* WXUNUSED(data))
268 {
269 // TODO
270 return false;
271 }
272
273 // Set the size for a fixed-width tab control
274 void wxTabCtrl::SetItemSize(const wxSize& WXUNUSED(size))
275 {
276 // TODO
277 }
278
279 // Set the padding between tabs
280 void wxTabCtrl::SetPadding(const wxSize& WXUNUSED(padding))
281 {
282 // TODO
283 }
284
285 #if 0
286 // These are the default colors used to map the bitmap colors
287 // to the current system colors
288
289 #define BGR_BUTTONTEXT (RGB(000,000,000)) // black
290 #define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
291 #define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
292 #define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
293 #define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
294 #define BGR_BACKGROUND (RGB(255,000,255)) // magenta
295
296 void wxMapBitmap(HBITMAP hBitmap, int width, int height)
297 {
298 COLORMAP ColorMap[] = {
299 {BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
300 {BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
301 {BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
302 {BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
303 {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
304 {BGR_BACKGROUND, COLOR_WINDOW} // magenta
305 };
306
307 int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
308 int n;
309 for ( n = 0; n < NUM_MAPS; n++)
310 {
311 ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
312 }
313
314 HBITMAP hbmOld;
315 HDC hdcMem = CreateCompatibleDC(NULL);
316
317 if (hdcMem)
318 {
319 hbmOld = SelectObject(hdcMem, hBitmap);
320
321 int i, j, k;
322 for ( i = 0; i < width; i++)
323 {
324 for ( j = 0; j < height; j++)
325 {
326 COLORREF pixel = ::GetPixel(hdcMem, i, j);
327 /*
328 BYTE red = GetRValue(pixel);
329 BYTE green = GetGValue(pixel);
330 BYTE blue = GetBValue(pixel);
331 */
332
333 for ( k = 0; k < NUM_MAPS; k ++)
334 {
335 if ( ColorMap[k].from == pixel )
336 {
337 /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
338 break;
339 }
340 }
341 }
342 }
343
344
345 SelectObject(hdcMem, hbmOld);
346 DeleteObject(hdcMem);
347 }
348
349 }
350 #endif
351
352 // Tab event
353 IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
354
355 wxTabEvent::wxTabEvent(wxEventType commandType, int id)
356 :wxCommandEvent(commandType, id)
357 {
358 }
359
360 #endif // wxUSE_TAB_DIALOG