Motif wxNotebook about done; added print/preview to OGLEdit sample

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@925 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-10-27 17:58:46 +00:00
parent 31811e1aca
commit 0280030162
20 changed files with 290 additions and 65 deletions

View File

@@ -1087,7 +1087,7 @@ void wxListMainWindow::OnRenameAccept()
void wxListMainWindow::OnMouse( wxMouseEvent &event )
{
if (GetParent()->ProcessEvent( event)) return;
if (GetParent()->GetEventHandler()->ProcessEvent( event)) return;
if (!m_current) return;
if (m_dirty) return;
@@ -1402,7 +1402,7 @@ void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
wxFocusEvent event( wxEVT_SET_FOCUS, GetParent()->GetId() );
event.SetEventObject( GetParent() );
GetParent()->ProcessEvent( event );
GetParent()->GetEventHandler()->ProcessEvent( event );
}
void wxListMainWindow::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
@@ -2054,7 +2054,7 @@ void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data )
bool wxListMainWindow::OnListNotify( wxListEvent &event )
{
if (GetParent()) GetParent()->ProcessEvent( event );
if (GetParent()) GetParent()->GetEventHandler()->ProcessEvent( event );
return FALSE;
}

View File

@@ -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,7 +590,7 @@ 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 ++;
@@ -779,7 +791,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)
);

View File

@@ -112,8 +112,6 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW);
ChangeBackgroundColour();
return TRUE;
@@ -751,10 +749,41 @@ void wxListBox::ChangeFont(bool keepOriginalSize)
void wxListBox::ChangeBackgroundColour()
{
wxWindow::ChangeBackgroundColour();
Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb;
XtVaGetValues (parent,
XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb,
NULL);
/* TODO: should scrollbars be affected? Should probably have separate
* function to change them (by default, taken from wxSystemSettings)
DoChangeBackgroundColour((WXWidget) hsb, m_backgroundColour, TRUE);
DoChangeBackgroundColour((WXWidget) vsb, m_backgroundColour, TRUE);
*/
DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
}
void wxListBox::ChangeForegroundColour()
{
wxWindow::ChangeForegroundColour();
Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb;
XtVaGetValues (parent,
XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb,
NULL);
/* TODO: should scrollbars be affected? Should probably have separate
* function to change them (by default, taken from wxSystemSettings)
DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
*/
}

View File

@@ -26,6 +26,9 @@
#include <wx/notebook.h>
#include <wx/dcclient.h>
#include <Xm/Xm.h>
#include <wx/motif/private.h>
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
@@ -96,16 +99,9 @@ bool wxNotebook::Create(wxWindow *parent,
{
// base init
SetName(name);
SetParent(parent);
m_windowId = id == -1 ? NewControlId() : id;
// style
m_windowStyle = style;
if ( parent != NULL )
parent->AddChild(this);
// It's like a normal window...
if (!wxWindow::Create(parent, id, pos, size, style, name))
return FALSE;
@@ -137,6 +133,9 @@ int wxNotebook::GetRowCount() const
int wxNotebook::SetSelection(int nPage)
{
if (nPage == -1)
return 0;
wxASSERT( IS_VALID_PAGE(nPage) );
ChangePage(m_nSelection, nPage);
@@ -250,6 +249,7 @@ bool wxNotebook::InsertPage(int nPage,
wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
m_tabView->AddTab(nPage, strText);
pPage->Show(FALSE);
/*
if (bSelect)
@@ -323,9 +323,13 @@ void wxNotebook::OnSize(wxSizeEvent& event)
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();
if (pPage->IsShown())
{
wxRect clientRect = GetAvailableClientSize();
pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height);
if ( pPage->GetAutoLayout() )
pPage->Layout();
}
}
Refresh();
}
@@ -401,12 +405,20 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
if ( nOldSel != -1 ) {
m_aPages[nOldSel]->Show(FALSE);
m_aPages[nOldSel]->Lower();
}
wxNotebookPage *pPage = m_aPages[nSel];
wxRect clientRect = GetAvailableClientSize();
pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height);
pPage->Show(TRUE);
pPage->Raise();
pPage->SetFocus();
Refresh();
m_nSelection = nSel;
}
@@ -438,6 +450,23 @@ void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event) )
m_tabView->Draw(dc);
}
wxRect wxNotebook::GetAvailableClientSize()
{
int cw, ch;
GetClientSize(& cw, & ch);
int tabHeight = m_tabView->GetTotalTabHeight();
// TODO: these margins should be configurable.
wxRect rect;
rect.x = 6;
rect.y = tabHeight + 6;
rect.width = cw - 12;
rect.height = ch - 4 - rect.y ;
return rect;
}
/*
* wxNotebookTabView
*/
@@ -448,8 +477,6 @@ wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style): wxTabVie
{
m_notebook = notebook;
// m_currentWindow = (wxWindow *) NULL;
m_notebook->SetTabView(this);
SetWindow(m_notebook);
@@ -457,7 +484,6 @@ wxNotebookTabView::wxNotebookTabView(wxNotebook *notebook, long style): wxTabVie
wxNotebookTabView::~wxNotebookTabView(void)
{
// ClearWindows(TRUE);
}
// Called when a tab is activated
@@ -465,16 +491,44 @@ void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId)
{
if (!m_notebook)
return;
wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId());
event.SetEventObject(m_notebook);
event.SetSelection(activateId);
event.SetOldSelection(deactivateId);
m_notebook->GetEventHandler()->ProcessEvent(event);
/*
wxWindow *oldWindow = ((deactivateId == -1) ? 0 : m_notebook->GetPage(deactivateId));
wxWindow *newWindow = m_notebook->GetPage(activateId);
if (oldWindow)
{
oldWindow->Show(FALSE);
oldWindow->Lower();
}
if (newWindow)
{
newWindow->Show(TRUE);
newWindow->Raise();
int cw, ch;
m_notebook->GetClientSize(& cw, & ch);
int tabHeight = GetTotalTabHeight();
wxRect rect;
rect.x = 4;
rect.y = tabHeight + 4;
rect.width = cw - 8;
rect.height = ch - 4 - rect.y ;
newWindow->SetSize(rect.x + 2, rect.y + 2, rect.width - 2, rect.height - 2);
newWindow->Refresh();
}
// TODO: only refresh the tab area.
m_notebook->Refresh();
*/
}
#if 0

View File

@@ -74,7 +74,8 @@ wxColour wxSystemSettings::GetSystemColour(int index)
case wxSYS_COLOUR_INFOBK:
case wxSYS_COLOUR_APPWORKSPACE:
{
return *wxWHITE;
return wxColour("LIGHT GREY");
// return *wxWHITE;
}
}
return *wxWHITE;

View File

@@ -646,11 +646,47 @@ void wxTextCtrl::ChangeFont(bool keepOriginalSize)
void wxTextCtrl::ChangeBackgroundColour()
{
wxWindow::ChangeBackgroundColour();
Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb;
XtVaGetValues (parent,
XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb,
NULL);
/* TODO: should scrollbars be affected? Should probably have separate
* function to change them (by default, taken from wxSystemSettings)
if (hsb)
DoChangeBackgroundColour((WXWidget) hsb, m_backgroundColour, TRUE);
if (vsb)
DoChangeBackgroundColour((WXWidget) vsb, m_backgroundColour, TRUE);
*/
DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
}
void wxTextCtrl::ChangeForegroundColour()
{
wxWindow::ChangeForegroundColour();
Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb;
XtVaGetValues (parent,
XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb,
NULL);
/* TODO: should scrollbars be affected? Should probably have separate
* function to change them (by default, taken from wxSystemSettings)
if (hsb)
DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
if (vsb)
DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
*/
DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
}
static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr)

View File

@@ -740,6 +740,8 @@ bool wxWindow::Show(bool show)
{
if (m_borderWidget || m_scrolledWindow)
{
if (m_drawingArea)
XtMapWidget((Widget) m_drawingArea);
XtMapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
}
else
@@ -751,6 +753,8 @@ bool wxWindow::Show(bool show)
{
if (m_borderWidget || m_scrolledWindow)
{
if (m_drawingArea)
XtUnmapWidget((Widget) m_drawingArea);
XtUnmapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
}
else
@@ -1387,7 +1391,18 @@ void wxWindow::RemoveChild(wxWindow *child)
void wxWindow::DestroyChildren()
{
if (GetChildren()) {
if (GetChildren())
{
wxNode *node = GetChildren()->First();
while (node)
{
wxNode* next = node->Next();
wxWindow* child = (wxWindow*) node->Data();
delete child;
node = next;
}
GetChildren()->Clear();
#if 0
wxNode *node;
while ((node = GetChildren()->First()) != (wxNode *)NULL) {
wxWindow *child;
@@ -1397,6 +1412,7 @@ void wxWindow::DestroyChildren()
delete node;
}
} /* while */
#endif
}
}

View File

@@ -854,7 +854,7 @@ bool wxApp::SendIdleEvents(wxWindow* win)
wxIdleEvent event;
event.SetEventObject(win);
win->ProcessEvent(event);
win->GetEventHandler()->ProcessEvent(event);
if (event.MoreRequested())
needMore = TRUE;

View File

@@ -242,7 +242,7 @@ bool wxControl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
event.SetEventType(eventType);
event.SetEventObject(this);
if ( !ProcessEvent(event) )
if ( !GetEventHandler()->ProcessEvent(event) )
return FALSE;
return TRUE;
#else

View File

@@ -544,7 +544,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{
wxSysColourChangedEvent event2;
event2.SetEventObject( m_frameStatusBar );
m_frameStatusBar->ProcessEvent(event2);
m_frameStatusBar->GetEventHandler()->ProcessEvent(event2);
}
// Propagate the event to the non-top-level children

View File

@@ -508,7 +508,7 @@ void wxMenu::ProcessCommand(wxCommandEvent & event)
// Try the window the menu was popped up from (and up
// through the hierarchy)
if ( !processed && GetInvokingWindow())
processed = GetInvokingWindow()->ProcessEvent(event);
processed = GetInvokingWindow()->GetEventHandler()->ProcessEvent(event);
}
extern wxMenu *wxCurrentPopupMenu;

View File

@@ -398,7 +398,7 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
// pass to the parent
if ( GetParent() ) {
event.SetCurrentFocus(this);
GetParent()->ProcessEvent(event);
GetParent()->GetEventHandler()->ProcessEvent(event);
}
}
}
@@ -453,7 +453,7 @@ bool wxNotebook::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
event.SetEventObject(this);
event.SetInt(LOWORD(wParam));
return ProcessEvent(event);
return GetEventHandler()->ProcessEvent(event);
}
// ----------------------------------------------------------------------------

View File

@@ -252,7 +252,7 @@ bool wxSpinButton::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
event.eventObject = this;
event.SetEventType(eventType);
if ( !ProcessEvent(event) )
if ( !GetEventHandler()->ProcessEvent(event) )
return FALSE;
*/
return TRUE;

View File

@@ -1034,7 +1034,7 @@ bool wxTextCtrl::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
: wxEVT_SET_FOCUS,
m_windowId);
event.SetEventObject( this );
ProcessEvent(event);
GetEventHandler()->ProcessEvent(event);
}
break;
@@ -1083,7 +1083,7 @@ bool wxTextCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
event.SetEventObject( this );
event.SetEventType(eventType);
if ( !ProcessEvent(event) )
if ( !GetEventHandler()->ProcessEvent(event) )
return FALSE;
return TRUE;

View File

@@ -3575,7 +3575,7 @@ void wxWindow::OnChar(wxKeyEvent& event)
// propagate the TABs to the parent - it's up to it to decide what
// to do with it
if ( GetParent() ) {
if ( GetParent()->ProcessEvent(event) )
if ( GetParent()->GetEventHandler()->ProcessEvent(event) )
return;
}
}