Motif and other mods

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@918 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-10-26 17:10:25 +00:00
parent f4a4bd13d4
commit 4b5f3fe655
60 changed files with 618 additions and 203 deletions

View File

@@ -158,12 +158,12 @@ bool wxFTP::GetResult(char exp)
{
if ((m_lastError = GetLine(this, m_lastResult)))
return FALSE;
if (m_lastResult[0] != exp) {
if (m_lastResult.GetChar(0) != exp) {
m_lastError = wxPROTO_PROTERR;
return FALSE;
}
if (m_lastResult[3] == '-') {
if (m_lastResult.GetChar(3) == '-') {
wxString key = m_lastResult.Left((size_t)3);
key += ' ';

View File

@@ -31,6 +31,10 @@
#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)
@@ -56,7 +60,7 @@ wxTabControl::~wxTabControl(void)
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;
@@ -70,23 +74,23 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow)
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.
dc.DrawRectangle(tabX, tabY, (GetWidth()+1), (GetHeight() + 1 + tabHeightInc));
}
// 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.
@@ -107,7 +111,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow)
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))
@@ -126,7 +130,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow)
(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);
@@ -145,13 +149,13 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow)
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;
// 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);
}
@@ -171,7 +175,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow)
(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));
}
@@ -181,15 +185,14 @@ 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);
// 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);
@@ -197,7 +200,7 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow)
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),
@@ -207,10 +210,9 @@ void wxTabControl::OnDraw(wxDC& dc, bool lastInRow)
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;
@@ -518,6 +520,9 @@ wxTabView::~wxTabView()
}
// 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.
@@ -581,6 +586,32 @@ wxTabControl *wxTabView::AddTab(int id, const wxString& label, wxTabControl *exi
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();
@@ -603,7 +634,8 @@ void wxTabView::ClearTabs(bool deleteTabs)
layerNode = nextLayerNode;
}
}
// Layout tabs (optional, e.g. if resizing window)
void wxTabView::Layout(void)
{
@@ -720,7 +752,7 @@ void wxTabView::Draw(wxDC& dc)
}
#if 0
#ifndef wxUSE_NEW_METHOD
if (GetTabStyle() & wxTAB_STYLE_DRAW_BOX)
{
dc.SetPen(GetShadowPen());
@@ -729,7 +761,7 @@ void wxTabView::Draw(wxDC& dc)
dc.DrawLine(
(GetViewRect().x + 1),
(GetViewRect().y + GetViewRect().height),
(GetViewRect().x + GetViewRect().width),
(GetViewRect().x + GetViewRect().width + 1),
(GetViewRect().y + GetViewRect().height)
);
@@ -747,7 +779,7 @@ void wxTabView::Draw(wxDC& dc)
dc.DrawLine(
(GetViewRect().x),
(GetViewRect().y + GetViewRect().height + 1),
(GetViewRect().x + GetViewRect().width),
(GetViewRect().x + GetViewRect().width + 2),
(GetViewRect().y + GetViewRect().height + 1)
);
@@ -1088,7 +1120,7 @@ void wxTabbedPanel::OnPaint(wxPaintEvent& WXUNUSED(event) )
}
/*
* wxDialogTabView
* wxPanelTabView
*/
IMPLEMENT_CLASS(wxPanelTabView, wxTabView)

View File

@@ -67,7 +67,7 @@ wxColour::wxColour()
{
}
wxColour::wxColour( char red, char green, char blue )
wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue )
{
m_refData = new wxColourRefData();
M_COLDATA->m_color.red = ((unsigned short)red) << SHIFT;
@@ -128,7 +128,7 @@ bool wxColour::operator != ( const wxColour& col)
return m_refData != col.m_refData;
}
void wxColour::Set( const unsigned char red, const unsigned char green, const unsigned char blue )
void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue )
{
UnRef();
m_refData = new wxColourRefData();

View File

@@ -67,7 +67,7 @@ wxColour::wxColour()
{
}
wxColour::wxColour( char red, char green, char blue )
wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue )
{
m_refData = new wxColourRefData();
M_COLDATA->m_color.red = ((unsigned short)red) << SHIFT;
@@ -128,7 +128,7 @@ bool wxColour::operator != ( const wxColour& col)
return m_refData != col.m_refData;
}
void wxColour::Set( const unsigned char red, const unsigned char green, const unsigned char blue )
void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue )
{
UnRef();
m_refData = new wxColourRefData();

View File

@@ -79,6 +79,8 @@ bool wxApp::Initialize()
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize();
wxInitializeStockLists();
wxInitializeStockObjects();
#if wxUSE_WX_RESOURCES

View File

@@ -90,6 +90,9 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
m_mainWidget = (WXWidget) buttonWidget;
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
ChangeBackgroundColour ();
DoSetBitmap();
@@ -100,9 +103,6 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
return TRUE;
}

View File

@@ -74,11 +74,12 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
XtAddCallback ((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
(XtPointer) this);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -135,9 +136,9 @@ void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr)
item->ProcessCommand (event);
}
void wxButton::ChangeFont()
void wxButton::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxButton::ChangeBackgroundColour()

View File

@@ -66,12 +66,13 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
XmToggleButtonSetState ((Widget) m_mainWidget, FALSE, TRUE);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
SetFont(* parent->GetFont());
return TRUE;
}
@@ -151,9 +152,9 @@ void wxCheckBoxCallback (Widget w, XtPointer clientData,
item->ProcessCommand (event);
}
void wxCheckBox::ChangeFont()
void wxCheckBox::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxCheckBox::ChangeBackgroundColour()

View File

@@ -125,9 +125,11 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -173,9 +175,12 @@ void wxChoice::Append(const wxString& item)
WXWidget *new_widgetList = new WXWidget[m_noStrings + 1];
int i;
for (i = 0; i < m_noStrings; i++)
new_widgetList[i] = m_widgetList[i];
if (m_widgetList)
for (i = 0; i < m_noStrings; i++)
new_widgetList[i] = m_widgetList[i];
new_widgetList[m_noStrings] = (WXWidget) w;
if (m_widgetList)
delete[] m_widgetList;
m_widgetList = new_widgetList;
@@ -420,7 +425,7 @@ void wxChoiceCallback (Widget w, XtPointer clientData,
}
}
void wxChoice::ChangeFont()
void wxChoice::ChangeFont(bool keepOriginalSize)
{
// Note that this causes the widget to be resized back
// to its original size! We therefore have to set the size
@@ -434,11 +439,13 @@ void wxChoice::ChangeFont()
XtVaSetValues ((Widget) m_mainWidget, XmNfontList, fontList, NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNfontList, fontList, NULL);
/* TODO: why does this cause a crash in XtWidgetToApplicationContext?
int i;
for (i = 0; i < m_noStrings; i++)
XtVaSetValues ((Widget) m_widgetList[i], XmNfontList, fontList, NULL);
*/
GetSize(& width1, & height1);
if (width != width1 || height != height1)
if (keepOriginalSize && (width != width1 || height != height1))
{
SetSize(-1, -1, width, height);
}

View File

@@ -83,10 +83,12 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
SetValue(value);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -207,10 +209,10 @@ void wxComboBoxCallback (Widget w, XtPointer clientData,
}
}
void wxComboBox::ChangeFont()
void wxComboBox::ChangeFont(bool keepOriginalSize)
{
// Don't use the base class wxChoice's ChangeFont
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxComboBox::ChangeBackgroundColour()

View File

@@ -139,12 +139,15 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
XmStringFree(str);
}
m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
ChangeFont(FALSE);
wxAddWindowToTable(dialogShell, this);
// Intercept CLOSE messages from the window manager
Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
/* MATTHEW: [8] Remove and add WM_DELETE_WINDOW so ours is only handler */
/* Remove and add WM_DELETE_WINDOW so ours is only handler */
/* Why do we have to do this for wxDialog, but not wxFrame? */
XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1);
XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1);
@@ -236,7 +239,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
(XtPointer)this);
ChangeBackgroundColour();
SetFont(* parent->GetFont());
return TRUE;
}
@@ -745,7 +747,7 @@ static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call)
*/
}
void wxDialog::ChangeFont()
void wxDialog::ChangeFont(bool keepOriginalSize)
{
// TODO
}

View File

@@ -128,6 +128,7 @@ bool wxFrame::Create(wxWindow *parent,
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
m_foregroundColour = *wxBLACK;
m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
if ( id > -1 )
m_windowId = id;
@@ -222,6 +223,8 @@ bool wxFrame::Create(wxWindow *parent,
m_mainWidget = m_frameWidget;
ChangeFont(FALSE);
// This patch comes from Torsten Liermann lier@lier1.muc.de
if (XmIsMotifWMRunning( (Widget) m_frameShell ))
{
@@ -1040,7 +1043,7 @@ WXWidget wxFrame::GetClientWidget() const
return m_clientArea;
}
void wxFrame::ChangeFont()
void wxFrame::ChangeFont(bool keepOriginalSize)
{
// TODO
}

View File

@@ -123,10 +123,12 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
if (height == -1)
height = 80;
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -188,9 +190,9 @@ int wxGauge::GetValue() const
// return m_gaugePos;
}
void wxGauge::ChangeFont()
void wxGauge::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxGauge::ChangeBackgroundColour()

View File

@@ -107,11 +107,13 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
XtAddCallback (listWidget, XmNdefaultActionCallback, (XtCallbackProc) wxListBoxDefaultActionProc,
(XtPointer) this);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -741,9 +743,9 @@ WXWidget wxListBox::GetTopWidget() const
return (WXWidget) XtParent( (Widget) m_mainWidget );
}
void wxListBox::ChangeFont()
void wxListBox::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxListBox::ChangeBackgroundColour()

View File

@@ -24,6 +24,7 @@
#include <wx/log.h>
#include <wx/imaglist.h>
#include <wx/notebook.h>
#include <wx/dcclient.h>
// ----------------------------------------------------------------------------
// macros
@@ -39,8 +40,9 @@
#if !USE_SHARED_LIBRARIES
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
EVT_SIZE(wxNotebook::OnSize)
EVT_PAINT(wxNotebook::OnPaint)
EVT_MOUSE_EVENTS(wxNotebook::OnMouseEvent)
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
END_EVENT_TABLE()
@@ -60,6 +62,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
// common part of all ctors
void wxNotebook::Init()
{
m_tabView = (wxNotebookTabView*) NULL;
m_pImageList = NULL;
m_nSelection = -1;
}
@@ -103,14 +106,19 @@ bool wxNotebook::Create(wxWindow *parent,
if ( parent != NULL )
parent->AddChild(this);
// TODO
// It's like a normal window...
if (!wxWindow::Create(parent, id, pos, size, style, name))
return FALSE;
return FALSE;
SetTabView(new wxNotebookTabView(this));
return TRUE;
}
// dtor
wxNotebook::~wxNotebook()
{
delete m_tabView;
}
// ----------------------------------------------------------------------------
@@ -192,6 +200,10 @@ void wxNotebook::SetImageList(wxImageList* imageList)
// remove one page from the notebook
bool wxNotebook::DeletePage(int nPage)
{
wxFAIL_MSG("Sorry, DeletePage not implemented for Motif wxNotebook because wxTabView doesn't support it.");
return FALSE;
/*
wxCHECK( IS_VALID_PAGE(nPage), FALSE );
// TODO: delete native widget page
@@ -200,12 +212,13 @@ bool wxNotebook::DeletePage(int nPage)
m_aPages.Remove(nPage);
return TRUE;
*/
}
// remove all pages
bool wxNotebook::DeleteAllPages()
{
// TODO: delete native widget pages
m_tabView->ClearTabs(TRUE);
int nPageCount = GetPageCount();
int nPage;
@@ -236,7 +249,12 @@ bool wxNotebook::InsertPage(int nPage,
wxASSERT( pPage != NULL );
wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
// TODO: insert native widget page
m_tabView->AddTab(nPage, strText);
/*
if (bSelect)
m_tabView->SetTabSelection(nPage, TRUE);
*/
// save the pointer to the page
m_aPages.Insert(pPage, nPage);
@@ -265,24 +283,51 @@ void wxNotebook::OnSize(wxSizeEvent& event)
s_bFirstTime = FALSE;
}
// TODO: all this may or may not be necessary for your platform
if (m_tabView)
{
int cw, ch;
GetClientSize(& cw, & ch);
// emulate page change (it's esp. important to do it first time because
// otherwise our page would stay invisible)
int nSel = m_nSelection;
m_nSelection = -1;
SetSelection(nSel);
int tabHeight = m_tabView->GetTotalTabHeight();
wxRect rect;
rect.x = 4;
rect.y = tabHeight + 4;
rect.width = cw - 8;
rect.height = ch - 4 - rect.y ;
m_tabView->SetViewRect(rect);
// fit the notebook page to the tab control's display area
int w, h;
GetSize(&w, &h);
m_tabView->Layout();
unsigned int nCount = m_aPages.Count();
for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
wxNotebookPage *pPage = m_aPages[nPage];
pPage->SetSize(0, 0, w, h);
if ( pPage->GetAutoLayout() )
pPage->Layout();
// Need to do it a 2nd time to get the tab height with
// the new view width, since changing the view width changes the
// tab layout.
tabHeight = m_tabView->GetTotalTabHeight();
rect.x = 4;
rect.y = tabHeight + 4;
rect.width = cw - 8;
rect.height = ch - 4 - rect.y ;
m_tabView->SetViewRect(rect);
m_tabView->Layout();
// emulate page change (it's esp. important to do it first time because
// otherwise our page would stay invisible)
int nSel = m_nSelection;
m_nSelection = -1;
SetSelection(nSel);
// fit the notebook page to the tab control's display area
unsigned int nCount = m_aPages.Count();
for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
wxNotebookPage *pPage = m_aPages[nPage];
pPage->SetSize(rect.x + 2, rect.y + 2, rect.width - 2, rect.height - 2);
if ( pPage->GetAutoLayout() )
pPage->Layout();
}
Refresh();
}
// Processing continues to next OnSize
@@ -365,18 +410,105 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
m_nSelection = nSel;
}
void wxNotebook::ChangeFont()
void wxNotebook::ChangeFont(bool keepOriginalSize)
{
// TODO
wxWindow::ChangeFont(keepOriginalSize);
}
void wxNotebook::ChangeBackgroundColour()
{
// TODO
wxWindow::ChangeBackgroundColour();
}
void wxNotebook::ChangeForegroundColour()
{
// TODO
wxWindow::ChangeForegroundColour();
}
void wxNotebook::OnMouseEvent(wxMouseEvent& event)
{
if (m_tabView)
m_tabView->OnEvent(event);
}
void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event) )
{
wxPaintDC dc(this);
if (m_tabView)
m_tabView->Draw(dc);
}
/*
* wxNotebookTabView
*/
IMPLEMENT_CLASS(wxNotebookTabView, wxTabView)
wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style): wxTabView(style)
{
m_notebook = notebook;
// m_currentWindow = (wxWindow *) NULL;
m_notebook->SetTabView(this);
SetWindow(m_notebook);
}
wxNotebookTabView::~wxNotebookTabView(void)
{
// ClearWindows(TRUE);
}
// Called when a tab is activated
void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId)
{
if (!m_notebook)
return;
wxWindow *oldWindow = ((deactivateId == -1) ? 0 : m_notebook->GetPage(deactivateId));
wxWindow *newWindow = m_notebook->GetPage(activateId);
if (oldWindow)
oldWindow->Show(FALSE);
if (newWindow)
newWindow->Show(TRUE);
m_notebook->Refresh();
}
#if 0
void wxNotebookTabView::AddTabWindow(int id, wxWindow *window)
{
m_tabWindows.Append((long)id, window);
window->Show(FALSE);
}
wxWindow *wxNotebookTabView::GetTabWindow(int id) const
{
wxNode *node = m_tabWindows.Find((long)id);
if (!node)
return (wxWindow *) NULL;
return (wxWindow *)node->Data();
}
void wxNotebookTabView::ClearWindows(bool deleteWindows)
{
if (deleteWindows)
m_tabWindows.DeleteContents(TRUE);
m_tabWindows.Clear();
m_tabWindows.DeleteContents(FALSE);
}
void wxNotebookTabView::ShowWindowForTab(int id)
{
wxWindow *newWindow = GetTabWindow(id);
if (newWindow == m_currentWindow)
return;
if (m_currentWindow)
m_currentWindow->Show(FALSE);
newWindow->Show(TRUE);
newWindow->Refresh();
}
#endif

View File

@@ -172,12 +172,14 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
}
SetSelection (0);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
XtManageChild (radioBoxWidget);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -391,7 +393,7 @@ void wxRadioBox::Command (wxCommandEvent & event)
ProcessCommand (event);
}
void wxRadioBox::ChangeFont()
void wxRadioBox::ChangeFont(bool keepOriginalSize)
{
// TODO
}

View File

@@ -81,12 +81,14 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
m_mainWidget = (WXWidget) radioButtonWidget;
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
XtManageChild (radioButtonWidget);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -111,9 +113,9 @@ void wxRadioButton::Command (wxCommandEvent & event)
ProcessCommand (event);
}
void wxRadioButton::ChangeFont()
void wxRadioButton::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxRadioButton::ChangeBackgroundColour()

View File

@@ -152,7 +152,7 @@ void wxScrollBar::Command(wxCommandEvent& event)
ProcessCommand(event);
}
void wxScrollBar::ChangeFont()
void wxScrollBar::ChangeFont(bool keepOriginalSize)
{
// TODO
}

View File

@@ -99,10 +99,12 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -247,9 +249,9 @@ void wxSlider::Command (wxCommandEvent & event)
ProcessCommand (event);
}
void wxSlider::ChangeFont()
void wxSlider::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxSlider::ChangeBackgroundColour()

View File

@@ -68,7 +68,7 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
// TODO
}
void wxSpinButton::ChangeFont()
void wxSpinButton::ChangeFont(bool keepOriginalSize)
{
// TODO
}

View File

@@ -66,11 +66,12 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
XmNlabelType, XmPIXMAP,
NULL);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour ();
return TRUE;
@@ -119,9 +120,9 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
}
}
void wxStaticBitmap::ChangeFont()
void wxStaticBitmap::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxStaticBitmap::ChangeBackgroundColour()

View File

@@ -181,9 +181,9 @@ void wxStaticBox::SetSize(int x, int y, int width, int height, int sizeFlags)
}
}
void wxStaticBox::ChangeFont()
void wxStaticBox::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxStaticBox::ChangeBackgroundColour()

View File

@@ -64,19 +64,20 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
XmStringFree (text);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour ();
return TRUE;
}
void wxStaticText::ChangeFont()
void wxStaticText::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxStaticText::ChangeBackgroundColour()

View File

@@ -143,10 +143,12 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this);
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -636,9 +638,9 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
}
}
void wxTextCtrl::ChangeFont()
void wxTextCtrl::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont();
wxWindow::ChangeFont(keepOriginalSize);
}
void wxTextCtrl::ChangeBackgroundColour()

View File

@@ -98,10 +98,12 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
m_mainWidget = (WXWidget) toolbar;
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
SetFont(* parent->GetFont());
ChangeBackgroundColour();
return TRUE;
@@ -297,20 +299,22 @@ bool wxToolBar::CreateTools()
void wxToolBar::SetToolBitmapSize(const wxSize& size)
{
// TODO not necessary?
m_defaultWidth = size.x; m_defaultHeight = size.y;
// TODO
}
wxSize wxToolBar::GetMaxSize() const
{
// TODO
return wxSize(0, 0);
int w, h;
GetSize(& w, & h);
return wxSize(w, h);
}
// The button size is bigger than the bitmap size
wxSize wxToolBar::GetToolSize() const
{
// TODO
// TODO not necessary?
return wxSize(m_defaultWidth + 8, m_defaultHeight + 7);
}

View File

@@ -3070,7 +3070,7 @@ void wxWindow::SetForegroundColour(const wxColour& col)
ChangeForegroundColour();
}
void wxWindow::ChangeFont()
void wxWindow::ChangeFont(bool keepOriginalSize)
{
// Note that this causes the widget to be resized back
// to its original size! We therefore have to set the size
@@ -3086,7 +3086,7 @@ void wxWindow::ChangeFont()
NULL);
GetSize(& width1, & height1);
if (width != width1 || height != height1)
if (keepOriginalSize && (width != width1 || height != height1))
{
SetSize(-1, -1, width, height);
}

View File

@@ -69,6 +69,8 @@ bool wxApp::Initialize()
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize();
wxInitializeStockLists();
wxInitializeStockObjects();
#if wxUSE_WX_RESOURCES