X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c140b7e7c9aabb61ab5e6e017cfb768c05373502..85ac8ca017a0409e9762ed305ccc1d32a7c28fa7:/src/msw/wince/tbarwce.cpp diff --git a/src/msw/wince/tbarwce.cpp b/src/msw/wince/tbarwce.cpp index f6fa2b5a57..fe77c87875 100644 --- a/src/msw/wince/tbarwce.cpp +++ b/src/msw/wince/tbarwce.cpp @@ -41,7 +41,7 @@ // Use the WinCE-specific toolbar only if we're either compiling // with a WinCE earlier than 4, or we wish to emulate a PocketPC-style UI -#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (_WIN32_WCE < 400 || wxUSE_POCKETPC_UI) +#if wxUSE_TOOLBAR && wxUSE_TOOLBAR_NATIVE && (_WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP)) #include "wx/toolbar.h" @@ -56,7 +56,7 @@ #include #include #include -#if _WIN32_WCE < 400 +#if _WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) #include #endif #include "wx/msw/wince/missing.h" @@ -74,18 +74,6 @@ #endif -// ---------------------------------------------------------------------------- -// conditional compilation -// ---------------------------------------------------------------------------- - -// wxWindows previously always considered that toolbar buttons have light grey -// (0xc0c0c0) background and so ignored any bitmap masks - however, this -// doesn't work with XPMs which then appear to have black background. To make -// this work, we must respect the bitmap masks - which we do now. This should -// be ok in any case, but to restore 100% compatible with the old version -// behaviour, you can set this to 0. -#define USE_BITMAP_MASKS 1 - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -261,17 +249,14 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuB if (m_menuBar) m_menuBar->SetToolBar(this); -#if _WIN32_WCE >= 400 - HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND) GetParent()->GetHWND(), GetId()); - SetHWND((WXHWND) hWnd); -#else +#if _WIN32_WCE < 400 || defined(WIN32_PLATFORM_PSPC) || defined(WIN32_PLATFORM_WFSP) // Create the menubar. SHMENUBARINFO mbi; memset (&mbi, 0, sizeof (SHMENUBARINFO)); mbi.cbSize = sizeof (SHMENUBARINFO); mbi.hwndParent = (HWND) GetParent()->GetHWND(); -#if wxUSE_SMARTPHONE +#ifdef __SMARTPHONE__ mbi.nToolBarId = 5002; #else mbi.nToolBarId = 5000; @@ -288,6 +273,9 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuB } SetHWND((WXHWND) mbi.hwndMB); +#else + HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND) GetParent()->GetHWND(), GetId()); + SetHWND((WXHWND) hWnd); #endif // install wxWindows window proc for this window @@ -558,20 +546,6 @@ static wxToolBarIdMapping sm_ToolBarIdMappingArray[] = { 0, 0}, }; -static int wxFindIdForWinceId(int id) -{ - int i = 0; - while (TRUE) - { - if (sm_ToolBarIdMappingArray[i].m_winceId == 0) - return -1; - else if (sm_ToolBarIdMappingArray[i].m_winceId == id) - return sm_ToolBarIdMappingArray[i].m_wxwinId; - i ++; - } - return -1; -} - static int wxFindIdForwxWinId(int id) { int i = 0; @@ -1195,115 +1169,5 @@ WXLRESULT wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam return wxControl::MSWWindowProc(nMsg, wParam, lParam); } -// ---------------------------------------------------------------------------- -// private functions -// ---------------------------------------------------------------------------- - -WXHBITMAP wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height) -{ - MemoryHDC hdcMem; - - if ( !hdcMem ) - { - wxLogLastError(_T("CreateCompatibleDC")); - - return bitmap; - } - - SelectInHDC bmpInHDC(hdcMem, (HBITMAP)bitmap); - - if ( !bmpInHDC ) - { - wxLogLastError(_T("SelectObject")); - - return bitmap; - } - - wxCOLORMAP *cmap = wxGetStdColourMap(); - - for ( int i = 0; i < width; i++ ) - { - for ( int j = 0; j < height; j++ ) - { - COLORREF pixel = ::GetPixel(hdcMem, i, j); - - for ( size_t k = 0; k < wxSTD_COL_MAX; k++ ) - { - COLORREF col = cmap[k].from; - if ( abs(GetRValue(pixel) - GetRValue(col)) < 10 && - abs(GetGValue(pixel) - GetGValue(col)) < 10 && - abs(GetBValue(pixel) - GetBValue(col)) < 10 ) - { - ::SetPixel(hdcMem, i, j, cmap[k].to); - break; - } - } - } - } - - return bitmap; - - // VZ: I leave here my attempts to map the bitmap to the system colours - // faster by using BitBlt() even though it's broken currently - but - // maybe someone else can finish it? It should be faster than iterating - // over all pixels... -#if 0 - MemoryHDC hdcMask, hdcDst; - if ( !hdcMask || !hdcDst ) - { - wxLogLastError(_T("CreateCompatibleDC")); - - return bitmap; - } - - // create the target bitmap - HBITMAP hbmpDst = ::CreateCompatibleBitmap(hdcDst, width, height); - if ( !hbmpDst ) - { - wxLogLastError(_T("CreateCompatibleBitmap")); - - return bitmap; - } - - // create the monochrome mask bitmap - HBITMAP hbmpMask = ::CreateBitmap(width, height, 1, 1, 0); - if ( !hbmpMask ) - { - wxLogLastError(_T("CreateBitmap(mono)")); - - ::DeleteObject(hbmpDst); - - return bitmap; - } - - SelectInHDC bmpInDst(hdcDst, hbmpDst), - bmpInMask(hdcMask, hbmpMask); - - // for each colour: - for ( n = 0; n < NUM_OF_MAPPED_COLOURS; n++ ) - { - // create the mask for this colour - ::SetBkColor(hdcMem, ColorMap[n].from); - ::BitBlt(hdcMask, 0, 0, width, height, hdcMem, 0, 0, SRCCOPY); - - // replace this colour with the target one in the dst bitmap - HBRUSH hbr = ::CreateSolidBrush(ColorMap[n].to); - HGDIOBJ hbrOld = ::SelectObject(hdcDst, hbr); - - ::MaskBlt(hdcDst, 0, 0, width, height, - hdcMem, 0, 0, - hbmpMask, 0, 0, - MAKEROP4(PATCOPY, SRCCOPY)); - - (void)::SelectObject(hdcDst, hbrOld); - ::DeleteObject(hbr); - } - - ::DeleteObject((HBITMAP)bitmap); - - return (WXHBITMAP)hbmpDst; -#endif // 0 -} - #endif // wxUSE_TOOLBAR && Win95