X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9928e9d1ab76fd26557e2cf8e6715402639e999..c1637c8933a99cbce15d896ea43d741a14b8155a:/src/msw/wince/tbarwce.cpp?ds=inline diff --git a/src/msw/wince/tbarwce.cpp b/src/msw/wince/tbarwce.cpp index d69da49cb5..2138b8ef6a 100644 --- a/src/msw/wince/tbarwce.cpp +++ b/src/msw/wince/tbarwce.cpp @@ -56,7 +56,7 @@ #include #include #include -#if _WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__) +#if defined(WINCE_WITHOUT_COMMANDBAR) #include #endif #include "wx/msw/wince/missing.h" @@ -226,33 +226,33 @@ bool wxToolBar::Create(wxWindow *parent, { // common initialisation if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) ) - return FALSE; + return false; // MSW-specific initialisation if ( !MSWCreateToolbar(pos, size, menuBar) ) - return FALSE; + return false; // set up the colors and fonts SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR)); SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - return TRUE; + return true; } #ifndef TBSTYLE_NO_DROPDOWN_ARROW #define TBSTYLE_NO_DROPDOWN_ARROW 0x0080 #endif -bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuBar* menuBar) +bool wxToolBar::MSWCreateToolbar(const wxPoint& WXUNUSED(pos), const wxSize& WXUNUSED(size), wxMenuBar* menuBar) { SetMenuBar(menuBar); if (m_menuBar) m_menuBar->SetToolBar(this); -#if _WIN32_WCE < 400 || defined(__POCKETPC__) || defined(__SMARTPHONE__) +#if defined(WINCE_WITHOUT_COMMANDBAR) // Create the menubar. SHMENUBARINFO mbi; - + memset (&mbi, 0, sizeof (SHMENUBARINFO)); mbi.cbSize = sizeof (SHMENUBARINFO); mbi.hwndParent = (HWND) GetParent()->GetHWND(); @@ -265,13 +265,13 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuB mbi.cBmpImages = 0; mbi.dwFlags = 0 ; // SHCMBF_EMPTYBAR; mbi.hInstRes = wxGetInstance(); - + if (!SHCreateMenuBar(&mbi)) { wxFAIL_MSG( _T("SHCreateMenuBar failed") ); - return FALSE; + return false; } - + SetHWND((WXHWND) mbi.hwndMB); #else HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND) GetParent()->GetHWND(), GetId()); @@ -283,8 +283,8 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuB if (menuBar) menuBar->Create(); - - return TRUE; + + return true; } void wxToolBar::Recreate() @@ -368,12 +368,17 @@ wxSize wxToolBar::DoGetBestSize() const // Return HMENU for the menu associated with the commandbar WXHMENU wxToolBar::GetHMenu() { +#if defined(__HANDHELDPC__) + // TODO ??? + return 0; +#else if (GetHWND()) { return (WXHMENU) (HMENU)::SendMessage((HWND) GetHWND(), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0); } else return 0; +#endif } @@ -432,7 +437,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) // Realize() later tool->Attach(this); - return TRUE; + return true; } bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) @@ -489,7 +494,7 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) { wxLogLastError(wxT("TB_DELETEBUTTON")); - return FALSE; + return false; } } @@ -505,11 +510,11 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) int x; wxControl *control = tool2->GetControl(); control->GetPosition(&x, NULL); - control->Move(x - width, -1); + control->Move(x - width, wxDefaultCoord); } } - return TRUE; + return true; } struct wxToolBarIdMapping @@ -549,7 +554,7 @@ static wxToolBarIdMapping sm_ToolBarIdMappingArray[] = static int wxFindIdForwxWinId(int id) { int i = 0; - while (TRUE) + while (true) { if (sm_ToolBarIdMappingArray[i].m_wxwinId == 0) return -1; @@ -567,11 +572,9 @@ bool wxToolBar::Realize() if ( nTools == 0 ) { // nothing to do - return TRUE; + return true; } - const bool isVertical = HasFlag(wxTB_VERTICAL); - #if 0 // delete all old buttons, if any for ( size_t pos = 0; pos < m_nButtons; pos++ ) @@ -581,7 +584,7 @@ bool wxToolBar::Realize() wxLogDebug(wxT("TB_DELETEBUTTON failed")); } } -#endif +#endif // 0 // add the buttons and separators // ------------------------------ @@ -595,20 +598,20 @@ bool wxToolBar::Realize() // this array will hold the indices of all controls in the toolbar wxArrayInt controlIds; - bool lastWasRadio = FALSE; + bool lastWasRadio = false; int i = 0; wxToolBarToolsList::Node* node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { wxToolBarToolBase *tool = node->GetData(); - bool processedThis = TRUE; + bool processedThis = true; TBBUTTON& button = buttons[i]; wxZeroMemory(button); - bool isRadio = FALSE; + bool isRadio = false; switch ( tool->GetStyle() ) { case wxTOOL_STYLE_CONTROL: @@ -641,7 +644,7 @@ bool wxToolBar::Realize() button.iBitmap = winceId; } else - processedThis = FALSE; + processedThis = false; if ( tool->IsEnabled() ) button.fsState |= TBSTATE_ENABLED; @@ -660,10 +663,10 @@ bool wxToolBar::Realize() // radio items button.fsState |= TBSTATE_CHECKED; - tool->Toggle(TRUE); + tool->Toggle(true); } - isRadio = TRUE; + isRadio = true; break; case wxITEM_CHECK: @@ -697,6 +700,9 @@ bool wxToolBar::Realize() delete [] buttons; #if 0 + + const bool isVertical = HasFlag(wxTB_VERTICAL); + // Deal with the controls finally // ------------------------------ @@ -717,8 +723,8 @@ bool wxToolBar::Realize() // note that we use TB_GETITEMRECT and not TB_GETRECT because the // latter only appeared in v4.70 of comctl32.dll RECT r; - if ( !SendMessage(GetHwnd(), TB_GETITEMRECT, - index, (LPARAM)(LPRECT)&r) ) + if ( !::SendMessage(GetHwnd(), TB_GETITEMRECT, + index, (LPARAM)(LPRECT)&r) ) { wxLogLastError(wxT("TB_GETITEMRECT")); } @@ -750,8 +756,8 @@ bool wxToolBar::Realize() tbbi.cbSize = sizeof(tbbi); tbbi.dwMask = TBIF_SIZE; tbbi.cx = size.x; - if ( !SendMessage(GetHwnd(), TB_SETBUTTONINFO, - tool->GetId(), (LPARAM)&tbbi) ) + if ( !::SendMessage(GetHwnd(), TB_SETBUTTONINFO, + tool->GetId(), (LPARAM)&tbbi) ) { // the id is probably invalid? wxLogLastError(wxT("TB_SETBUTTONINFO")); @@ -774,8 +780,8 @@ bool wxToolBar::Realize() size_t nSeparators = size.x / widthSep; for ( size_t nSep = 0; nSep < nSeparators; nSep++ ) { - if ( !SendMessage(GetHwnd(), TB_INSERTBUTTON, - index, (LPARAM)&tbb) ) + if ( !::SendMessage(GetHwnd(), TB_INSERTBUTTON, + index, (LPARAM)&tbb) ) { wxLogLastError(wxT("TB_INSERTBUTTON")); } @@ -788,7 +794,7 @@ bool wxToolBar::Realize() ((wxToolBarTool *)tool)->SetSeparatorsCount(nSeparators); // adjust the controls width to exactly cover the separators - control->SetSize((nSeparators + 1)*widthSep, -1); + control->SetSize((nSeparators + 1)*widthSep, wxDefaultCoord); } // position the control itself correctly vertically @@ -797,7 +803,7 @@ bool wxToolBar::Realize() if ( diff < 0 ) { // the control is too high, resize to fit - control->SetSize(-1, height - 2); + control->SetSize(wxDefaultCoord, height - 2); diff = 2; } @@ -841,9 +847,9 @@ bool wxToolBar::Realize() SetRows(m_nButtons); } } -#endif +#endif // 0 - return TRUE; + return true; } // ---------------------------------------------------------------------------- @@ -887,7 +893,7 @@ bool wxToolBar::MSWCommand(WXUINT WXUNUSED(cmd), WXWORD id) } } - return TRUE; + return true; } bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl), @@ -902,22 +908,23 @@ bool wxToolBar::MSWOnNotify(int WXUNUSED(idCtrl), // in an ANSI application - this seems to be a bug in comctl32.dll v5 UINT code = hdr->code; if ( (code != (UINT) TTN_NEEDTEXTA) && (code != (UINT) TTN_NEEDTEXTW) ) - return FALSE; + return false; HWND toolTipWnd = (HWND)::SendMessage((HWND)GetHWND(), TB_GETTOOLTIPS, 0, 0); if ( toolTipWnd != hdr->hwndFrom ) - return FALSE; + return false; LPTOOLTIPTEXT ttText = (LPTOOLTIPTEXT)lParam; int id = (int)ttText->hdr.idFrom; wxToolBarToolBase *tool = FindById(id); if ( !tool ) - return FALSE; + return false; return HandleTooltipNotify(code, lParam, tool->GetShortHelp()); #else - return FALSE; + wxUnusedVar(lParam); + return false; #endif } @@ -1025,7 +1032,7 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const void wxToolBar::UpdateSize() { // the toolbar size changed - SendMessage(GetHwnd(), TB_AUTOSIZE, 0, 0); + ::SendMessage(GetHwnd(), TB_AUTOSIZE, 0, 0); // we must also refresh the frame after the toolbar size (possibly) changed wxFrame *frame = wxDynamicCast(GetParent(), wxFrame); @@ -1128,7 +1135,7 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event) } } -void wxToolBar::HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam) +void wxToolBar::HandleMouseMove(WXWPARAM WXUNUSED(wParam), WXLPARAM lParam) { wxCoord x = GET_X_LPARAM(lParam), y = GET_Y_LPARAM(lParam);