]>
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
,
91 WXLPARAM
WXUNUSED(lParam
),
92 WXLPARAM
*WXUNUSED(result
) )
94 wxTabEvent
event(wxEVT_NULL
, m_windowId
);
95 wxEventType eventType
= wxEVT_NULL
;
98 NMHDR* hdr1 = (NMHDR*) lParam;
102 eventType = wxEVT_COMMAND_TAB_SEL_CHANGED;
105 case TCN_SELCHANGING:
106 eventType = wxEVT_COMMAND_TAB_SEL_CHANGING;
112 // if (tool->m_shortHelpString != "")
113 // ttText->lpszText = (char *) (const char *)tool->m_shortHelpString;
117 return wxControl::OS2OnNotify(idCtrl, lParam, result);
120 event
.SetEventObject( this );
121 event
.SetEventType(eventType
);
122 event
.SetInt(idCtrl
) ;
124 return ProcessEvent(event
);
127 // Responds to colour changes, and passes event on to children.
128 void wxTabCtrl::OnSysColourChanged(wxSysColourChangedEvent
& event
)
132 m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)),
133 GetGValue(GetSysColor(COLOR_BTNFACE)),
134 GetBValue(GetSysColor(COLOR_BTNFACE)));
138 // Propagate the event to the non-top-level children
139 wxWindow::OnSysColourChanged(event
);
144 bool wxTabCtrl::DeleteAllItems()
151 bool wxTabCtrl::DeleteItem(int WXUNUSED(item
))
158 int wxTabCtrl::GetSelection() const
164 // Get the tab with the current keyboard focus
165 int wxTabCtrl::GetCurFocus() const
171 // Get the associated image list
172 wxImageList
* wxTabCtrl::GetImageList() const
177 // Get the number of items
178 int wxTabCtrl::GetItemCount() const
184 // Get the rect corresponding to the tab
185 bool wxTabCtrl::GetItemRect(int WXUNUSED(item
),
186 wxRect
& WXUNUSED(wxrect
)) const
192 // Get the number of rows
193 int wxTabCtrl::GetRowCount() const
200 wxString
wxTabCtrl::GetItemText(int WXUNUSED(item
)) const
203 return wxEmptyString
;
206 // Get the item image
207 int wxTabCtrl::GetItemImage(int WXUNUSED(item
)) const
214 void* wxTabCtrl::GetItemData(int WXUNUSED(item
)) const
221 int wxTabCtrl::HitTest(const wxPoint
& WXUNUSED(pt
), long& WXUNUSED(flags
))
228 bool wxTabCtrl::InsertItem(int WXUNUSED(item
),
229 const wxString
& WXUNUSED(text
),
230 int WXUNUSED(imageId
),
231 void* WXUNUSED(data
))
238 int wxTabCtrl::SetSelection(int WXUNUSED(item
))
244 // Set the image list
245 void wxTabCtrl::SetImageList(wxImageList
* WXUNUSED(imageList
))
250 // Set the text for an item
251 bool wxTabCtrl::SetItemText(int WXUNUSED(item
), const wxString
& WXUNUSED(text
))
257 // Set the image for an item
258 bool wxTabCtrl::SetItemImage(int WXUNUSED(item
), int WXUNUSED(image
))
264 // Set the data for an item
265 bool wxTabCtrl::SetItemData(int WXUNUSED(item
), void* WXUNUSED(data
))
271 // Set the size for a fixed-width tab control
272 void wxTabCtrl::SetItemSize(const wxSize
& WXUNUSED(size
))
277 // Set the padding between tabs
278 void wxTabCtrl::SetPadding(const wxSize
& WXUNUSED(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
)