]> git.saurik.com Git - wxWidgets.git/blame - src/os2/tabctrl.cpp
moved fix
[wxWidgets.git] / src / os2 / tabctrl.cpp
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: tabctrl.cpp
3// Purpose: wxTabCtrl
d90895ac 4// Author: David Webster
0e320a79 5// Modified by:
d90895ac 6// Created: 10/17/99
0e320a79 7// RCS-ID: $Id$
d90895ac
DW
8// Copyright: (c) David Webster
9// Licence: wxWindows licence
0e320a79
DW
10/////////////////////////////////////////////////////////////////////////////
11
d90895ac
DW
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifndef WX_PRECOMP
16#include "wx/wx.h"
0e320a79
DW
17#endif
18
d90895ac
DW
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"
004fd0c8 28#include "wx/generic/imaglist.h"
0e320a79 29
0e320a79
DW
30IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
31
32BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
33END_EVENT_TABLE()
0e320a79
DW
34
35wxTabCtrl::wxTabCtrl()
36{
37 m_imageList = NULL;
38}
39
40bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
41 long style, const wxString& name)
42{
43 m_imageList = NULL;
44
d90895ac
DW
45 m_backgroundColour = *wxWHITE; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
46// GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
47 m_foregroundColour = *wxBLACK ;
48
0e320a79
DW
49 SetName(name);
50
d90895ac
DW
51 int x = pos.x;
52 int y = pos.y;
53 int width = size.x;
54 int height = size.y;
55
0e320a79
DW
56 m_windowStyle = style;
57
d90895ac
DW
58 SetFont(* (wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL)));
59
0e320a79
DW
60 SetParent(parent);
61
d90895ac
DW
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
0e320a79
DW
73 m_windowId = (id < 0 ? NewControlId() : id);
74
d90895ac 75 long tabStyle = 0;
0e320a79 76
d90895ac
DW
77 // Create the toolbar control.
78 HWND hWndTabCtrl = 0;
0e320a79 79 // TODO: create tab control
d90895ac
DW
80
81 m_hWnd = (WXHWND) hWndTabCtrl;
82 if (parent) parent->AddChild(this);
83
84 SubclassWin((WXHWND) hWndTabCtrl);
85
0e320a79
DW
86 return FALSE;
87}
88
89wxTabCtrl::~wxTabCtrl()
90{
d90895ac 91 UnsubclassWin();
0e320a79
DW
92}
93
d90895ac 94bool wxTabCtrl::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
0e320a79 95{
d90895ac
DW
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);
0e320a79
DW
127}
128
d90895ac
DW
129// Responds to colour changes, and passes event on to children.
130void 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
0e320a79
DW
145// Delete all items
146bool wxTabCtrl::DeleteAllItems()
147{
148 // TODO
149 return FALSE;
150}
151
152// Delete an item
153bool wxTabCtrl::DeleteItem(int item)
154{
155 // TODO
156 return FALSE;
157}
158
159// Get the selection
160int wxTabCtrl::GetSelection() const
161{
162 // TODO
163 return 0;
164}
165
166// Get the tab with the current keyboard focus
167int wxTabCtrl::GetCurFocus() const
168{
169 // TODO
170 return 0;
171}
172
173// Get the associated image list
174wxImageList* wxTabCtrl::GetImageList() const
175{
176 return m_imageList;
177}
178
179// Get the number of items
180int wxTabCtrl::GetItemCount() const
181{
182 // TODO
183 return 0;
184}
185
186// Get the rect corresponding to the tab
187bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const
188{
189 // TODO
190 return FALSE;
191}
192
193// Get the number of rows
194int wxTabCtrl::GetRowCount() const
195{
196 // TODO
197 return 0;
198}
199
200// Get the item text
201wxString wxTabCtrl::GetItemText(int item) const
202{
203 // TODO
204 return wxString("");
205}
206
207// Get the item image
208int wxTabCtrl::GetItemImage(int item) const
209{
210 // TODO
211 return 0;
212}
213
214// Get the item data
215void* wxTabCtrl::GetItemData(int item) const
216{
217 // TODO
218 return NULL;
219}
220
221// Hit test
222int wxTabCtrl::HitTest(const wxPoint& pt, long& flags)
223{
224 // TODO
225 return 0;
226}
227
228// Insert an item
229bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data)
230{
231 // TODO
232 return FALSE;
233}
234
235// Set the selection
236int wxTabCtrl::SetSelection(int item)
237{
238 // TODO
239 return 0;
240}
241
242// Set the image list
243void wxTabCtrl::SetImageList(wxImageList* imageList)
244{
245 // TODO
246}
247
248// Set the text for an item
249bool wxTabCtrl::SetItemText(int item, const wxString& text)
250{
251 // TODO
252 return FALSE;
253}
254
255// Set the image for an item
256bool wxTabCtrl::SetItemImage(int item, int image)
257{
258 // TODO
259 return FALSE;
260}
261
262// Set the data for an item
263bool wxTabCtrl::SetItemData(int item, void* data)
264{
265 // TODO
266 return FALSE;
267}
268
269// Set the size for a fixed-width tab control
270void wxTabCtrl::SetItemSize(const wxSize& size)
271{
272 // TODO
273}
274
275// Set the padding between tabs
276void wxTabCtrl::SetPadding(const wxSize& padding)
277{
278 // TODO
279}
280
d90895ac
DW
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
292void 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
0e320a79
DW
348// Tab event
349IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
350
351wxTabEvent::wxTabEvent(wxEventType commandType, int id):
352 wxCommandEvent(commandType, id)
353{
354}
355
d90895ac 356