]>
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
))); 
  73     m_windowId 
= (id 
< 0 ? NewControlId() : id
); 
  77     // Create the toolbar control. 
  79     // TODO: create tab control 
  81     m_hWnd 
= (WXHWND
) hWndTabCtrl
; 
  82     if (parent
) parent
->AddChild(this); 
  84     SubclassWin((WXHWND
) hWndTabCtrl
); 
  89 wxTabCtrl::~wxTabCtrl() 
  94 bool wxTabCtrl::OS2OnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM 
*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 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 item
, wxRect
& wxrect
) const 
 193 // Get the number of rows 
 194 int wxTabCtrl::GetRowCount() const 
 201 wxString 
wxTabCtrl::GetItemText(int item
) const 
 207 // Get the item image 
 208 int wxTabCtrl::GetItemImage(int item
) const 
 215 void* wxTabCtrl::GetItemData(int item
) const 
 222 int wxTabCtrl::HitTest(const wxPoint
& pt
, long& flags
) 
 229 bool wxTabCtrl::InsertItem(int item
, const wxString
& text
, int imageId
, void* data
) 
 236 int wxTabCtrl::SetSelection(int item
) 
 242 // Set the image list 
 243 void wxTabCtrl::SetImageList(wxImageList
* imageList
) 
 248 // Set the text for an item 
 249 bool wxTabCtrl::SetItemText(int item
, const wxString
& text
) 
 255 // Set the image for an item 
 256 bool wxTabCtrl::SetItemImage(int item
, int image
) 
 262 // Set the data for an item 
 263 bool wxTabCtrl::SetItemData(int item
, void* data
) 
 269 // Set the size for a fixed-width tab control 
 270 void wxTabCtrl::SetItemSize(const wxSize
& size
) 
 275 // Set the padding between tabs 
 276 void wxTabCtrl::SetPadding(const wxSize
& padding
) 
 282 // These are the default colors used to map the bitmap colors 
 283 // to the current system colors 
 285 #define BGR_BUTTONTEXT      (RGB(000,000,000))  // black 
 286 #define BGR_BUTTONSHADOW    (RGB(128,128,128))  // dark grey 
 287 #define BGR_BUTTONFACE      (RGB(192,192,192))  // bright grey 
 288 #define BGR_BUTTONHILIGHT   (RGB(255,255,255))  // white 
 289 #define BGR_BACKGROUNDSEL   (RGB(255,000,000))  // blue 
 290 #define BGR_BACKGROUND      (RGB(255,000,255))  // magenta 
 292 void wxMapBitmap(HBITMAP hBitmap
, int width
, int height
) 
 294   COLORMAP ColorMap
[] = { 
 295     {BGR_BUTTONTEXT
,    COLOR_BTNTEXT
},     // black 
 296     {BGR_BUTTONSHADOW
,  COLOR_BTNSHADOW
},   // dark grey 
 297     {BGR_BUTTONFACE
,    COLOR_BTNFACE
},     // bright grey 
 298     {BGR_BUTTONHILIGHT
, COLOR_BTNHIGHLIGHT
},// white 
 299     {BGR_BACKGROUNDSEL
, COLOR_HIGHLIGHT
},   // blue 
 300     {BGR_BACKGROUND
,    COLOR_WINDOW
}       // magenta 
 303   int NUM_MAPS 
= (sizeof(ColorMap
)/sizeof(COLORMAP
)); 
 305   for ( n 
= 0; n 
< NUM_MAPS
; n
++) 
 307     ColorMap
[n
].to 
= ::GetSysColor(ColorMap
[n
].to
); 
 311   HDC hdcMem 
= CreateCompatibleDC(NULL
); 
 315     hbmOld 
= SelectObject(hdcMem
, hBitmap
); 
 318     for ( i 
= 0; i 
< width
; i
++) 
 320         for ( j 
= 0; j 
< height
; j
++) 
 322             COLORREF pixel 
= ::GetPixel(hdcMem
, i
, j
); 
 324             BYTE red = GetRValue(pixel); 
 325             BYTE green = GetGValue(pixel); 
 326             BYTE blue = GetBValue(pixel); 
 329             for ( k 
= 0; k 
< NUM_MAPS
; k 
++) 
 331                 if ( ColorMap
[k
].from 
== pixel 
) 
 333                     /* COLORREF actualPixel = */ ::SetPixel(hdcMem
, i
, j
, ColorMap
[k
].to
); 
 341     SelectObject(hdcMem
, hbmOld
); 
 342     DeleteObject(hdcMem
); 
 349 IMPLEMENT_DYNAMIC_CLASS(wxTabEvent
, wxCommandEvent
) 
 351 wxTabEvent::wxTabEvent(wxEventType commandType
, int id
): 
 352   wxCommandEvent(commandType
, id
)