]> git.saurik.com Git - wxWidgets.git/blame - src/os2/tabctrl.cpp
define MIM_STYLE and MNS_CHECKORBMP for mingw32 which doesn't have them
[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 8// Copyright: (c) David Webster
65571936 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 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
0e320a79
DW
71 m_windowId = (id < 0 ? NewControlId() : id);
72
d90895ac
DW
73 // Create the toolbar control.
74 HWND hWndTabCtrl = 0;
0e320a79 75 // TODO: create tab control
d90895ac
DW
76
77 m_hWnd = (WXHWND) hWndTabCtrl;
78 if (parent) parent->AddChild(this);
79
80 SubclassWin((WXHWND) hWndTabCtrl);
81
0e320a79
DW
82 return FALSE;
83}
84
85wxTabCtrl::~wxTabCtrl()
86{
d90895ac 87 UnsubclassWin();
0e320a79
DW
88}
89
d90895ac 90bool wxTabCtrl::OS2OnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
0e320a79 91{
d90895ac
DW
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);
0e320a79
DW
123}
124
d90895ac
DW
125// Responds to colour changes, and passes event on to children.
126void 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
0e320a79
DW
141// Delete all items
142bool wxTabCtrl::DeleteAllItems()
143{
144 // TODO
145 return FALSE;
146}
147
148// Delete an item
149bool wxTabCtrl::DeleteItem(int item)
150{
151 // TODO
152 return FALSE;
153}
154
155// Get the selection
156int wxTabCtrl::GetSelection() const
157{
158 // TODO
159 return 0;
160}
161
162// Get the tab with the current keyboard focus
163int wxTabCtrl::GetCurFocus() const
164{
165 // TODO
166 return 0;
167}
168
169// Get the associated image list
170wxImageList* wxTabCtrl::GetImageList() const
171{
172 return m_imageList;
173}
174
175// Get the number of items
176int wxTabCtrl::GetItemCount() const
177{
178 // TODO
179 return 0;
180}
181
182// Get the rect corresponding to the tab
183bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const
184{
185 // TODO
186 return FALSE;
187}
188
189// Get the number of rows
190int wxTabCtrl::GetRowCount() const
191{
192 // TODO
193 return 0;
194}
195
196// Get the item text
197wxString wxTabCtrl::GetItemText(int item) const
198{
199 // TODO
0fba44b4 200 return wxString(wxEmptyString);
0e320a79
DW
201}
202
203// Get the item image
204int wxTabCtrl::GetItemImage(int item) const
205{
206 // TODO
207 return 0;
208}
209
210// Get the item data
211void* wxTabCtrl::GetItemData(int item) const
212{
213 // TODO
214 return NULL;
215}
216
217// Hit test
218int wxTabCtrl::HitTest(const wxPoint& pt, long& flags)
219{
220 // TODO
221 return 0;
222}
223
224// Insert an item
225bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data)
226{
227 // TODO
228 return FALSE;
229}
230
231// Set the selection
232int wxTabCtrl::SetSelection(int item)
233{
234 // TODO
235 return 0;
236}
237
238// Set the image list
239void wxTabCtrl::SetImageList(wxImageList* imageList)
240{
241 // TODO
242}
243
244// Set the text for an item
245bool wxTabCtrl::SetItemText(int item, const wxString& text)
246{
247 // TODO
248 return FALSE;
249}
250
251// Set the image for an item
252bool wxTabCtrl::SetItemImage(int item, int image)
253{
254 // TODO
255 return FALSE;
256}
257
258// Set the data for an item
259bool wxTabCtrl::SetItemData(int item, void* data)
260{
261 // TODO
262 return FALSE;
263}
264
265// Set the size for a fixed-width tab control
266void wxTabCtrl::SetItemSize(const wxSize& size)
267{
268 // TODO
269}
270
271// Set the padding between tabs
272void wxTabCtrl::SetPadding(const wxSize& padding)
273{
274 // TODO
275}
276
d90895ac
DW
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
288void 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
0e320a79
DW
344// Tab event
345IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
346
347wxTabEvent::wxTabEvent(wxEventType commandType, int id):
348 wxCommandEvent(commandType, id)
349{
350}
351
d90895ac 352