X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bb6290e3514a84a7b50860d1c75d4623696ff601..73fb82f3f3c1e722ad874d487c85249f6e866fbf:/src/msw/tbar95.cpp?ds=sidebyside diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index 63a64b9f57..12b4f41ba8 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -45,6 +45,7 @@ #include "wx/app.h" #include "wx/msw/private.h" +// Styles #ifndef TBSTYLE_FLAT #define TBSTYLE_LIST 0x1000 #define TBSTYLE_FLAT 0x0800 @@ -52,6 +53,23 @@ #endif // use TBSTYLE_TRANSPARENT if you use TBSTYLE_FLAT +// Messages +#ifndef TB_GETSTYLE +#define TB_GETSTYLE (WM_USER + 57) +#define TB_SETSTYLE (WM_USER + 56) +#endif + +/* Hint from a newsgroup for custom flatbar drawing: +Set the TBSTYLE_CUSTOMERASE style, then handle the +NM_CUSTOMDRAW message and do your custom drawing. +*/ + +#define DEFAULTBITMAPX 16 +#define DEFAULTBITMAPY 15 +#define DEFAULTBUTTONX 24 +#define DEFAULTBUTTONY 24 +#define DEFAULTBARHEIGHT 27 + #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxToolBar95, wxToolBarBase) @@ -68,9 +86,6 @@ void wxMapBitmap(HBITMAP hBitmap, int width, int height); wxToolBar95::wxToolBar95(void) { - m_tilingDirection = wxVERTICAL ; - m_rowsOrColumns = 0; - m_currentRowsOrColumns = 0; m_maxWidth = -1; m_maxHeight = -1; m_hBitmap = 0; @@ -79,8 +94,7 @@ wxToolBar95::wxToolBar95(void) } bool wxToolBar95::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - long style, int orientation, - int RowsOrColumns, const wxString& name) + long style, const wxString& name) { m_backgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)), GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); @@ -90,11 +104,8 @@ bool wxToolBar95::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, co m_defaultBackgroundColour = wxColour(GetRValue(GetSysColor(COLOR_BTNFACE)), GetGValue(GetSysColor(COLOR_BTNFACE)), GetBValue(GetSysColor(COLOR_BTNFACE))); - m_tilingDirection = orientation; - if (m_tilingDirection == wxHORIZONTAL) - wxMessageBox("Sorry, wxToolBar95 under Windows 95 only supports vertical tiling.\nPass the number of rows.", "wxToolBar95 usage", wxOK); - m_rowsOrColumns = RowsOrColumns; - m_currentRowsOrColumns = 0; + if (style & wxTB_VERTICAL) + wxMessageBox("Sorry, wxToolBar95 under Windows 95 only supports horizontal orientation.", "wxToolBar95 usage", wxOK); m_maxWidth = -1; m_maxHeight = -1; @@ -188,7 +199,7 @@ bool wxToolBar95::CreateTools(void) // Now blit all the tools onto this bitmap HDC memoryDC = ::CreateCompatibleDC(NULL); - HBITMAP oldBitmap = ::SelectObject(memoryDC, (HBITMAP) m_hBitmap); + HBITMAP oldBitmap = (HBITMAP) ::SelectObject(memoryDC, (HBITMAP) m_hBitmap); HDC memoryDC2 = ::CreateCompatibleDC(NULL); int x = 0; @@ -201,7 +212,7 @@ bool wxToolBar95::CreateTools(void) { // wxPalette *palette = tool->m_bitmap1->GetPalette(); - HBITMAP oldBitmap2 = ::SelectObject(memoryDC2, (HBITMAP) tool->m_bitmap1.GetHBITMAP()); + HBITMAP oldBitmap2 = (HBITMAP) ::SelectObject(memoryDC2, (HBITMAP) tool->m_bitmap1.GetHBITMAP()); /* int bltResult = */ BitBlt(memoryDC, x, 0, (int) m_defaultWidth, (int) m_defaultHeight, memoryDC2, 0, 0, SRCCOPY); @@ -293,7 +304,7 @@ bool wxToolBar95::CreateTools(void) ans = (int)::SendMessage((HWND) GetHWND(), TB_AUTOSIZE, (WPARAM)0, (LPARAM) 0); RECT rect; - ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_rowsOrColumns, TRUE), (LPARAM) & rect); + ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_maxRows, TRUE), (LPARAM) & rect); m_maxWidth = (rect.right - rect.left + 2); m_maxHeight = (rect.bottom - rect.top + 2); @@ -356,7 +367,7 @@ bool wxToolBar95::MSWNotify(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) return TRUE; } -void wxToolBar95::SetDefaultSize(const wxSize& size) +void wxToolBar95::SetToolBitmapSize(const wxSize& size) { m_defaultWidth = size.x; m_defaultHeight = size.y; ::SendMessage((HWND) GetHWND(), TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG ((int)size.x, (int)size.y)); @@ -375,7 +386,7 @@ wxSize wxToolBar95::GetMaxSize(void) const if (m_maxWidth == -1 | m_maxHeight == -1) { RECT rect; - ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_rowsOrColumns, TRUE), (LPARAM) & rect); + ::SendMessage((HWND) GetHWND(), TB_SETROWS, MAKEWPARAM(m_maxRows, TRUE), (LPARAM) & rect); ((wxToolBar95 *)this)->m_maxWidth = (rect.right - rect.left + 2); // ??? ((wxToolBar95 *)this)->m_maxHeight = (rect.bottom - rect.top + 2); // ??? } @@ -391,7 +402,7 @@ void wxToolBar95::GetSize(int *w, int *h) const } // The button size is bigger than the bitmap size -wxSize wxToolBar95::GetDefaultButtonSize(void) const +wxSize wxToolBar95::GetToolSize(void) const { return wxSize(m_defaultWidth + 8, m_defaultHeight + 7); } @@ -421,6 +432,11 @@ void wxToolBar95::ToggleTool(int toolIndex, bool toggle) } } +bool wxToolBar95::GetToolState(int toolIndex) const +{ + return (::SendMessage((HWND) GetHWND(), TB_ISBUTTONCHECKED, (WPARAM)toolIndex, (LPARAM)0) != 0); +} + void wxToolBar95::ClearTools(void) { // TODO: Don't know how to reset the toolbar bitmap, as yet. @@ -506,7 +522,7 @@ void wxMapBitmap(HBITMAP hBitmap, int width, int height) if (hdcMem) { - hbmOld = SelectObject(hdcMem, hBitmap); + hbmOld = (HBITMAP) SelectObject(hdcMem, hBitmap); int i, j, k; for ( i = 0; i < width; i++)