]> git.saurik.com Git - wxWidgets.git/blame - src/os2/tabctrl.cpp
fix a hang up in wxExecute(wxArrayString& output) overload (#4380)
[wxWidgets.git] / src / os2 / tabctrl.cpp
CommitLineData
0e320a79 1/////////////////////////////////////////////////////////////////////////////
670f9935 2// Name: src/os2/tabctrl.cpp
0e320a79 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
db6d3918
VZ
15#if wxUSE_TAB_DIALOG
16
d90895ac 17#ifndef WX_PRECOMP
670f9935
WS
18 #include "wx/wx.h"
19 #include "wx/app.h"
0e320a79
DW
20#endif
21
d90895ac
DW
22#include "malloc.h"
23
24#define INCL_PM
25#include <os2.h>
26
27//#include "wx/msw/dib.h"
28#include "wx/os2/tabctrl.h"
d90895ac 29#include "wx/os2/private.h"
1c36c09c 30#include "wx/imaglist.h"
0e320a79 31
0e320a79
DW
32IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
33
34BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
35END_EVENT_TABLE()
0e320a79
DW
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 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
DW
75 // Create the toolbar control.
76 HWND hWndTabCtrl = 0;
0e320a79 77 // TODO: create tab control
d90895ac
DW
78
79 m_hWnd = (WXHWND) hWndTabCtrl;
80 if (parent) parent->AddChild(this);
81
82 SubclassWin((WXHWND) hWndTabCtrl);
83
670f9935 84 return false;
0e320a79
DW
85}
86
87wxTabCtrl::~wxTabCtrl()
88{
d90895ac 89 UnsubclassWin();
0e320a79
DW
90}
91
6670f564
WS
92bool wxTabCtrl::OS2OnNotify(int idCtrl,
93 WXLPARAM WXUNUSED(lParam),
94 WXLPARAM *WXUNUSED(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
6670f564 149 return false;
0e320a79
DW
150}
151
152// Delete an item
6670f564 153bool wxTabCtrl::DeleteItem(int WXUNUSED(item))
0e320a79
DW
154{
155 // TODO
6670f564 156 return false;
0e320a79
DW
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
6670f564
WS
187bool wxTabCtrl::GetItemRect(int WXUNUSED(item),
188 wxRect& WXUNUSED(wxrect)) const
0e320a79
DW
189{
190 // TODO
6670f564 191 return false;
0e320a79
DW
192}
193
194// Get the number of rows
195int wxTabCtrl::GetRowCount() const
196{
197 // TODO
198 return 0;
199}
200
201// Get the item text
6670f564 202wxString wxTabCtrl::GetItemText(int WXUNUSED(item)) const
0e320a79
DW
203{
204 // TODO
6670f564 205 return wxEmptyString;
0e320a79
DW
206}
207
208// Get the item image
6670f564 209int wxTabCtrl::GetItemImage(int WXUNUSED(item)) const
0e320a79
DW
210{
211 // TODO
212 return 0;
213}
214
215// Get the item data
6670f564 216void* wxTabCtrl::GetItemData(int WXUNUSED(item)) const
0e320a79
DW
217{
218 // TODO
219 return NULL;
220}
221
222// Hit test
6670f564 223int wxTabCtrl::HitTest(const wxPoint& WXUNUSED(pt), long& WXUNUSED(flags))
0e320a79
DW
224{
225 // TODO
226 return 0;
227}
228
229// Insert an item
6670f564
WS
230bool wxTabCtrl::InsertItem(int WXUNUSED(item),
231 const wxString& WXUNUSED(text),
232 int WXUNUSED(imageId),
233 void* WXUNUSED(data))
0e320a79
DW
234{
235 // TODO
6670f564 236 return false;
0e320a79
DW
237}
238
239// Set the selection
6670f564 240int wxTabCtrl::SetSelection(int WXUNUSED(item))
0e320a79
DW
241{
242 // TODO
243 return 0;
244}
245
246// Set the image list
6670f564 247void wxTabCtrl::SetImageList(wxImageList* WXUNUSED(imageList))
0e320a79
DW
248{
249 // TODO
250}
251
252// Set the text for an item
6670f564 253bool wxTabCtrl::SetItemText(int WXUNUSED(item), const wxString& WXUNUSED(text))
0e320a79
DW
254{
255 // TODO
6670f564 256 return false;
0e320a79
DW
257}
258
259// Set the image for an item
6670f564 260bool wxTabCtrl::SetItemImage(int WXUNUSED(item), int WXUNUSED(image))
0e320a79
DW
261{
262 // TODO
6670f564 263 return false;
0e320a79
DW
264}
265
266// Set the data for an item
6670f564 267bool wxTabCtrl::SetItemData(int WXUNUSED(item), void* WXUNUSED(data))
0e320a79
DW
268{
269 // TODO
6670f564 270 return false;
0e320a79
DW
271}
272
273// Set the size for a fixed-width tab control
6670f564 274void wxTabCtrl::SetItemSize(const wxSize& WXUNUSED(size))
0e320a79
DW
275{
276 // TODO
277}
278
279// Set the padding between tabs
6670f564 280void wxTabCtrl::SetPadding(const wxSize& WXUNUSED(padding))
0e320a79
DW
281{
282 // TODO
283}
284
d90895ac
DW
285#if 0
286// These are the default colors used to map the bitmap colors
287// to the current system colors
288
289#define BGR_BUTTONTEXT (RGB(000,000,000)) // black
290#define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
291#define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
292#define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
293#define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
294#define BGR_BACKGROUND (RGB(255,000,255)) // magenta
295
296void wxMapBitmap(HBITMAP hBitmap, int width, int height)
297{
298 COLORMAP ColorMap[] = {
299 {BGR_BUTTONTEXT, COLOR_BTNTEXT}, // black
300 {BGR_BUTTONSHADOW, COLOR_BTNSHADOW}, // dark grey
301 {BGR_BUTTONFACE, COLOR_BTNFACE}, // bright grey
302 {BGR_BUTTONHILIGHT, COLOR_BTNHIGHLIGHT},// white
303 {BGR_BACKGROUNDSEL, COLOR_HIGHLIGHT}, // blue
304 {BGR_BACKGROUND, COLOR_WINDOW} // magenta
305 };
306
307 int NUM_MAPS = (sizeof(ColorMap)/sizeof(COLORMAP));
308 int n;
309 for ( n = 0; n < NUM_MAPS; n++)
310 {
311 ColorMap[n].to = ::GetSysColor(ColorMap[n].to);
312 }
313
314 HBITMAP hbmOld;
315 HDC hdcMem = CreateCompatibleDC(NULL);
316
317 if (hdcMem)
318 {
319 hbmOld = SelectObject(hdcMem, hBitmap);
320
321 int i, j, k;
322 for ( i = 0; i < width; i++)
323 {
324 for ( j = 0; j < height; j++)
325 {
326 COLORREF pixel = ::GetPixel(hdcMem, i, j);
327/*
328 BYTE red = GetRValue(pixel);
329 BYTE green = GetGValue(pixel);
330 BYTE blue = GetBValue(pixel);
331*/
332
333 for ( k = 0; k < NUM_MAPS; k ++)
334 {
335 if ( ColorMap[k].from == pixel )
336 {
337 /* COLORREF actualPixel = */ ::SetPixel(hdcMem, i, j, ColorMap[k].to);
338 break;
339 }
340 }
341 }
342 }
343
344
345 SelectObject(hdcMem, hbmOld);
346 DeleteObject(hdcMem);
347 }
348
349}
350#endif
351
0e320a79
DW
352// Tab event
353IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxCommandEvent)
354
6670f564
WS
355wxTabEvent::wxTabEvent(wxEventType commandType, int id)
356 :wxCommandEvent(commandType, id)
0e320a79
DW
357{
358}
db6d3918
VZ
359
360#endif // wxUSE_TAB_DIALOG