#include "wx/tab.h"
+// not defined: use old, square tab implementation (fills in tabs)
+// defined: use new, rounded tab implementation (doesn't colour in tabs)
+// #define wxUSE_NEW_METHOD
+
IMPLEMENT_DYNAMIC_CLASS(wxTabControl, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxTabLayer, wxList)
{
m_view = v;
m_isSelected = FALSE;
- m_labelFont = NULL;
m_offsetX = 0;
m_offsetY = 0;
m_width = 0;
void wxTabControl::OnDraw(wxDC& dc, bool lastInRow)
{
// Old, but in some ways better (drawing opaque tabs)
-#if 0
+#ifndef wxUSE_NEW_METHOD
if (!m_view)
return;
int tabHeightInc = 0;
if (m_isSelected)
{
- tabHeightInc = (view->GetTabSelectionHeight() - view->GetTabHeight());
+ tabHeightInc = (m_view->GetTabSelectionHeight() - m_view->GetTabHeight());
tabY -= tabHeightInc;
}
- dc.SetPen(wxTRANSPARENT_PEN);
+ dc.SetPen(*wxTRANSPARENT_PEN);
// Draw grey background
- if (view->GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR)
+ if (m_view->GetTabStyle() & wxTAB_STYLE_COLOUR_INTERIOR)
{
- dc.SetBrush(m_view->GetBackgroundBrush());
+ 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
- dc.SetPen(m_view->GetHighlightPen());
+ dc.SetPen(*m_view->GetHighlightPen());
// Calculate the top of the tab beneath. It's the height of the tab, MINUS
// a bit if the tab below happens to be selected. Check.
dc.DrawLine(tabX, tabY, tabX, (tabY + GetHeight() + tabHeightInc - subtractThis));
dc.DrawLine(tabX, tabY, (tabX + GetWidth()), tabY);
- dc.SetPen(m_view->GetShadowPen());
+ dc.SetPen(*m_view->GetShadowPen());
// Test if we're outside the right-hand edge of the view area
if (((tabX + GetWidth()) >= m_view->GetViewRect().x + m_view->GetViewRect().width) && (m_view->GetTabStyle() & wxTAB_STYLE_DRAW_BOX))
(tabX + GetWidth()), (bottomY-1));
// Draw black line to emphasize shadow
- dc.SetPen(wxBLACK_PEN);
+ dc.SetPen(*wxBLACK_PEN);
dc.DrawLine((tabX + GetWidth() + 1), (tabY+1),
(tabX + GetWidth() + 1), bottomY);
int maxPositions = ((wxTabLayer *)m_view->GetLayers().Nth(0)->Data())->Number();
// Only down to the bottom of the tab, not to the top of the view
- if ( GetColPosition() < maxPositions )
+ 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
- dc.SetPen(wxBLACK_PEN);
+ dc.SetPen(*wxBLACK_PEN);
dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1),
topY);
}
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));
// Draw black line to emphasize shadow
- dc.SetPen(wxBLACK_PEN);
+ dc.SetPen(*wxBLACK_PEN);
dc.DrawLine((tabX + GetWidth() + 1), (tabY+1), (tabX + GetWidth() + 1),
(tabY + GetHeight() + tabHeightInc - subtractThis));
}
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);
-// dc.SetTextForeground(&(m_view->GetTextColour()));
+ dc.SetTextForeground(col);
dc.SetBackgroundMode(wxTRANSPARENT);
- float textWidth, textHeight;
+ long textWidth, textHeight;
dc.GetTextExtent(GetLabel(), &textWidth, &textHeight);
int textX = (int)(tabX + (GetWidth() - textWidth)/2.0);
if (m_isSelected)
{
- dc.SetPen(m_view->GetHighlightPen());
+ dc.SetPen(*m_view->GetHighlightPen());
// Draw white highlight from the tab's left side to the left hand edge of the view
dc.DrawLine(m_view->GetViewRect().x, (tabY + GetHeight() + tabHeightInc),
dc.DrawLine((tabX + GetWidth()), (tabY + GetHeight() + tabHeightInc),
m_view->GetViewRect().x + m_view->GetViewRect().width, (tabY + GetHeight() + tabHeightInc));
}
-#endif
+#else
+ // New HEL version with rounder tabs
-// New HEL version with rounder tabs
-#if 1
if (!m_view) return;
int tabInc = 0;
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_window = NULL;
+ 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
+// TODO: this should just add the tab to a list, and then
+// a layout function (e.g. Realize) should be called when all tabs have been added.
+// The view rect could easily change as the view window is resized.
wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *existingTab)
{
// First, find which layer we should be adding to.
{
tabLayer = new wxTabLayer;
m_layers.Append(tabLayer);
- lastTabNode = NULL;
+ lastTabNode = (wxNode *) NULL;
}
}
int layer = m_layers.Number() - 1;
tabControl->SetRowPosition(tabLayer->Number());
tabControl->SetColPosition(layer);
- wxTabControl *lastTab = NULL;
+ wxTabControl *lastTab = (wxTabControl *) NULL;
if (lastTabNode)
lastTab = (wxTabControl *)lastTabNode->Data();
tabControl->SetSize(GetTabWidth(), GetTabHeight());
tabControl->SetId(id);
tabControl->SetLabel(label);
- tabControl->SetFont(GetTabFont());
+ tabControl->SetFont(* GetTabFont());
tabLayer->Append(tabControl);
m_noTabs ++;
return tabControl;
}
+// 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).
+int wxTabView::GetTotalTabHeight()
+{
+ int minY = 0;
+
+ 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->GetY() < minY)
+ minY = tab->GetY();
+
+ tabNode = tabNode->Next();
+ }
+ layerNode = layerNode->Next();
+ }
+
+ return - minY;
+}
+
void wxTabView::ClearTabs(bool deleteTabs)
{
wxNode *layerNode = m_layers.First();
layerNode = nextLayerNode;
}
}
-
+
+
// Layout tabs (optional, e.g. if resizing window)
void wxTabView::Layout(void)
{
layerNode = nextLayerNode;
}
- wxTabControl *lastTab = NULL;
+ wxTabControl *lastTab = (wxTabControl *) NULL;
wxTabLayer *currentLayer = new wxTabLayer;
m_layers.Append(currentLayer);
{
currentLayer = new wxTabLayer;
m_layers.Append(currentLayer);
- lastTab = NULL;
+ lastTab = (wxTabControl *) NULL;
}
}
}
-#if 0
+#ifndef wxUSE_NEW_METHOD
if (GetTabStyle() & wxTAB_STYLE_DRAW_BOX)
{
dc.SetPen(GetShadowPen());
dc.DrawLine(
(GetViewRect().x + 1),
(GetViewRect().y + GetViewRect().height),
- (GetViewRect().x + GetViewRect().width),
+ (GetViewRect().x + GetViewRect().width + 1),
(GetViewRect().y + GetViewRect().height)
);
dc.DrawLine(
(GetViewRect().x),
(GetViewRect().y + GetViewRect().height + 1),
- (GetViewRect().x + GetViewRect().width),
+#if defined(__WXMOTIF__)
+ (GetViewRect().x + GetViewRect().width + 1),
+#else
+ (GetViewRect().x + GetViewRect().width + 2),
+#endif
+
(GetViewRect().y + GetViewRect().height + 1)
);
float x, y;
event.Position(&x, &y);
- wxTabControl *hitControl = NULL;
+ wxTabControl *hitControl = (wxTabControl *) NULL;
wxNode *node = m_layers.First();
while (node)
if (control->HitTest((int)x, (int)y))
{
hitControl = control;
- node = NULL;
- node2 = NULL;
+ node = (wxNode *) NULL;
+ node2 = (wxNode *) NULL;
}
else
node2 = node2->Next();
control->SetSelected((sel != 0)); // TODO ??
else
{
- wxMessageBox("Could not find tab for id", "Error", wxOK);
+ wxMessageBox(_("Could not find tab for id"), _("Error"), wxOK);
return;
}
}
node1 = node1->Next();
}
- return NULL;
+ return (wxTabControl *) NULL;
}
// Find tab control for layer, position (starting from zero)
{
wxNode *node1 = m_layers.Nth(layer);
if (!node1)
- return NULL;
+ return (wxTabControl *) NULL;
wxTabLayer *tabLayer = (wxTabLayer *)node1->Data();
wxNode *node2 = tabLayer->Nth(position);
if (!node2)
- return NULL;
+ return (wxTabControl *) NULL;
return (wxTabControl *)node2->Data();
}
}
node1 = node1->Next();
}
- return NULL;
+ return (wxNode *) NULL;
}
int wxTabView::CalculateTabWidth(int noTabs, bool adjustView)
long windowStyle, const wxString& name):
wxDialog(parent, id, title, pos, size, windowStyle, name)
{
- m_tabView = NULL;
+ m_tabView = (wxTabView *) NULL;
}
wxTabbedDialog::~wxTabbedDialog(void)
const wxSize& size, long windowStyle, const wxString& name):
wxPanel(parent, id, pos, size, windowStyle, name)
{
- m_tabView = NULL;
+ m_tabView = (wxTabView *) NULL;
}
wxTabbedPanel::~wxTabbedPanel(void)
}
/*
- * wxDialogTabView
+ * wxPanelTabView
*/
IMPLEMENT_CLASS(wxPanelTabView, wxTabView)
wxPanelTabView::wxPanelTabView(wxPanel *pan, long style): wxTabView(style), m_tabWindows(wxKEY_INTEGER)
{
m_panel = pan;
- m_currentWindow = NULL;
+ m_currentWindow = (wxWindow *) NULL;
if (m_panel->IsKindOf(CLASSINFO(wxTabbedDialog)))
((wxTabbedDialog *)m_panel)->SetTabView(this);
{
wxNode *node = m_tabWindows.Find((long)id);
if (!node)
- return NULL;
+ return (wxWindow *) NULL;
return (wxWindow *)node->Data();
}