X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4b5f3fe655deeb91d5d3abe8fad30c4a1cae63dc..a38b83c353cce75329b2c53c0eaa4ad0f500ccf1:/src/generic/tabg.cpp diff --git a/src/generic/tabg.cpp b/src/generic/tabg.cpp index 5adc584c4c..cc6a601bc5 100644 --- a/src/generic/tabg.cpp +++ b/src/generic/tabg.cpp @@ -43,7 +43,6 @@ wxTabControl::wxTabControl(wxTabView *v) { m_view = v; m_isSelected = FALSE; - m_labelFont = (wxFont *) NULL; m_offsetX = 0; m_offsetY = 0; m_width = 0; @@ -86,7 +85,11 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) dc.SetBrush(*m_view->GetBackgroundBrush()); // Add 1 because the pen is transparent. Under Motif, may be different. +#ifdef __WXMOTIF__ + dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + tabHeightInc)); +#else dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc)); +#endif } // Draw highlight and shadow @@ -152,6 +155,10 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) if ( GetRowPosition() < (maxPositions - 1) ) topY = tabY + GetHeight() + tabHeightInc; +#ifdef __WXMOTIF__ + topY -= 1; +#endif + // Shadow dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), topY); // Draw black line to emphasize shadow @@ -170,6 +177,10 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) if (tabBeneath && tabBeneath->IsSelected()) subtractThis = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight()); +#ifdef __WXMOTIF__ + subtractThis += 1; +#endif + // Draw only to next tab down. dc.DrawLine((tabX + GetWidth()), tabY, (tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc - subtractThis)); @@ -185,9 +196,9 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow) int textY = tabY + m_view->GetVerticalTabTextSpacing() + tabHeightInc; if (m_isSelected) - dc.SetFont(*m_view->GetSelectedTabFont()); + dc.SetFont(* m_view->GetSelectedTabFont()); else - dc.SetFont(*GetFont()); + dc.SetFont(* GetFont()); wxColour col(m_view->GetTextColour()); dc.SetTextForeground(col); @@ -510,13 +521,14 @@ wxTabView::wxTabView(long style) m_shadowPen = wxGREY_PEN; m_backgroundPen = wxLIGHT_GREY_PEN; m_backgroundBrush = wxLIGHT_GREY_BRUSH; - m_tabFont = wxTheFontList->FindOrCreateFont(9, wxSWISS, wxNORMAL, wxNORMAL); - m_tabSelectedFont = wxTheFontList->FindOrCreateFont(9, wxSWISS, wxNORMAL, wxBOLD); + m_tabFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); + m_tabSelectedFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); m_window = (wxWindow *) NULL; } wxTabView::~wxTabView() { + ClearTabs(TRUE); } // Automatically positions tabs @@ -578,13 +590,42 @@ wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *exi tabControl->SetSize(GetTabWidth(), GetTabHeight()); tabControl->SetId(id); tabControl->SetLabel(label); - tabControl->SetFont(GetTabFont()); + tabControl->SetFont(* GetTabFont()); tabLayer->Append(tabControl); m_noTabs ++; return tabControl; } + +// Remove the tab without deleting the window +bool wxTabView::RemoveTab(int id) +{ + wxNode *layerNode = m_layers.First(); + while (layerNode) + { + wxTabLayer *layer = (wxTabLayer *)layerNode->Data(); + wxNode *tabNode = layer->First(); + while (tabNode) + { + wxTabControl *tab = (wxTabControl *)tabNode->Data(); + if (tab->GetId() == id) + { + if (id == m_tabSelection) + m_tabSelection = -1; + delete tab; + delete tabNode; + + // The layout has changed + Layout(); + return TRUE; + } + tabNode = tabNode->Next(); + } + layerNode = layerNode->Next(); + } + return FALSE; +} // Returns the total height of the tabs component -- this may be several // times the height of a tab, if there are several tab layers (rows). @@ -779,7 +820,12 @@ void wxTabView::Draw(wxDC& dc) dc.DrawLine( (GetViewRect().x), (GetViewRect().y + GetViewRect().height + 1), +#if defined(__WXMOTIF__) + (GetViewRect().x + GetViewRect().width + 1), +#else (GetViewRect().x + GetViewRect().width + 2), +#endif + (GetViewRect().y + GetViewRect().height + 1) ); @@ -951,20 +997,26 @@ void wxTabView::SetTabSelection(int sel, bool activateTool) { int oldSel = m_tabSelection; wxTabControl *control = FindTabControlForId(sel); + wxTabControl *oldControl = FindTabControlForId(m_tabSelection); if (!OnTabPreActivate(sel, oldSel)) return; if (control) - control->SetSelected((sel != 0)); // TODO ?? - else + control->SetSelected((sel != -1)); // TODO ?? + else if (sel != -1) { - wxMessageBox(_("Could not find tab for id"), _("Error"), wxOK); + wxFAIL_MSG(_("Could not find tab for id")); return; } + + if (oldControl) + oldControl->SetSelected(FALSE); m_tabSelection = sel; - MoveSelectionTab(control); + + if (control) + MoveSelectionTab(control); if (activateTool) OnTabActivate(sel, oldSel);