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