inline void SetLabel(const wxString& str) { m_controlLabel = str; }
inline wxString GetLabel(void) const { return m_controlLabel; }
- inline void SetFont(wxFont *f) { m_labelFont = f; }
- inline wxFont *GetFont(void) const { return m_labelFont; }
+ inline void SetFont(const wxFont& f) { m_labelFont = f; }
+ inline wxFont *GetFont(void) const { return (wxFont*) & m_labelFont; }
inline void SetSelected(bool sel) { m_isSelected = sel; }
inline bool IsSelected(void) const { return m_isSelected; }
wxTabView* m_view;
wxString m_controlLabel;
bool m_isSelected;
- wxFont* m_labelFont;
+ wxFont m_labelFont;
int m_offsetX; // Offsets from top-left of tab view area (the area below the tabs)
int m_offsetY;
int m_width;
inline void SetVerticalTabTextSpacing(int s) { m_tabVerticalTextSpacing = s; }
inline int GetVerticalTabTextSpacing() const { return m_tabVerticalTextSpacing; }
- inline wxFont *GetTabFont() const { return m_tabFont; }
- inline void SetTabFont(wxFont *f) { m_tabFont = f; }
+ inline wxFont *GetTabFont() const { return (wxFont*) & m_tabFont; }
+ inline void SetTabFont(const wxFont& f) { m_tabFont = f; }
- inline wxFont *GetSelectedTabFont() const { return m_tabSelectedFont; }
- inline void SetSelectedTabFont(wxFont *f) { m_tabSelectedFont = f; }
+ inline wxFont *GetSelectedTabFont() const { return (wxFont*) & m_tabSelectedFont; }
+ inline void SetSelectedTabFont(const wxFont& f) { m_tabSelectedFont = f; }
// Find the node and the column at which this control is positioned.
wxNode *FindTabNodeAndColumn(wxTabControl *control, int *col) const ;
wxPen* m_backgroundPen;
wxBrush* m_backgroundBrush;
- wxFont* m_tabFont;
- wxFont* m_tabSelectedFont;
+ wxFont m_tabFont;
+ wxFont m_tabSelectedFont;
int m_noTabs;
int GetSelection() const { return m_nSel; }
int GetOldSelection() const { return m_nOldSel; }
+ void SetSelection(int sel) { m_nSel = sel; }
+ void SetOldSelection(int oldSel) { m_nOldSel = oldSel; }
+
private:
int m_nSel, // currently selected page
m_nOldSel; // previously selected page
// Called when a tab is activated
virtual void OnTabActivate(int activateId, int deactivateId);
-/*
- // Specific to this class
- void AddTabWindow(int id, wxWindow *window);
- wxWindow *GetTabWindow(int id) const ;
- void ClearWindows(bool deleteWindows = TRUE);
- inline wxWindow *GetCurrentWindow() const { return m_currentWindow; }
- void ShowWindowForTab(int id);
-*/
-
protected:
-/*
- // List of panels, one for each tab. Indexed
- // by tab ID.
- wxList m_tabWindows;
- wxWindow* m_currentWindow;
-*/
wxNotebook* m_notebook;
};
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
+ virtual wxRect GetAvailableClientSize();
protected:
// common part of all ctors
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size):
wxScrolledWindow(parent, -1, pos, size, wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL)
{
+ SetBackgroundColour(wxColour("WHITE"));
}
// Define the repainting behaviour
// Add some panels
wxPanel *panel1 = new wxPanel(notebook, -1);
+ // panel1->SetBackgroundColour(wxColour("RED"));
(void)new wxButton(panel1, -1, "Press me", wxPoint(10, 10));
(void)new wxTextCtrl(panel1, -1, "1234", wxPoint(10, 40), wxSize(120, 150));
notebook->AddPage(panel1, "Cat");
wxPanel *panel2 = new wxPanel(notebook, -1);
+ panel2->SetBackgroundColour(wxColour("BLUE"));
wxString animals[] = { "Fox", "Hare", "Rabbit", "Sabre-toothed tiger", "T Rex" };
(void)new wxListBox(panel2, -1, wxPoint(5, 5), wxSize(170, 80), 5, animals);
wxTE_MULTILINE);
notebook->AddPage(panel2, "Dog");
+
+ wxPanel *panel3 = new wxPanel(notebook, -1);
+ panel3->SetBackgroundColour(wxColour("WHITE"));
+ notebook->AddPage(panel3, "Goat");
+
+ wxPanel *panel4 = new wxPanel(notebook, -1);
+ panel4->SetBackgroundColour(wxColour("YELLOW"));
+ notebook->AddPage(panel4, "Sheep");
}
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
void wxListMainWindow::OnMouse( wxMouseEvent &event )
{
- if (GetParent()->ProcessEvent( event)) return;
+ if (GetParent()->GetEventHandler()->ProcessEvent( event)) return;
if (!m_current) return;
if (m_dirty) return;
wxFocusEvent event( wxEVT_SET_FOCUS, GetParent()->GetId() );
event.SetEventObject( GetParent() );
- GetParent()->ProcessEvent( event );
+ GetParent()->GetEventHandler()->ProcessEvent( event );
}
void wxListMainWindow::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
bool wxListMainWindow::OnListNotify( wxListEvent &event )
{
- if (GetParent()) GetParent()->ProcessEvent( event );
+ if (GetParent()) GetParent()->GetEventHandler()->ProcessEvent( event );
return FALSE;
}
{
m_view = v;
m_isSelected = FALSE;
- m_labelFont = (wxFont *) NULL;
m_offsetX = 0;
m_offsetY = 0;
m_width = 0;
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
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
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));
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);
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
tabControl->SetSize(GetTabWidth(), GetTabHeight());
tabControl->SetId(id);
tabControl->SetLabel(label);
- tabControl->SetFont(GetTabFont());
+ tabControl->SetFont(* GetTabFont());
tabLayer->Append(tabControl);
m_noTabs ++;
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)
);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
- m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW);
-
ChangeBackgroundColour();
return TRUE;
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);
+ */
}
+
#include <wx/notebook.h>
#include <wx/dcclient.h>
+#include <Xm/Xm.h>
+#include <wx/motif/private.h>
+
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
{
// 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;
int wxNotebook::SetSelection(int nPage)
{
+ if (nPage == -1)
+ return 0;
+
wxASSERT( IS_VALID_PAGE(nPage) );
ChangePage(m_nSelection, nPage);
wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
m_tabView->AddTab(nPage, strText);
+ pPage->Show(FALSE);
/*
if (bSelect)
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();
}
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;
}
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
*/
{
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
{
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
case wxSYS_COLOUR_INFOBK:
case wxSYS_COLOUR_APPWORKSPACE:
{
- return *wxWHITE;
+ return wxColour("LIGHT GREY");
+ // return *wxWHITE;
}
}
return *wxWHITE;
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)
{
if (m_borderWidget || m_scrolledWindow)
{
+ if (m_drawingArea)
+ XtMapWidget((Widget) m_drawingArea);
XtMapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
}
else
{
if (m_borderWidget || m_scrolledWindow)
{
+ if (m_drawingArea)
+ XtUnmapWidget((Widget) m_drawingArea);
XtUnmapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
}
else
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;
delete node;
}
} /* while */
+#endif
}
}
wxIdleEvent event;
event.SetEventObject(win);
- win->ProcessEvent(event);
+ win->GetEventHandler()->ProcessEvent(event);
if (event.MoreRequested())
needMore = TRUE;
event.SetEventType(eventType);
event.SetEventObject(this);
- if ( !ProcessEvent(event) )
+ if ( !GetEventHandler()->ProcessEvent(event) )
return FALSE;
return TRUE;
#else
{
wxSysColourChangedEvent event2;
event2.SetEventObject( m_frameStatusBar );
- m_frameStatusBar->ProcessEvent(event2);
+ m_frameStatusBar->GetEventHandler()->ProcessEvent(event2);
}
// Propagate the event to the non-top-level children
// 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;
// pass to the parent
if ( GetParent() ) {
event.SetCurrentFocus(this);
- GetParent()->ProcessEvent(event);
+ GetParent()->GetEventHandler()->ProcessEvent(event);
}
}
}
event.SetEventObject(this);
event.SetInt(LOWORD(wParam));
- return ProcessEvent(event);
+ return GetEventHandler()->ProcessEvent(event);
}
// ----------------------------------------------------------------------------
event.eventObject = this;
event.SetEventType(eventType);
- if ( !ProcessEvent(event) )
+ if ( !GetEventHandler()->ProcessEvent(event) )
return FALSE;
*/
return TRUE;
: wxEVT_SET_FOCUS,
m_windowId);
event.SetEventObject( this );
- ProcessEvent(event);
+ GetEventHandler()->ProcessEvent(event);
}
break;
event.SetEventObject( this );
event.SetEventType(eventType);
- if ( !ProcessEvent(event) )
+ if ( !GetEventHandler()->ProcessEvent(event) )
return FALSE;
return TRUE;
// 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;
}
}
return TRUE;
}
+#define CENTER FALSE // Place the drawing to the center of the page
+
+
// Sneakily gets used for default print/preview
-// as well as drawing on the screen.
-void DiagramView::OnDraw(wxDC *dc)
-{
+// as well as drawing on the screen.
+void DiagramView::OnDraw(wxDC *dc)
+{
+
+ /* You might use THIS code if you were scaling
+ * graphics of known size to fit on the page.
+ */
+ float w, h;
+
+ // We need to adjust for the graphic size, a formula will be added
+ float maxX = 900;
+ float maxY = 700;
+ // A better way of find the maxium values would be to search through
+ // the linked list
+
+ // Let's have at least 10 device units margin
+ float marginX = 10;
+ float marginY = 10;
+
+ // Add the margin to the graphic size
+ maxX += (2 * marginX);
+ maxY += (2 * marginY);
+
+ // Get the size of the DC in pixels
+ dc->GetSize (&w, &h);
+
+ // Calculate a suitable scaling factor
+ float scaleX = (float) (w / maxX);
+ float scaleY = (float) (h / maxY);
+
+ // Use x or y scaling factor, whichever fits on the DC
+ float actualScale = wxMin (scaleX, scaleY);
+
+ float posX, posY;
+ // Calculate the position on the DC for centring the graphic
+ if (CENTER == TRUE) // center the drawing
+ {
+ posX = (float) ((w - (200 * actualScale)) / 2.0);
+ posY = (float) ((h - (200 * actualScale)) / 2.0);
+ }
+ else // Use defined presets
+ {
+ posX = 10;
+ posY = 35;
+ }
+
+
+ // Set the scale and origin
+ dc->SetUserScale (actualScale, actualScale);
+ dc->SetDeviceOrigin (posX, posY);
+
+ // This part was added to preform the print preview and printing functions
+
+ dc->BeginDrawing(); // Allows optimization of drawing code under MS Windows.
+ wxDiagram *diagram_p=((DiagramDocument*)GetDocument())->GetDiagram(); // Get the current diagram
+ if (diagram_p->GetShapeList())
+ {
+ wxCursor *old_cursor = NULL;
+ wxNode *current = diagram_p->GetShapeList()->First();
+
+ while (current) // Loop through the entire list of shapes
+ {
+ wxShape *object = (wxShape *)current->Data();
+ if (!object->GetParent())
+ {
+ object->Draw(* dc); // Draw the shape onto our printing dc
+ }
+ current = current->Next(); // Procede to the next shape in the list
+ }
+ }
+ dc->EndDrawing(); // Allows optimization of drawing code under MS Windows.
}
void DiagramView::OnUpdate(wxView *sender, wxObject *hint)
}
}
+
/*
* Window implementations
*/