]>
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"
24 //#include "wx/msw/dib.h"
25 #include "wx/os2/tabctrl.h"
27 #include "wx/os2/private.h"
28 #include "wx/generic/imaglist.h"
30 IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl
, wxControl
)
32 BEGIN_EVENT_TABLE(wxTabCtrl
, wxControl
)
35 wxTabCtrl::wxTabCtrl()
40 bool wxTabCtrl::Create(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
,
41 long style
, const wxString
& name
)
45 m_backgroundColour
= *wxWHITE
; // TODO: wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
46 // GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE)));
47 m_foregroundColour
= *wxBLACK
;
56 m_windowStyle
= style
;
58 SetFont(* (wxTheFontList
->FindOrCreateFont(11, wxSWISS
, wxNORMAL
, wxNORMAL
)));
71 m_windowId
= (id
< 0 ? NewControlId() : id
);
73 // Create the toolbar control.
75 // TODO: create tab control
77 m_hWnd
= (WXHWND
) hWndTabCtrl
;
78 if (parent
) parent
->AddChild(this);
80 SubclassWin((WXHWND
) hWndTabCtrl
);
85 wxTabCtrl::~wxTabCtrl()
90 bool wxTabCtrl::OS2OnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
)
92 wxTabEvent
event(wxEVT_NULL
, m_windowId
);
93 wxEventType eventType
= wxEVT_NULL
;
96 NMHDR* hdr1 = (NMHDR*) lParam;
100 eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
103 case TCN_SELCHANGING:
104 eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
110 // if (tool->m_shortHelpString != "")
111 // ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
115 return wxControl::OS2OnNotify(idCtrl, lParam, result);
118 event
.SetEventObject( this );
119 event
.SetEventType(eventType
);
120 event
.SetInt(idCtrl
) ;
122 return ProcessEvent(event
);
125 // Responds to colour changes, and passes event on to children.
126 void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent
& event
)
130 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
131 GetGValue(GetSysColor(COLOR_BTNFACE)),
132 GetBValue(GetSysColor(COLOR_BTNFACE)));
136 // Propagate the event to the non-top-level children
137 wxWindow::OnSysColourChanged(event
);
142 bool wxTabCtrl::DeleteAllItems()
149 bool wxTabCtrl::DeleteItem(int item
)
156 int wxTabCtrl::GetSelection() const
162 // Get the tab with the current keyboard focus
163 int wxTabCtrl::GetCurFocus() const
169 // Get the associated image list
170 wxImageList
* wxTabCtrl::GetImageList() const
175 // Get the number of items
176 int wxTabCtrl::GetItemCount() const
182 // Get the rect corresponding to the tab
183 bool wxTabCtrl::GetItemRect(int item
, wxRect
& wxrect
) const
189 // Get the number of rows
190 int wxTabCtrl::GetRowCount() const
197 wxString
wxTabCtrl::GetItemText(int item
) const
203 // Get the item image
204 int wxTabCtrl::GetItemImage(int item
) const
211 void* wxTabCtrl::GetItemData(int item
) const
218 int wxTabCtrl::HitTest(const wxPoint
& pt
, long& flags
)
225 bool wxTabCtrl::InsertItem(int item
, const wxString
& text
, int imageId
, void* data
)
232 int wxTabCtrl::SetSelection(int item
)
238 // Set the image list
239 void wxTabCtrl::SetImageList(wxImageList
* imageList
)
244 // Set the text for an item
245 bool wxTabCtrl::SetItemText(int item
, const wxString
& text
)
251 // Set the image for an item
252 bool wxTabCtrl::SetItemImage(int item
, int image
)
258 // Set the data for an item
259 bool wxTabCtrl::SetItemData(int item
, void* data
)
265 // Set the size for a fixed-width tab control
266 void wxTabCtrl::SetItemSize(const wxSize
& size
)
271 // Set the padding between tabs
272 void wxTabCtrl::SetPadding(const wxSize
& padding
)
278 // These are the default colors used to map the bitmap colors
279 // to the current system colors
281 #define BGR_BUTTONTEXT (RGB(000,000,000)) // black
282 #define BGR_BUTTONSHADOW (RGB(128,128,128)) // dark grey
283 #define BGR_BUTTONFACE (RGB(192,192,192)) // bright grey
284 #define BGR_BUTTONHILIGHT (RGB(255,255,255)) // white
285 #define BGR_BACKGROUNDSEL (RGB(255,000,000)) // blue
286 #define BGR_BACKGROUND (RGB(255,000,255)) // magenta
288 void wxMapBitmap(HBITMAP hBitmap
, int width
, int height
)
290 COLORMAP ColorMap
[] = {
291 {BGR_BUTTONTEXT
, COLOR_BTNTEXT
}, // black
292 {BGR_BUTTONSHADOW
, COLOR_BTNSHADOW
}, // dark grey
293 {BGR_BUTTONFACE
, COLOR_BTNFACE
}, // bright grey
294 {BGR_BUTTONHILIGHT
, COLOR_BTNHIGHLIGHT
},// white
295 {BGR_BACKGROUNDSEL
, COLOR_HIGHLIGHT
}, // blue
296 {BGR_BACKGROUND
, COLOR_WINDOW
} // magenta
299 int NUM_MAPS
= (sizeof(ColorMap
)/sizeof(COLORMAP
));
301 for ( n
= 0; n
< NUM_MAPS
; n
++)
303 ColorMap
[n
].to
= ::GetSysColor(ColorMap
[n
].to
);
307 HDC hdcMem
= CreateCompatibleDC(NULL
);
311 hbmOld
= SelectObject(hdcMem
, hBitmap
);
314 for ( i
= 0; i
< width
; i
++)
316 for ( j
= 0; j
< height
; j
++)
318 COLORREF pixel
= ::GetPixel(hdcMem
, i
, j
);
320 BYTE red = GetRValue(pixel);
321 BYTE green = GetGValue(pixel);
322 BYTE blue = GetBValue(pixel);
325 for ( k
= 0; k
< NUM_MAPS
; k
++)
327 if ( ColorMap
[k
].from
== pixel
)
329 /* COLORREF actualPixel = */ ::SetPixel(hdcMem
, i
, j
, ColorMap
[k
].to
);
337 SelectObject(hdcMem
, hbmOld
);
338 DeleteObject(hdcMem
);
345 IMPLEMENT_DYNAMIC_CLASS(wxTabEvent
, wxCommandEvent
)
347 wxTabEvent::wxTabEvent(wxEventType commandType
, int id
):
348 wxCommandEvent(commandType
, id
)