]>
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 #if !USE_SHARED_LIBRARY
31 IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl
, wxControl
)
33 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
)));
75 m_windowId
= (id
< 0 ? NewControlId() : id
);
79 // Create the toolbar control.
81 // TODO: create tab control
83 m_hWnd
= (WXHWND
) hWndTabCtrl
;
84 if (parent
) parent
->AddChild(this);
86 SubclassWin((WXHWND
) hWndTabCtrl
);
91 wxTabCtrl::~wxTabCtrl()
96 bool wxTabCtrl::OS2OnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
)
98 wxTabEvent
event(wxEVT_NULL
, m_windowId
);
99 wxEventType eventType
= wxEVT_NULL
;
102 NMHDR* hdr1 = (NMHDR*) lParam;
103 switch ( hdr1->code )
106 eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
109 case TCN_SELCHANGING:
110 eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
116 // if (tool->m_shortHelpString != "")
117 // ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
121 return wxControl::OS2OnNotify(idCtrl, lParam, result);
124 event
.SetEventObject( this );
125 event
.SetEventType(eventType
);
126 event
.SetInt(idCtrl
) ;
128 return ProcessEvent(event
);
131 // Responds to colour changes, and passes event on to children.
132 void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent
& event
)
136 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
137 GetGValue(GetSysColor(COLOR_BTNFACE)),
138 GetBValue(GetSysColor(COLOR_BTNFACE)));
142 // Propagate the event to the non-top-level children
143 wxWindow::OnSysColourChanged(event
);
148 bool wxTabCtrl::DeleteAllItems()
155 bool wxTabCtrl::DeleteItem(int item
)
162 int wxTabCtrl::GetSelection() const
168 // Get the tab with the current keyboard focus
169 int wxTabCtrl::GetCurFocus() const
175 // Get the associated image list
176 wxImageList
* wxTabCtrl::GetImageList() const
181 // Get the number of items
182 int wxTabCtrl::GetItemCount() const
188 // Get the rect corresponding to the tab
189 bool wxTabCtrl::GetItemRect(int item
, wxRect
& wxrect
) const
195 // Get the number of rows
196 int wxTabCtrl::GetRowCount() const
203 wxString
wxTabCtrl::GetItemText(int item
) const
209 // Get the item image
210 int wxTabCtrl::GetItemImage(int item
) const
217 void* wxTabCtrl::GetItemData(int item
) const
224 int wxTabCtrl::HitTest(const wxPoint
& pt
, long& flags
)
231 bool wxTabCtrl::InsertItem(int item
, const wxString
& text
, int imageId
, void* data
)
238 int wxTabCtrl::SetSelection(int item
)
244 // Set the image list
245 void wxTabCtrl::SetImageList(wxImageList
* imageList
)
250 // Set the text for an item
251 bool wxTabCtrl::SetItemText(int item
, const wxString
& text
)
257 // Set the image for an item
258 bool wxTabCtrl::SetItemImage(int item
, int image
)
264 // Set the data for an item
265 bool wxTabCtrl::SetItemData(int item
, void* data
)
271 // Set the size for a fixed-width tab control
272 void wxTabCtrl::SetItemSize(const wxSize
& size
)
277 // Set the padding between tabs
278 void wxTabCtrl::SetPadding(const wxSize
& padding
)
284 // These are the default colors used to map the bitmap colors
285 // to the current system colors
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
294 void wxMapBitmap(HBITMAP hBitmap
, int width
, int height
)
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
305 int NUM_MAPS
= (sizeof(ColorMap
)/sizeof(COLORMAP
));
307 for ( n
= 0; n
< NUM_MAPS
; n
++)
309 ColorMap
[n
].to
= ::GetSysColor(ColorMap
[n
].to
);
313 HDC hdcMem
= CreateCompatibleDC(NULL
);
317 hbmOld
= SelectObject(hdcMem
, hBitmap
);
320 for ( i
= 0; i
< width
; i
++)
322 for ( j
= 0; j
< height
; j
++)
324 COLORREF pixel
= ::GetPixel(hdcMem
, i
, j
);
326 BYTE red = GetRValue(pixel);
327 BYTE green = GetGValue(pixel);
328 BYTE blue = GetBValue(pixel);
331 for ( k
= 0; k
< NUM_MAPS
; k
++)
333 if ( ColorMap
[k
].from
== pixel
)
335 /* COLORREF actualPixel = */ ::SetPixel(hdcMem
, i
, j
, ColorMap
[k
].to
);
343 SelectObject(hdcMem
, hbmOld
);
344 DeleteObject(hdcMem
);
351 IMPLEMENT_DYNAMIC_CLASS(wxTabEvent
, wxCommandEvent
)
353 wxTabEvent::wxTabEvent(wxEventType commandType
, int id
):
354 wxCommandEvent(commandType
, id
)