]> git.saurik.com Git - wxWidgets.git/blame - src/os2/tabctrl.cpp
more non-const string literal warnings correction
[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
6670f564
WS
90bool wxTabCtrl::OS2OnNotify(int idCtrl,
91 WXLPARAM WXUNUSED(lParam),
92 WXLPARAM *WXUNUSED(result) )
0e320a79 93{
d90895ac
DW
94 wxTabEvent event(wxEVT_NULL, m_windowId);
95 wxEventType eventType = wxEVT_NULL;
96// TODO:
97/*
98 NMHDR* hdr1 = (NMHDR*) lParam;
99 switch ( hdr1->code )
100 {
101 case TCN_SELCHANGE:
102 eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
103 break;
104
105 case TCN_SELCHANGING:
106 eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
107 break;
108
109 case TTN_NEEDTEXT:
110 {
111 // TODO
112// if (tool->m_shortHelpString != "")
113// ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
114 }
115
116 default :
117 return wxControl::OS2OnNotify(idCtrl, lParam, result);
118 }
119*/
120 event.SetEventObject( this );
121 event.SetEventType(eventType);
122 event.SetInt(idCtrl) ;
123
124 return ProcessEvent(event);
0e320a79
DW
125}
126
d90895ac
DW
127// Responds to colour changes, and passes event on to children.
128void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent& event)
129{
130 // TODO:
131/*
132 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
133 GetGValue(GetSysColor(COLOR_BTNFACE)),
134 GetBValue(GetSysColor(COLOR_BTNFACE)));
135
136 Refresh();
137*/
138 // Propagate the event to the non-top-level children
139 wxWindow::OnSysColourChanged(event);
140}
141
142
0e320a79
DW
143// Delete all items
144bool wxTabCtrl::DeleteAllItems()
145{
146 // TODO
6670f564 147 return false;
0e320a79
DW
148}
149
150// Delete an item
6670f564 151bool wxTabCtrl::DeleteItem(int WXUNUSED(item))
0e320a79
DW
152{
153 // TODO
6670f564 154 return false;
0e320a79
DW
155}
156
157// Get the selection
158int wxTabCtrl::GetSelection() const
159{
160 // TODO
161 return 0;
162}
163
164// Get the tab with the current keyboard focus
165int wxTabCtrl::GetCurFocus() const
166{
167 // TODO
168 return 0;
169}
170
171// Get the associated image list
172wxImageList* wxTabCtrl::GetImageList() const
173{
174 return m_imageList;
175}
176
177// Get the number of items
178int wxTabCtrl::GetItemCount() const
179{
180 // TODO
181 return 0;
182}
183
184// Get the rect corresponding to the tab
6670f564
WS
185bool wxTabCtrl::GetItemRect(int WXUNUSED(item),
186 wxRect& WXUNUSED(wxrect)) const
0e320a79
DW
187{
188 // TODO
6670f564 189 return false;
0e320a79
DW
190}
191
192// Get the number of rows
193int wxTabCtrl::GetRowCount() const
194{
195 // TODO
196 return 0;
197}
198
199// Get the item text
6670f564 200wxString wxTabCtrl::GetItemText(int WXUNUSED(item)) const
0e320a79
DW
201{
202 // TODO
6670f564 203 return wxEmptyString;
0e320a79
DW
204}
205
206// Get the item image
6670f564 207int wxTabCtrl::GetItemImage(int WXUNUSED(item)) const
0e320a79
DW
208{
209 // TODO
210 return 0;
211}
212
213// Get the item data
6670f564 214void* wxTabCtrl::GetItemData(int WXUNUSED(item)) const
0e320a79
DW
215{
216 // TODO
217 return NULL;
218}
219
220// Hit test
6670f564 221int wxTabCtrl::HitTest(const wxPoint& WXUNUSED(pt), long& WXUNUSED(flags))
0e320a79
DW
222{
223 // TODO
224 return 0;
225}
226
227// Insert an item
6670f564
WS
228bool wxTabCtrl::InsertItem(int WXUNUSED(item),
229 const wxString& WXUNUSED(text),
230 int WXUNUSED(imageId),
231 void* WXUNUSED(data))
0e320a79
DW
232{
233 // TODO
6670f564 234 return false;
0e320a79
DW
235}
236
237// Set the selection
6670f564 238int wxTabCtrl::SetSelection(int WXUNUSED(item))
0e320a79
DW
239{
240 // TODO
241 return 0;
242}
243
244// Set the image list
6670f564 245void wxTabCtrl::SetImageList(wxImageList* WXUNUSED(imageList))
0e320a79
DW
246{
247 // TODO
248}
249
250// Set the text for an item
6670f564 251bool wxTabCtrl::SetItemText(int WXUNUSED(item), const wxString& WXUNUSED(text))
0e320a79
DW
252{
253 // TODO
6670f564 254 return false;
0e320a79
DW
255}
256
257// Set the image for an item
6670f564 258bool wxTabCtrl::SetItemImage(int WXUNUSED(item), int WXUNUSED(image))
0e320a79
DW
259{
260 // TODO
6670f564 261 return false;
0e320a79
DW
262}
263
264// Set the data for an item
6670f564 265bool wxTabCtrl::SetItemData(int WXUNUSED(item), void* WXUNUSED(data))
0e320a79
DW
266{
267 // TODO
6670f564 268 return false;
0e320a79
DW
269}
270
271// Set the size for a fixed-width tab control
6670f564 272void wxTabCtrl::SetItemSize(const wxSize& WXUNUSED(size))
0e320a79
DW
273{
274 // TODO
275}
276
277// Set the padding between tabs
6670f564 278void wxTabCtrl::SetPadding(const wxSize& WXUNUSED(padding))
0e320a79
DW
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
6670f564
WS
353wxTabEvent::wxTabEvent(wxEventType commandType, int id)
354 :wxCommandEvent(commandType, id)
0e320a79
DW
355{
356}