X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8896cb72d256dbb1bed12724699ee9e72c74b14c..4ca64d4137439844a5e6c95b4da16f32cf7840ab:/src/aui/auibook.cpp diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp index b6e23ea1cd..c9dd327873 100644 --- a/src/aui/auibook.cpp +++ b/src/aui/auibook.cpp @@ -179,6 +179,11 @@ private: 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x03, 0xF8, 0x01, 0xF0, 0x19, 0xF3, 0xB8, 0xE3, 0xF0, 0xE1, 0xE0, 0xE0, 0xF0, 0xE1, 0xB8, 0xE3, 0x19, 0xF3, 0x01, 0xF0, 0x03, 0xF8, 0x0F, 0xFE, 0xFF, 0xFF }; +#elif defined( __WXGTK__) + static unsigned char close_bits[]={ + 0xff, 0xff, 0xff, 0xff, 0x07, 0xf0, 0xfb, 0xef, 0xdb, 0xed, 0x8b, 0xe8, + 0x1b, 0xec, 0x3b, 0xee, 0x1b, 0xec, 0x8b, 0xe8, 0xdb, 0xed, 0xfb, 0xef, + 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; #else static unsigned char close_bits[]={ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7, 0xf3, 0xcf, 0xf9, @@ -264,7 +269,7 @@ void wxAuiDefaultTabArt::SetSizingInfo(const wxSize& tab_ctrl_size, { m_fixed_tab_width = 100; - int tot_width = tab_ctrl_size.x; + int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - 4; if (tab_count > 0) { m_fixed_tab_width = tot_width/(int)tab_count; @@ -386,7 +391,7 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc, // draw gradient background if (active) - { + { wxColour c = m_bkbrush.GetColour(); dc.SetPen(wxPen(c)); @@ -415,7 +420,7 @@ void wxAuiDefaultTabArt::DrawTab(wxDC& dc, { wxColour c = m_bkbrush.GetColour(); dc.SetPen(wxPen(c)); - dc.DrawLine(points[0].x+1, points[0].y, points[5].x, points[5].y); + dc.DrawLine(points[0].x, points[0].y, points[5].x+1, points[5].y); } int text_offset; @@ -487,11 +492,12 @@ wxSize wxAuiDefaultTabArt::GetTabSize(wxDC& dc, dc.GetTextExtent(wxT("ABCDEFXj"), &tmp, &measured_texty); - wxCoord tab_width = measured_textx + 5; + // add padding around the text + wxCoord tab_width = measured_textx + 16; wxCoord tab_height = measured_texty + 10; if (close_button_state != wxAUI_BUTTON_STATE_HIDDEN) - tab_width += m_active_close_bmp.GetWidth() + 8; + tab_width += m_active_close_bmp.GetWidth() + 3; if (m_flags & wxAUI_NB_TAB_FIXED_WIDTH) @@ -709,7 +715,7 @@ void wxAuiSimpleTabArt::SetSizingInfo(const wxSize& tab_ctrl_size, { m_fixed_tab_width = 100; - int tot_width = tab_ctrl_size.x; + int tot_width = (int)tab_ctrl_size.x - GetIndentSize() - 4; if (tab_count > 0) { m_fixed_tab_width = tot_width/(int)tab_count; @@ -1397,6 +1403,9 @@ void wxAuiTabContainer::SetTabOffset(size_t offset) // provide custom drawing capabilities void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) { + if (!raw_dc || !raw_dc->IsOk()) + return; + wxMemoryDC dc; wxBitmap bmp; size_t i; @@ -1407,6 +1416,8 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) bmp.Create(m_rect.GetWidth(), m_rect.GetHeight()); dc.SelectObject(bmp); + if (!dc.IsOk()) + return; // find out if size of tabs is larger than can be // afforded on screen @@ -1624,6 +1635,10 @@ void wxAuiTabContainer::Render(wxDC* raw_dc, wxWindow* wnd) rect.x = offset; rect.width = m_rect.width - right_buttons_width - offset - 2; + if (rect.width <= 0) + break; + + m_art->DrawTab(dc, @@ -1726,7 +1741,9 @@ bool wxAuiTabContainer::ButtonHitTest(int x, int y, for (i = 0; i < button_count; ++i) { wxAuiTabContainerButton& button = m_buttons.Item(i); - if (button.rect.Contains(x,y)) + if (button.rect.Contains(x,y) && + !(button.cur_state & (wxAUI_BUTTON_STATE_HIDDEN | + wxAUI_BUTTON_STATE_DISABLED))) { if (hit) *hit = &button; @@ -1738,7 +1755,9 @@ bool wxAuiTabContainer::ButtonHitTest(int x, int y, for (i = 0; i < button_count; ++i) { wxAuiTabContainerButton& button = m_tab_close_buttons.Item(i); - if (button.rect.Contains(x,y)) + if (button.rect.Contains(x,y) && + !(button.cur_state & (wxAUI_BUTTON_STATE_HIDDEN | + wxAUI_BUTTON_STATE_DISABLED))) { if (hit) *hit = &button; @@ -1824,6 +1843,7 @@ wxAuiTabCtrl::wxAuiTabCtrl(wxWindow* parent, m_click_pt = wxDefaultPosition; m_is_dragging = false; m_hover_button = NULL; + m_pressed_button = NULL; } wxAuiTabCtrl::~wxAuiTabCtrl() @@ -1857,6 +1877,8 @@ void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt) m_click_pt = wxDefaultPosition; m_is_dragging = false; m_click_tab = NULL; + m_pressed_button = NULL; + wxWindow* wnd; if (TabHitTest(evt.m_x, evt.m_y, &wnd)) @@ -1871,16 +1893,17 @@ void wxAuiTabCtrl::OnLeftDown(wxMouseEvent& evt) m_click_pt.y = evt.m_y; m_click_tab = wnd; } - + if (m_hover_button) { - m_hover_button->cur_state = wxAUI_BUTTON_STATE_PRESSED; + m_pressed_button = m_hover_button; + m_pressed_button->cur_state = wxAUI_BUTTON_STATE_PRESSED; Refresh(); Update(); } } -void wxAuiTabCtrl::OnLeftUp(wxMouseEvent&) +void wxAuiTabCtrl::OnLeftUp(wxMouseEvent& evt) { if (GetCapture() == this) ReleaseMouse(); @@ -1895,19 +1918,31 @@ void wxAuiTabCtrl::OnLeftUp(wxMouseEvent&) return; } - if (m_hover_button) + if (m_pressed_button) { - m_hover_button->cur_state = wxAUI_BUTTON_STATE_HOVER; + // make sure we're still clicking the button + wxAuiTabContainerButton* button = NULL; + if (!ButtonHitTest(evt.m_x, evt.m_y, &button)) + return; + + if (button != m_pressed_button) + { + m_pressed_button = NULL; + return; + } + Refresh(); Update(); - if (!(m_hover_button->cur_state & wxAUI_BUTTON_STATE_DISABLED)) + if (!(m_pressed_button->cur_state & wxAUI_BUTTON_STATE_DISABLED)) { wxAuiNotebookEvent evt(wxEVT_COMMAND_AUINOTEBOOK_BUTTON, m_windowId); - evt.SetInt(m_hover_button->id); + evt.SetInt(m_pressed_button->id); evt.SetEventObject(this); GetEventHandler()->ProcessEvent(evt); } + + m_pressed_button = NULL; } m_click_pt = wxDefaultPosition; @@ -2698,8 +2733,12 @@ void wxAuiNotebook::OnTabDragMotion(wxCommandEvent& evt) { wxWindow* tab_ctrl = ::wxFindWindowAtPoint(screen_pt); + // if we aren't over any window, stop here + if (!tab_ctrl) + return; + // make sure we are not over the hint window - if (tab_ctrl && !tab_ctrl->IsKindOf(CLASSINFO(wxFrame))) + if (!tab_ctrl->IsKindOf(CLASSINFO(wxFrame))) { while (tab_ctrl) { @@ -2714,22 +2753,32 @@ void wxAuiNotebook::OnTabDragMotion(wxCommandEvent& evt) if (nb != this) { - wxRect hint_rect = tab_ctrl->GetRect(); + wxRect hint_rect = tab_ctrl->GetClientRect(); tab_ctrl->ClientToScreen(&hint_rect.x, &hint_rect.y); m_mgr.ShowHint(hint_rect); return; } - + } + } + else + { + if (!dest_tabs) + { + // we are either over a hint window, or not over a tab + // window, and there is no where to drag to, so exit + return; } } } + // if there are less than two panes, split can't happen, so leave + if (m_tabs.GetPageCount() < 2) + return; + // if tab moving is not allowed, leave if (!(m_flags & wxAUI_NB_TAB_SPLIT)) - { return; - } if (src_tabs) @@ -2861,7 +2910,7 @@ void wxAuiNotebook::OnTabEndDrag(wxCommandEvent& command_evt) // only perform a tab split if it's allowed - if (m_flags & wxAUI_NB_TAB_SPLIT) + if ((m_flags & wxAUI_NB_TAB_SPLIT) && m_tabs.GetPageCount() >= 2) { // If the pointer is in an existing tab frame, do a tab insert wxWindow* hit_wnd = ::wxFindWindowAtPoint(mouse_screen_pt);