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