]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/os2/tabctrl.cpp
added HAVE_FSYNC and wxHAVE_PTHREAD_CLEANUP (replacing HAVE_THREAD_CLEANUP_FUNCTIONS)
[wxWidgets.git] / src / os2 / tabctrl.cpp
... / ...
CommitLineData
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/generic/imaglist.h"
29
30IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
31
32BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
33END_EVENT_TABLE()
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
45 m_backgroundColour = *wxWHITE; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
46// GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
47 m_foregroundColour = *wxBLACK ;
48
49 SetName(name);
50
51 int x = pos.x;
52 int y = pos.y;
53 int width = size.x;
54 int height = size.y;
55
56 m_windowStyle = style;
57
58 SetFont(* (wxTheFontList->FindOrCreateFont(11, wxSWISS, wxNORMAL, wxNORMAL)));
59
60 SetParent(parent);
61
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
71 m_windowId = (id < 0 ? NewControlId() : id);
72
73 // Create the toolbar control.
74 HWND hWndTabCtrl = 0;
75 // TODO: create tab control
76
77 m_hWnd = (WXHWND) hWndTabCtrl;
78 if (parent) parent->AddChild(this);
79
80 SubclassWin((WXHWND) hWndTabCtrl);
81
82 return FALSE;
83}
84
85wxTabCtrl::~wxTabCtrl()
86{
87 UnsubclassWin();
88}
89
90bool wxTabCtrl::OS2OnNotify(int idCtrl,
91 WXLPARAM WXUNUSED(lParam),
92 WXLPARAM *WXUNUSED(result) )
93{
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);
125}
126
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
143// Delete all items
144bool wxTabCtrl::DeleteAllItems()
145{
146 // TODO
147 return false;
148}
149
150// Delete an item
151bool wxTabCtrl::DeleteItem(int WXUNUSED(item))
152{
153 // TODO
154 return false;
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
185bool wxTabCtrl::GetItemRect(int WXUNUSED(item),
186 wxRect& WXUNUSED(wxrect)) const
187{
188 // TODO
189 return false;
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
200wxString wxTabCtrl::GetItemText(int WXUNUSED(item)) const
201{
202 // TODO
203 return wxEmptyString;
204}
205
206// Get the item image
207int wxTabCtrl::GetItemImage(int WXUNUSED(item)) const
208{
209 // TODO
210 return 0;
211}
212
213// Get the item data
214void* wxTabCtrl::GetItemData(int WXUNUSED(item)) const
215{
216 // TODO
217 return NULL;
218}
219
220// Hit test
221int wxTabCtrl::HitTest(const wxPoint& WXUNUSED(pt), long& WXUNUSED(flags))
222{
223 // TODO
224 return 0;
225}
226
227// Insert an item
228bool wxTabCtrl::InsertItem(int WXUNUSED(item),
229 const wxString& WXUNUSED(text),
230 int WXUNUSED(imageId),
231 void* WXUNUSED(data))
232{
233 // TODO
234 return false;
235}
236
237// Set the selection
238int wxTabCtrl::SetSelection(int WXUNUSED(item))
239{
240 // TODO
241 return 0;
242}
243
244// Set the image list
245void wxTabCtrl::SetImageList(wxImageList* WXUNUSED(imageList))
246{
247 // TODO
248}
249
250// Set the text for an item
251bool wxTabCtrl::SetItemText(int WXUNUSED(item), const wxString& WXUNUSED(text))
252{
253 // TODO
254 return false;
255}
256
257// Set the image for an item
258bool wxTabCtrl::SetItemImage(int WXUNUSED(item), int WXUNUSED(image))
259{
260 // TODO
261 return false;
262}
263
264// Set the data for an item
265bool wxTabCtrl::SetItemData(int WXUNUSED(item), void* WXUNUSED(data))
266{
267 // TODO
268 return false;
269}
270
271// Set the size for a fixed-width tab control
272void wxTabCtrl::SetItemSize(const wxSize& WXUNUSED(size))
273{
274 // TODO
275}
276
277// Set the padding between tabs
278void wxTabCtrl::SetPadding(const wxSize& WXUNUSED(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
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
350// Tab event
351IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
352
353wxTabEvent::wxTabEvent(wxEventType commandType, int id)
354 :wxCommandEvent(commandType, id)
355{
356}