diff --git a/include/wx/window.h b/include/wx/window.h index aeae05a689..a6bdc327d4 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -1004,14 +1004,21 @@ public: void SetToolTip( const wxString &tip ); // attach a tooltip to the window void SetToolTip( wxToolTip *tip ) { DoSetToolTip(tip); } +#if wxABI_VERSION >= 20809 + // more readable synonym for SetToolTip(NULL) + void UnsetToolTip() { SetToolTip(NULL); } +#endif // wxABI_VERSION >= 2.8.9 // get the associated tooltip or NULL if none wxToolTip* GetToolTip() const { return m_tooltip; } wxString GetToolTipText() const ; -#else +#else // !wxUSE_TOOLTIPS // make it much easier to compile apps in an environment // that doesn't support tooltips, such as PocketPC - inline void SetToolTip( const wxString & WXUNUSED(tip) ) {} -#endif // wxUSE_TOOLTIPS + void SetToolTip( const wxString & WXUNUSED(tip) ) {} +#if wxABI_VERSION >= 20809 + void UnsetToolTip() { } +#endif // wxABI_VERSION >= 2.8.9 +#endif // wxUSE_TOOLTIPS/!wxUSE_TOOLTIPS // drag and drop // ------------- diff --git a/src/aui/auibar.cpp b/src/aui/auibar.cpp index f54ff793a0..554a34eef3 100644 --- a/src/aui/auibar.cpp +++ b/src/aui/auibar.cpp @@ -37,7 +37,9 @@ #include "wx/aui/framemanager.h" #ifdef __WXMAC__ -#include "wx/mac/carbon/private.h" +#include "wx/osx/private.h" +// for themeing support +#include #endif #include "wx/arrimpl.cpp" @@ -110,24 +112,22 @@ static wxBitmap MakeDisabledBitmap(wxBitmap& bmp) static wxColor GetBaseColor() { -#ifdef __WXMAC__ - wxBrush toolbarbrush; - toolbarbrush.MacSetTheme( kThemeBrushToolbarBackground ); - wxColor base_color = toolbarbrush.GetColour(); +#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON + wxColor base_colour = wxColour( wxMacCreateCGColorFromHITheme(kThemeBrushToolbarBackground)); #else - wxColor base_color = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); + wxColor base_colour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE); #endif // the base_colour is too pale to use as our base colour, // so darken it a bit -- - if ((255-base_color.Red()) + - (255-base_color.Green()) + - (255-base_color.Blue()) < 60) + if ((255-base_colour.Red()) + + (255-base_colour.Green()) + + (255-base_colour.Blue()) < 60) { - base_color = wxAuiStepColour(base_color, 92); + base_colour = wxAuiStepColour(base_colour, 92); } - return base_color; + return base_colour; } @@ -165,7 +165,6 @@ const wxColour DISABLED_TEXT_COLOR(DISABLED_TEXT_GREY_HUE, DISABLED_TEXT_GREY_HUE, DISABLED_TEXT_GREY_HUE); - wxAuiDefaultToolBarArt::wxAuiDefaultToolBarArt() { m_base_colour = GetBaseColor(); @@ -210,7 +209,7 @@ wxAuiDefaultToolBarArt::~wxAuiDefaultToolBarArt() wxAuiToolBarArt* wxAuiDefaultToolBarArt::Clone() { - return wx_static_cast(wxAuiToolBarArt*, new wxAuiDefaultToolBarArt); + return static_cast(new wxAuiDefaultToolBarArt); } void wxAuiDefaultToolBarArt::SetFlags(unsigned int flags) @@ -302,7 +301,7 @@ void wxAuiDefaultToolBarArt::DrawButton( text_x = rect.x + (rect.width/2) - (text_width/2) + 1; text_y = rect.y + rect.height - text_height - 1; } - else if (m_text_orientation == wxAUI_TBTOOL_TEXT_RIGHT) + else if (m_text_orientation == wxAUI_TBTOOL_TEXT_RIGHT) { bmp_x = rect.x + 3; @@ -325,7 +324,7 @@ void wxAuiDefaultToolBarArt::DrawButton( dc.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour, 150))); dc.DrawRectangle(rect); } - else if ((item.GetState() & wxAUI_BUTTON_STATE_HOVER) || item.IsSticky()) + else if ((item.GetState() & wxAUI_BUTTON_STATE_HOVER) || item.IsSticky()) { dc.SetPen(wxPen(m_highlight_colour)); dc.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour, 170))); @@ -337,7 +336,7 @@ void wxAuiDefaultToolBarArt::DrawButton( dc.DrawRectangle(rect); } - else if (item.GetState() & wxAUI_BUTTON_STATE_CHECKED) + else if (item.GetState() & wxAUI_BUTTON_STATE_CHECKED) { // it's important to put this code in an else statment after the // hover, otherwise hovers won't draw properly for checked items @@ -350,7 +349,7 @@ void wxAuiDefaultToolBarArt::DrawButton( wxBitmap bmp; if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED) bmp = item.GetDisabledBitmap(); - else + else bmp = item.GetBitmap(); if (!bmp.IsOk()) @@ -363,7 +362,7 @@ void wxAuiDefaultToolBarArt::DrawButton( if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED) dc.SetTextForeground(DISABLED_TEXT_COLOR); - if ((m_flags & wxAUI_TB_TEXT) && item.GetLabel().Length() > 0) + if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() ) { dc.DrawText(item.GetLabel(), text_x, text_y); } @@ -424,7 +423,7 @@ void wxAuiDefaultToolBarArt::DrawDropDownButton( text_x = rect.x + (rect.width/2) - (text_width/2) + 1; text_y = rect.y + rect.height - text_height - 1; } - else if (m_text_orientation == wxAUI_TBTOOL_TEXT_RIGHT) + else if (m_text_orientation == wxAUI_TBTOOL_TEXT_RIGHT) { bmp_x = rect.x + 3; @@ -446,8 +445,8 @@ void wxAuiDefaultToolBarArt::DrawDropDownButton( dc.DrawRectangle(button_rect); dc.DrawRectangle(dropdown_rect); } - else if (item.GetState() & wxAUI_BUTTON_STATE_HOVER || - item.IsSticky()) + else if (item.GetState() & wxAUI_BUTTON_STATE_HOVER || + item.IsSticky()) { dc.SetPen(wxPen(m_highlight_colour)); dc.SetBrush(wxBrush(wxAuiStepColour(m_highlight_colour, 170))); @@ -462,7 +461,7 @@ void wxAuiDefaultToolBarArt::DrawDropDownButton( bmp = item.GetDisabledBitmap(); dropbmp = m_disabled_button_dropdown_bmp; } - else + else { bmp = item.GetBitmap(); dropbmp = m_button_dropdown_bmp; @@ -479,7 +478,7 @@ void wxAuiDefaultToolBarArt::DrawDropDownButton( if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED) dc.SetTextForeground(DISABLED_TEXT_COLOR); - if ((m_flags & wxAUI_TB_TEXT) && item.GetLabel().Length() > 0) + if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() ) { dc.DrawText(item.GetLabel(), text_x, text_y); } @@ -521,7 +520,7 @@ void wxAuiDefaultToolBarArt::DrawControlLabel( text_x = rect.x + (rect.width/2) - (text_width/2) + 1; text_y = rect.y + rect.height - text_height - 1; - if ((m_flags & wxAUI_TB_TEXT) && item.GetLabel().Length() > 0) + if ( (m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty() ) { dc.DrawText(item.GetLabel(), text_x, text_y); } @@ -565,18 +564,19 @@ wxSize wxAuiDefaultToolBarArt::GetToolSize( dc.GetTextExtent(wxT("ABCDHgj"), &tx, &ty); height += ty; - if (item.GetLabel().Length() > 0) + if ( !item.GetLabel().empty() ) { dc.GetTextExtent(item.GetLabel(), &tx, &ty); width = wxMax(width, tx+6); } } - else if (m_text_orientation == wxAUI_TBTOOL_TEXT_RIGHT && item.GetLabel().Length() > 0) + else if ( m_text_orientation == wxAUI_TBTOOL_TEXT_RIGHT && + !item.GetLabel().empty() ) { width += 3; // space between left border and bitmap width += 3; // space between bitmap and text - if (item.GetLabel().Length() > 0) + if ( !item.GetLabel().empty() ) { dc.GetTextExtent(item.GetLabel(), &tx, &ty); width += tx; @@ -611,7 +611,7 @@ void wxAuiDefaultToolBarArt::DrawSeparator( rect.y += (rect.height/2) - (new_height/2); rect.height = new_height; } - else + else { rect.y += (rect.height/2); rect.height = 1; @@ -641,7 +641,7 @@ void wxAuiDefaultToolBarArt::DrawGripper(wxDC& dc, if (x > rect.GetWidth()-5) break; } - else + else { x = rect.x + 3; y = rect.y + (i*4) + 5; @@ -746,7 +746,7 @@ int wxAuiDefaultToolBarArt::ShowDropDown(wxWindow* wnd, menuPopup.Append(m); items_added++; } - else if (item.GetKind() == wxITEM_SEPARATOR) + else if (item.GetKind() == wxITEM_SEPARATOR) { if (items_added > 0) menuPopup.AppendSeparator(); @@ -850,18 +850,18 @@ void wxAuiToolBar::SetWindowStyleFlag(long style) if (m_style & wxAUI_TB_GRIPPER) m_gripper_visible = true; - else + else m_gripper_visible = false; if (m_style & wxAUI_TB_OVERFLOW) m_overflow_visible = true; - else + else m_overflow_visible = false; if (style & wxAUI_TB_HORZ_LAYOUT) SetToolTextOrientation(wxAUI_TBTOOL_TEXT_RIGHT); - else + else SetToolTextOrientation(wxAUI_TBTOOL_TEXT_BOTTOM); } @@ -1217,7 +1217,7 @@ int wxAuiToolBar::GetToolSeparation() const { if (m_art) return m_art->GetElementSize(wxAUI_TBART_SEPARATOR_SIZE); - else + else return 5; } @@ -1437,7 +1437,7 @@ void wxAuiToolBar::RefreshOverflowState() { if (::wxGetMouseState().LeftDown()) overflow_state = wxAUI_BUTTON_STATE_PRESSED; - else + else overflow_state = wxAUI_BUTTON_STATE_HOVER; } @@ -1462,7 +1462,7 @@ void wxAuiToolBar::ToggleTool(int tool_id, bool state) if (state == true) tool->state |= wxAUI_BUTTON_STATE_CHECKED; - else + else tool->state &= ~wxAUI_BUTTON_STATE_CHECKED; } } @@ -1490,7 +1490,7 @@ void wxAuiToolBar::EnableTool(int tool_id, bool state) { if (state == true) tool->state &= ~wxAUI_BUTTON_STATE_DISABLED; - else + else tool->state |= wxAUI_BUTTON_STATE_DISABLED; } } @@ -1634,7 +1634,7 @@ bool wxAuiToolBar::GetToolFitsByIndex(int tool_idx) const if (rect.y+rect.height < cli_h) return true; } - else + else { // take the dropdown size into account if (m_overflow_visible) @@ -1697,10 +1697,10 @@ bool wxAuiToolBar::Realize() { if (horizontal) m_gripper_sizer_item = sizer->Add(gripper_size, 1, 0, wxEXPAND); - else + else m_gripper_sizer_item = sizer->Add(1, gripper_size, 0, wxEXPAND); } - else + else { m_gripper_sizer_item = NULL; } @@ -1710,7 +1710,7 @@ bool wxAuiToolBar::Realize() { if (horizontal) sizer->Add(m_left_padding, 1); - else + else sizer->Add(1, m_left_padding); } @@ -1758,7 +1758,7 @@ bool wxAuiToolBar::Realize() { if (horizontal) sizer_item = sizer->Add(separator_size, 1, 0, wxEXPAND); - else + else sizer_item = sizer->Add(1, separator_size, 0, wxEXPAND); // add tool packing @@ -1773,7 +1773,7 @@ bool wxAuiToolBar::Realize() case wxITEM_SPACER: if (item.proportion > 0) sizer_item = sizer->AddStretchSpacer(item.proportion); - else + else sizer_item = sizer->Add(item.spacer_pixels, 1); break; @@ -1786,11 +1786,11 @@ bool wxAuiToolBar::Realize() vert_sizer->AddStretchSpacer(1); ctrl_sizer_item = vert_sizer->Add(item.window, 0, wxEXPAND); vert_sizer->AddStretchSpacer(1); - if ((m_style & wxAUI_TB_TEXT) && - m_tool_text_orientation == wxAUI_TBTOOL_TEXT_BOTTOM && - item.label.Length() > 0) + if ( (m_style & wxAUI_TB_TEXT) && + m_tool_text_orientation == wxAUI_TBTOOL_TEXT_BOTTOM && + !item.GetLabel().empty() ) { - wxSize s = GetLabelSize(item.label); + wxSize s = GetLabelSize(item.GetLabel()); vert_sizer->Add(1, s.y); } @@ -1829,7 +1829,7 @@ bool wxAuiToolBar::Realize() { if (horizontal) sizer->Add(m_right_padding, 1); - else + else sizer->Add(1, m_right_padding); } @@ -1843,10 +1843,10 @@ bool wxAuiToolBar::Realize() { if (horizontal) m_overflow_sizer_item = sizer->Add(overflow_size, 1, 0, wxEXPAND); - else + else m_overflow_sizer_item = sizer->Add(1, overflow_size, 0, wxEXPAND); } - else + else { m_overflow_sizer_item = NULL; } @@ -1861,7 +1861,7 @@ bool wxAuiToolBar::Realize() { if (horizontal) outside_sizer->Add(1, m_top_padding); - else + else outside_sizer->Add(m_top_padding, 1); } @@ -1873,7 +1873,7 @@ bool wxAuiToolBar::Realize() { if (horizontal) outside_sizer->Add(1, m_bottom_padding); - else + else outside_sizer->Add(m_bottom_padding, 1); } @@ -1911,12 +1911,12 @@ bool wxAuiToolBar::Realize() { SetClientSize(new_size); } - else + else { m_sizer->SetDimension(0, 0, cur_size.x, cur_size.y); } } - else + else { wxSize cur_size = GetClientSize(); m_sizer->SetDimension(0, 0, cur_size.x, cur_size.y); @@ -1944,7 +1944,7 @@ wxRect wxAuiToolBar::GetOverflowRect() const overflow_rect.width = cli_rect.width; overflow_rect.height = overflow_size; } - else + else { overflow_rect.x = cli_rect.width - overflow_size; overflow_rect.y = 0; @@ -1998,7 +1998,7 @@ void wxAuiToolBar::DoIdleUpdate() bool is_enabled; if (item.window) is_enabled = item.window->IsEnabled(); - else + else is_enabled = (item.state & wxAUI_BUTTON_STATE_DISABLED) ? false : true; bool new_enabled = evt.GetEnabled(); @@ -2008,11 +2008,11 @@ void wxAuiToolBar::DoIdleUpdate() { item.window->Enable(new_enabled); } - else + else { if (new_enabled) item.state &= ~wxAUI_BUTTON_STATE_DISABLED; - else + else item.state |= wxAUI_BUTTON_STATE_DISABLED; } need_refresh = true; @@ -2032,7 +2032,7 @@ void wxAuiToolBar::DoIdleUpdate() { if (new_checked) item.state |= wxAUI_BUTTON_STATE_CHECKED; - else + else item.state &= ~wxAUI_BUTTON_STATE_CHECKED; need_refresh = true; @@ -2057,7 +2057,7 @@ void wxAuiToolBar::OnSize(wxSizeEvent& WXUNUSED(evt)) if (x > y) SetOrientation(wxHORIZONTAL); - else + else SetOrientation(wxVERTICAL); if (((x >= y) && m_absolute_min_size.x > x) || @@ -2075,7 +2075,7 @@ void wxAuiToolBar::OnSize(wxSizeEvent& WXUNUSED(evt)) } } } - else + else { // show all flexible items size_t i, count; @@ -2142,7 +2142,7 @@ void wxAuiToolBar::OnPaint(wxPaintEvent& WXUNUSED(evt)) wxRect gripper_rect = m_gripper_sizer_item->GetRect(); if (horizontal) gripper_rect.width = gripper_size; - else + else gripper_rect.height = gripper_size; m_art->DrawGripper(dc, this, gripper_rect); } @@ -2151,7 +2151,7 @@ void wxAuiToolBar::OnPaint(wxPaintEvent& WXUNUSED(evt)) int last_extent; if (horizontal) last_extent = cli_rect.width; - else + else last_extent = cli_rect.height; if (m_overflow_visible) last_extent -= dropdown_size; @@ -2179,25 +2179,25 @@ void wxAuiToolBar::OnPaint(wxPaintEvent& WXUNUSED(evt)) // draw a separator m_art->DrawSeparator(dc, this, item_rect); } - else if (item.kind == wxITEM_LABEL) + else if (item.kind == wxITEM_LABEL) { // draw a text label only m_art->DrawLabel(dc, this, item, item_rect); } - else if (item.kind == wxITEM_NORMAL) + else if (item.kind == wxITEM_NORMAL) { // draw a regular button or dropdown button if (!item.dropdown) m_art->DrawButton(dc, this, item, item_rect); - else + else m_art->DrawDropDownButton(dc, this, item, item_rect); } - else if (item.kind == wxITEM_CHECK) + else if (item.kind == wxITEM_CHECK) { // draw a toggle button m_art->DrawButton(dc, this, item, item_rect); } - else if (item.kind == wxITEM_CONTROL) + else if (item.kind == wxITEM_CONTROL) { // draw the control's label m_art->DrawControlLabel(dc, this, item, item_rect); @@ -2261,7 +2261,7 @@ void wxAuiToolBar::OnLeftDown(wxMouseEvent& evt) { DoIdleUpdate(); } - else + else { size_t i, count; wxAuiToolBarItemArray overflow_items; @@ -2357,14 +2357,14 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt) m_action_item = NULL; return; } - else + else { wxAuiToolBarItem* hit_item; hit_item = FindToolByPosition(evt.GetX(), evt.GetY()); if (m_action_item && hit_item == m_action_item) { - SetToolTip(NULL); + UnsetToolTip(); if (hit_item->kind == wxITEM_CHECK) { @@ -2372,7 +2372,7 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt) if (m_action_item->state & wxAUI_BUTTON_STATE_CHECKED) toggle = false; - else + else toggle = true; ToggleTool(m_action_item->id, toggle); @@ -2382,7 +2382,7 @@ void wxAuiToolBar::OnLeftUp(wxMouseEvent& evt) ProcessEvent(e); DoIdleUpdate(); } - else + else { wxCommandEvent e(wxEVT_COMMAND_MENU_SELECTED, m_action_item->id); e.SetEventObject(this); @@ -2453,7 +2453,7 @@ void wxAuiToolBar::OnRightUp(wxMouseEvent& evt) DoIdleUpdate(); } } - else + else { // right-clicked on the invalid area of the toolbar wxAuiToolBarEvent e(wxEVT_COMMAND_AUITOOLBAR_RIGHT_CLICK, -1); @@ -2538,7 +2538,7 @@ void wxAuiToolBar::OnMotion(wxMouseEvent& evt) m_action_pos != wxPoint(-1,-1) && abs(evt.m_x - m_action_pos.x) + abs(evt.m_y - m_action_pos.y) > 5) { - SetToolTip(NULL); + UnsetToolTip(); m_dragging = true; @@ -2555,10 +2555,10 @@ void wxAuiToolBar::OnMotion(wxMouseEvent& evt) { if (!(hit_item->state & wxAUI_BUTTON_STATE_DISABLED)) SetHoverItem(hit_item); - else + else SetHoverItem(NULL); } - else + else { // no hit item, remove any hit item SetHoverItem(hit_item); @@ -2573,15 +2573,15 @@ void wxAuiToolBar::OnMotion(wxMouseEvent& evt) { m_tip_item = packing_hit_item; - if (packing_hit_item->short_help.Length() > 0) + if ( !packing_hit_item->short_help.empty() ) SetToolTip(packing_hit_item->short_help); - else - SetToolTip(NULL); + else + UnsetToolTip(); } } - else + else { - SetToolTip(NULL); + UnsetToolTip(); m_tip_item = NULL; } @@ -2591,7 +2591,7 @@ void wxAuiToolBar::OnMotion(wxMouseEvent& evt) { if (m_action_item == hit_item) SetPressedItem(m_action_item); - else + else SetPressedItem(NULL); } diff --git a/version-script.in b/version-script.in index 503fa4fce8..a6db3de926 100644 --- a/version-script.in +++ b/version-script.in @@ -29,6 +29,7 @@ @WX_VERSION_TAG@.9 { *wxAuiTabCtrl*OnCaptureLost*; *wxAuiToolBar*; + *wxWindow*UnsetToolTip*; }; @WX_VERSION_TAG@.8 {