]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/tabctrl.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
26 //#include "wx/msw/dib.h"
27 #include "wx/os2/tabctrl.h"
29 #include "wx/os2/private.h"
30 #include "wx/generic/imaglist.h"
32 IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl
, wxControl
)
34 BEGIN_EVENT_TABLE(wxTabCtrl
, wxControl
)
37 wxTabCtrl::wxTabCtrl()
42 bool wxTabCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
43 long style
, const wxString
& name
)
47 m_backgroundColour
= *wxWHITE
; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
48 // GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
49 m_foregroundColour
= *wxBLACK
;
58 m_windowStyle
= style
;
60 SetFont(* (wxTheFontList
->FindOrCreateFont(11, wxSWISS
, wxNORMAL
, wxNORMAL
)));
73 m_windowId
= (id
< 0 ? NewControlId() : id
);
75 // Create the toolbar control.
77 // TODO: create tab control
79 m_hWnd
= (WXHWND
) hWndTabCtrl
;
80 if (parent
) parent
->AddChild(this);
82 SubclassWin((WXHWND
) hWndTabCtrl
);
87 wxTabCtrl::~wxTabCtrl()
92 bool wxTabCtrl::OS2OnNotify(int idCtrl
,
93 WXLPARAM
WXUNUSED(lParam
),
94 WXLPARAM
*WXUNUSED(result
) )
96 wxTabEvent
event(wxEVT_NULL
, m_windowId
);
97 wxEventType eventType
= wxEVT_NULL
;
100 NMHDR* hdr1 = (NMHDR*) lParam;
101 switch ( hdr1->code )
104 eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
107 case TCN_SELCHANGING:
108 eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
114 // if (tool->m_shortHelpString != "")
115 // ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
119 return wxControl::OS2OnNotify(idCtrl, lParam, result);
122 event
.SetEventObject( this );
123 event
.SetEventType(eventType
);
124 event
.SetInt(idCtrl
) ;
126 return ProcessEvent(event
);
129 // Responds to colour changes, and passes event on to children.
130 void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent
& event
)
134 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
135 GetGValue(GetSysColor(COLOR_BTNFACE)),
136 GetBValue(GetSysColor(COLOR_BTNFACE)));
140 // Propagate the event to the non-top-level children
141 wxWindow::OnSysColourChanged(event
);
146 bool wxTabCtrl::DeleteAllItems()
153 bool wxTabCtrl::DeleteItem(int WXUNUSED(item
))
160 int wxTabCtrl::GetSelection() const
166 // Get the tab with the current keyboard focus
167 int wxTabCtrl::GetCurFocus() const
173 // Get the associated image list
174 wxImageList
* wxTabCtrl::GetImageList() const
179 // Get the number of items
180 int wxTabCtrl::GetItemCount() const
186 // Get the rect corresponding to the tab
187 bool wxTabCtrl::GetItemRect(int WXUNUSED(item
),
188 wxRect
& WXUNUSED(wxrect
)) const
194 // Get the number of rows
195 int wxTabCtrl::GetRowCount() const
202 wxString
wxTabCtrl::GetItemText(int WXUNUSED(item
)) const
205 return wxEmptyString
;
208 // Get the item image
209 int wxTabCtrl::GetItemImage(int WXUNUSED(item
)) const
216 void* wxTabCtrl::GetItemData(int WXUNUSED(item
)) const
223 int wxTabCtrl::HitTest(const wxPoint
& WXUNUSED(pt
), long& WXUNUSED(flags
))
230 bool wxTabCtrl::InsertItem(int WXUNUSED(item
),
231 const wxString
& WXUNUSED(text
),
232 int WXUNUSED(imageId
),
233 void* WXUNUSED(data
))
240 int wxTabCtrl::SetSelection(int WXUNUSED(item
))
246 // Set the image list
247 void wxTabCtrl::SetImageList(wxImageList
* WXUNUSED(imageList
))
252 // Set the text for an item
253 bool wxTabCtrl::SetItemText(int WXUNUSED(item
), const wxString
& WXUNUSED(text
))
259 // Set the image for an item
260 bool wxTabCtrl::SetItemImage(int WXUNUSED(item
), int WXUNUSED(image
))
266 // Set the data for an item
267 bool wxTabCtrl::SetItemData(int WXUNUSED(item
), void* WXUNUSED(data
))
273 // Set the size for a fixed-width tab control
274 void wxTabCtrl::SetItemSize(const wxSize
& WXUNUSED(size
))
279 // Set the padding between tabs
280 void wxTabCtrl::SetPadding(const wxSize
& WXUNUSED(padding
))
286 // These are the default colors used to map the bitmap colors
287 // to the current system colors
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
296 void wxMapBitmap(HBITMAP hBitmap
, int width
, int height
)
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
307 int NUM_MAPS
= (sizeof(ColorMap
)/sizeof(COLORMAP
));
309 for ( n
= 0; n
< NUM_MAPS
; n
++)
311 ColorMap
[n
].to
= ::GetSysColor(ColorMap
[n
].to
);
315 HDC hdcMem
= CreateCompatibleDC(NULL
);
319 hbmOld
= SelectObject(hdcMem
, hBitmap
);
322 for ( i
= 0; i
< width
; i
++)
324 for ( j
= 0; j
< height
; j
++)
326 COLORREF pixel
= ::GetPixel(hdcMem
, i
, j
);
328 BYTE red = GetRValue(pixel);
329 BYTE green = GetGValue(pixel);
330 BYTE blue = GetBValue(pixel);
333 for ( k
= 0; k
< NUM_MAPS
; k
++)
335 if ( ColorMap
[k
].from
== pixel
)
337 /* COLORREF actualPixel = */ ::SetPixel(hdcMem
, i
, j
, ColorMap
[k
].to
);
345 SelectObject(hdcMem
, hbmOld
);
346 DeleteObject(hdcMem
);
353 IMPLEMENT_DYNAMIC_CLASS(wxTabEvent
, wxCommandEvent
)
355 wxTabEvent::wxTabEvent(wxEventType commandType
, int id
)
356 :wxCommandEvent(commandType
, id
)
360 #endif // wxUSE_TAB_DIALOG