From f449ef69b45acaa2faf554af774ce7b6b5f4af4e Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Wed, 29 Jul 1998 10:43:51 +0000 Subject: [PATCH] Added missing OGL files; added defaults to wxDocMDIParentFrame; corrected toolbar usage in Dialog Editor git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/docmdi.h | 9 +- src/msw/window.cpp | 10 +- utils/dialoged/src/reseditr.cpp | 12 +- utils/dialoged/src/reseditr.h | 2 +- utils/ogl/samples/ogledit/bitmaps/arrow.bmp | Bin 0 -> 382 bytes utils/ogl/samples/ogledit/bitmaps/tool1.bmp | Bin 0 -> 382 bytes utils/ogl/samples/ogledit/bitmaps/tool2.bmp | Bin 0 -> 382 bytes utils/ogl/samples/ogledit/bitmaps/tool3.bmp | Bin 0 -> 382 bytes utils/ogl/samples/ogledit/bitmaps/tool4.bmp | Bin 0 -> 382 bytes utils/ogl/samples/ogledit/doc.cpp | 570 ++++++++++++++++++++ utils/ogl/samples/ogledit/doc.h | 172 ++++++ utils/ogl/samples/ogledit/makefile.b32 | 88 +++ utils/ogl/samples/ogledit/makefile.bcc | 87 +++ utils/ogl/samples/ogledit/makefile.dos | 103 ++++ utils/ogl/samples/ogledit/makefile.nt | 95 ++++ utils/ogl/samples/ogledit/makefile.sc | 33 ++ utils/ogl/samples/ogledit/makefile.unx | 79 +++ utils/ogl/samples/ogledit/makefile.vms | 44 ++ utils/ogl/samples/ogledit/makefile.wat | 43 ++ utils/ogl/samples/ogledit/ogl.ico | Bin 0 -> 766 bytes utils/ogl/samples/ogledit/ogledit.cpp | 211 ++++++++ utils/ogl/samples/ogledit/ogledit.def | 8 + utils/ogl/samples/ogledit/ogledit.h | 75 +++ utils/ogl/samples/ogledit/ogledit.rc | 10 + utils/ogl/samples/ogledit/palette.cpp | 115 ++++ utils/ogl/samples/ogledit/palette.h | 58 ++ utils/ogl/samples/ogledit/view.cpp | 264 +++++++++ utils/ogl/samples/ogledit/view.h | 79 +++ utils/ogl/src/basic.h | 4 +- 29 files changed, 2150 insertions(+), 21 deletions(-) create mode 100644 utils/ogl/samples/ogledit/bitmaps/arrow.bmp create mode 100644 utils/ogl/samples/ogledit/bitmaps/tool1.bmp create mode 100644 utils/ogl/samples/ogledit/bitmaps/tool2.bmp create mode 100644 utils/ogl/samples/ogledit/bitmaps/tool3.bmp create mode 100644 utils/ogl/samples/ogledit/bitmaps/tool4.bmp create mode 100644 utils/ogl/samples/ogledit/doc.cpp create mode 100644 utils/ogl/samples/ogledit/doc.h create mode 100644 utils/ogl/samples/ogledit/makefile.b32 create mode 100644 utils/ogl/samples/ogledit/makefile.bcc create mode 100644 utils/ogl/samples/ogledit/makefile.dos create mode 100644 utils/ogl/samples/ogledit/makefile.nt create mode 100644 utils/ogl/samples/ogledit/makefile.sc create mode 100644 utils/ogl/samples/ogledit/makefile.unx create mode 100644 utils/ogl/samples/ogledit/makefile.vms create mode 100644 utils/ogl/samples/ogledit/makefile.wat create mode 100644 utils/ogl/samples/ogledit/ogl.ico create mode 100644 utils/ogl/samples/ogledit/ogledit.cpp create mode 100644 utils/ogl/samples/ogledit/ogledit.def create mode 100644 utils/ogl/samples/ogledit/ogledit.h create mode 100644 utils/ogl/samples/ogledit/ogledit.rc create mode 100644 utils/ogl/samples/ogledit/palette.cpp create mode 100644 utils/ogl/samples/ogledit/palette.h create mode 100644 utils/ogl/samples/ogledit/view.cpp create mode 100644 utils/ogl/samples/ogledit/view.h diff --git a/include/wx/docmdi.h b/include/wx/docmdi.h index e0e3e6fe66..195b6126f7 100644 --- a/include/wx/docmdi.h +++ b/include/wx/docmdi.h @@ -27,8 +27,9 @@ class wxDocMDIParentFrame: public wxMDIParentFrame { DECLARE_CLASS(wxDocMDIParentFrame) public: - wxDocMDIParentFrame(wxDocManager *manager, wxFrame *frame, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, - long style, const wxString& name); + wxDocMDIParentFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, + const wxString& title, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); bool OnClose(void); // Extend event processing to search the document manager's event table @@ -55,8 +56,8 @@ class WXDLLEXPORT wxDocMDIChildFrame: public wxMDIChildFrame DECLARE_CLASS(wxDocMDIChildFrame) public: - wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id, const wxString& title, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + wxDocMDIChildFrame(wxDocument *doc, wxView *view, wxMDIParentFrame *frame, wxWindowID id, + const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long type = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"); ~wxDocMDIChildFrame(void); diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 5281e2a8bf..d5e8050619 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -81,7 +81,7 @@ #endif #ifdef __WXDEBUG__ - static const char *GetMessageName(int message); +const char *wxGetMessageName(int message); #endif //WXDEBUG #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events @@ -954,7 +954,7 @@ LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { #ifdef __WXDEBUG__ - wxLogTrace(wxTraceMessages, "Processing %s", GetMessageName(message)); + wxLogTrace(wxTraceMessages, "Processing %s", wxGetMessageName(message)); #endif // WXDEBUG HWND hWnd = (HWND)m_hWnd; @@ -1938,7 +1938,7 @@ long wxWindow::Default() #ifdef __WXDEBUG__ wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.", - GetMessageName(m_lastMsg)); + wxGetMessageName(m_lastMsg)); #endif // WXDEBUG return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam); @@ -4593,10 +4593,8 @@ bool wxWindow::IsExposed(const wxRect& rect) const return (m_updateRegion.Contains(rect) != wxOutRegion); } - - #ifdef __WXDEBUG__ -static const char *GetMessageName(int message) +const char *wxGetMessageName(int message) { switch ( message ) { case 0x0000: return "WM_NULL"; diff --git a/utils/dialoged/src/reseditr.cpp b/utils/dialoged/src/reseditr.cpp index 61d14b9b6c..80f9f0c845 100644 --- a/utils/dialoged/src/reseditr.cpp +++ b/utils/dialoged/src/reseditr.cpp @@ -732,10 +732,8 @@ wxToolBarBase *wxResourceManager::OnCreateToolBar(wxFrame *parent) #endif // Create the toolbar - EditorToolBar *toolbar = new EditorToolBar(parent, wxPoint(0, 0), wxSize(-1, -1), wxNO_BORDER, - wxVERTICAL, 1); + EditorToolBar *toolbar = new EditorToolBar(parent, wxPoint(0, 0), wxSize(-1, -1), wxNO_BORDER|wxTB_HORIZONTAL); toolbar->SetMargins(2, 2); -// toolbar->GetDC()->SetBackground(wxLIGHT_GREY_BRUSH); #ifdef __WXMSW__ int width = 24; @@ -792,11 +790,9 @@ wxToolBarBase *wxResourceManager::OnCreateToolBar(wxFrame *parent) FALSE, (float)currentX, -1, NULL, "Help"); currentX += width + dx; - toolbar->CreateTools(); + toolbar->Realize(); return toolbar; - -// parent->OnSize(-1, -1); } void wxResourceManager::UpdateResourceList() @@ -1965,8 +1961,8 @@ BEGIN_EVENT_TABLE(EditorToolBar, wxToolBar) END_EVENT_TABLE() EditorToolBar::EditorToolBar(wxFrame *frame, const wxPoint& pos, const wxSize& size, - long style, int direction, int RowsOrColumns): - wxToolBar(frame, -1, pos, size, style, direction, RowsOrColumns) + long style): + wxToolBar(frame, -1, pos, size, style) { } diff --git a/utils/dialoged/src/reseditr.h b/utils/dialoged/src/reseditr.h index 3839f94ee8..e78d4765dc 100644 --- a/utils/dialoged/src/reseditr.h +++ b/utils/dialoged/src/reseditr.h @@ -373,7 +373,7 @@ class EditorToolBar: public wxToolBar { public: EditorToolBar(wxFrame *frame, const wxPoint& pos = wxPoint(0, 0), const wxSize& size = wxSize(0, 0), - long style = 0, int direction = wxVERTICAL, int RowsOrColumns = 2); + long style = wxTB_HORIZONTAL); bool OnLeftClick(int toolIndex, bool toggled); void OnMouseEnter(int toolIndex); void OnPaint(wxPaintEvent& event); diff --git a/utils/ogl/samples/ogledit/bitmaps/arrow.bmp b/utils/ogl/samples/ogledit/bitmaps/arrow.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d406ceb64f017d99bcc2d4913aef75135de357a0 GIT binary patch literal 382 zcmb7-I}UJZQ>1WPN=;5qEQ3zc?;o59U+Ka+r!5!mH1Gr)e_0X9zQo7Bn*m`tDP z>tSJ;fdXA9#W(4KsI?;JEJm}1)|8}VswC~|bu-BQ Vombvu=JhAub(#Nm-N`e*_yJ^>eVzaS literal 0 HcmV?d00001 diff --git a/utils/ogl/samples/ogledit/bitmaps/tool1.bmp b/utils/ogl/samples/ogledit/bitmaps/tool1.bmp new file mode 100644 index 0000000000000000000000000000000000000000..cb1760d2859cd5b32630cb6c294a6c913d4b28f3 GIT binary patch literal 382 zcmZ?rtz%>WgEAng0mNcZ%*en37UzJJQ409!#Op@kUh#ZHNo5<&TT>4iR1ivT=$yRS#8XFECq!-*mgr LV^3-JfBEkPyAH!9 literal 0 HcmV?d00001 diff --git a/utils/ogl/samples/ogledit/bitmaps/tool3.bmp b/utils/ogl/samples/ogledit/bitmaps/tool3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..6a49f459c3034a9d633c00c876720d1d6ec01a59 GIT binary patch literal 382 zcmbtP$qj%o3^NiE{NTk5%)y^sc#$9KX6;C9Q0!1~{E$dv*LBpindYs6$4VZFp`b$T zep~7~^aWl(gc32H8<`R*C4>-I$ezeqir|t(vOE52cJ>w|bn4wu*h0nFrR6FbL$Ou( Uq@Q8CoZa7Pu)am`?}1?Jt#_EJF0 + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include +#endif + +#if !USE_DOC_VIEW_ARCHITECTURE +#error You must set USE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h! +#endif + +#include "ogledit.h" +#include "doc.h" +#include +#include "view.h" + +IMPLEMENT_DYNAMIC_CLASS(DiagramDocument, wxDocument) + +DiagramDocument::DiagramDocument(void) +{ +} + +DiagramDocument::~DiagramDocument(void) +{ +} + +bool DiagramDocument::OnCloseDocument(void) +{ + diagram.DeleteAllShapes(); + return TRUE; +} + +ostream& DiagramDocument::SaveObject(ostream& stream) +{ + wxDocument::SaveObject(stream); + + char buf[400]; + (void) wxGetTempFileName("diag", buf); + + diagram.SaveFile(buf); + wxTransferFileToStream(buf, stream); + + wxRemoveFile(buf); + + return stream; +} + +istream& DiagramDocument::LoadObject(istream& stream) +{ + wxDocument::LoadObject(stream); + + char buf[400]; + (void) wxGetTempFileName("diag", buf); + + wxTransferStreamToFile(stream, buf); + + diagram.DeleteAllShapes(); + diagram.LoadFile(buf); + wxRemoveFile(buf); + + return stream; +} + +/* + * Implementation of drawing command + */ + +DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxClassInfo *info, float xx, float yy, + bool sel, wxShape *theShape, wxShape *fs, wxShape *ts): + wxCommand(TRUE, name) +{ + doc = ddoc; + cmd = command; + shape = theShape; + fromShape = fs; + toShape = ts; + shapeInfo = info; + shapeBrush = NULL; + shapePen = NULL; + x = xx; + y = yy; + selected = sel; + deleteShape = FALSE; +} + +DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape): + wxCommand(TRUE, name) +{ + doc = ddoc; + cmd = command; + shape = theShape; + fromShape = NULL; + toShape = NULL; + shapeInfo = NULL; + x = 0.0; + y = 0.0; + selected = FALSE; + deleteShape = FALSE; + shapeBrush = backgroundColour; + shapePen = NULL; +} + +DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape): + wxCommand(TRUE, name) +{ + doc = ddoc; + cmd = command; + shape = theShape; + fromShape = NULL; + toShape = NULL; + shapeInfo = NULL; + x = 0.0; + y = 0.0; + selected = FALSE; + deleteShape = FALSE; + shapeBrush = NULL; + shapePen = NULL; + shapeLabel = lab; +} + +DiagramCommand::~DiagramCommand(void) +{ + if (shape && deleteShape) + { + shape->SetCanvas(NULL); + delete shape; + } +} + +bool DiagramCommand::Do(void) +{ + switch (cmd) + { + case OGLEDIT_CUT: + { + if (shape) + { + deleteShape = TRUE; + + shape->Select(FALSE); + + // Generate commands to explicitly remove each connected line. + RemoveLines(shape); + + doc->GetDiagram()->RemoveShape(shape); + if (shape->IsKindOf(CLASSINFO(wxLineShape))) + { + wxLineShape *lineShape = (wxLineShape *)shape; + fromShape = lineShape->GetFrom(); + toShape = lineShape->GetTo(); + } + shape->Unlink(); + + doc->Modify(TRUE); + doc->UpdateAllViews(); + } + + break; + } + case OGLEDIT_ADD_SHAPE: + { + wxShape *theShape = NULL; + if (shape) + theShape = shape; // Saved from undoing the shape + else + { + theShape = (wxShape *)shapeInfo->CreateObject(); + theShape->AssignNewIds(); + theShape->SetEventHandler(new MyEvtHandler(theShape, theShape, wxString(""))); + theShape->SetCentreResize(FALSE); + theShape->SetPen(wxBLACK_PEN); + theShape->SetBrush(wxCYAN_BRUSH); + + theShape->SetSize(60, 60); + } + doc->GetDiagram()->AddShape(theShape); + theShape->Show(TRUE); + + wxClientDC dc(theShape->GetCanvas()); + theShape->GetCanvas()->PrepareDC(dc); + + theShape->Move(dc, x, y); + + shape = theShape; + deleteShape = FALSE; + + doc->Modify(TRUE); + doc->UpdateAllViews(); + break; + } + case OGLEDIT_ADD_LINE: + { + wxShape *theShape = NULL; + if (shape) + theShape = shape; // Saved from undoing the line + else + { + theShape = (wxShape *)shapeInfo->CreateObject(); + theShape->AssignNewIds(); + theShape->SetEventHandler(new MyEvtHandler(theShape, theShape, wxString(""))); + theShape->SetPen(wxBLACK_PEN); + theShape->SetBrush(wxRED_BRUSH); + + wxLineShape *lineShape = (wxLineShape *)theShape; + + // Yes, you can have more than 2 control points, in which case + // it becomes a multi-segment line. + lineShape->MakeLineControlPoints(2); + lineShape->AddArrow(ARROW_ARROW, ARROW_POSITION_END, 10.0, 0.0, "Normal arrowhead"); + } + + doc->GetDiagram()->AddShape(theShape); + + fromShape->AddLine((wxLineShape *)theShape, toShape); + + theShape->Show(TRUE); + + wxClientDC dc(theShape->GetCanvas()); + theShape->GetCanvas()->PrepareDC(dc); + + // It won't get drawn properly unless you move both + // connected images + fromShape->Move(dc, fromShape->GetX(), fromShape->GetY()); + toShape->Move(dc, toShape->GetX(), toShape->GetY()); + + shape = theShape; + deleteShape = FALSE; + + doc->Modify(TRUE); + doc->UpdateAllViews(); + break; + } + case OGLEDIT_CHANGE_BACKGROUND_COLOUR: + { + if (shape) + { + wxClientDC dc(shape->GetCanvas()); + shape->GetCanvas()->PrepareDC(dc); + + wxBrush *oldBrush = shape->GetBrush(); + shape->SetBrush(shapeBrush); + shapeBrush = oldBrush; + shape->Draw(dc); + + doc->Modify(TRUE); + doc->UpdateAllViews(); + } + + break; + } + case OGLEDIT_EDIT_LABEL: + { + if (shape) + { + MyEvtHandler *myHandler = (MyEvtHandler *)shape->GetEventHandler(); + wxString oldLabel(myHandler->label); + myHandler->label = shapeLabel; + shapeLabel = oldLabel; + + wxClientDC dc(shape->GetCanvas()); + shape->GetCanvas()->PrepareDC(dc); + + shape->FormatText(dc, (char*) (const char*) myHandler->label); + shape->Draw(dc); + + doc->Modify(TRUE); + doc->UpdateAllViews(); + } + + break; + } + } + return TRUE; +} + +bool DiagramCommand::Undo(void) +{ + switch (cmd) + { + case OGLEDIT_CUT: + { + if (shape) + { + doc->GetDiagram()->AddShape(shape); + shape->Show(TRUE); + + if (shape->IsKindOf(CLASSINFO(wxLineShape))) + { + wxLineShape *lineShape = (wxLineShape *)shape; + + fromShape->AddLine(lineShape, toShape); + } + if (selected) + shape->Select(TRUE); + + deleteShape = FALSE; + } + doc->Modify(TRUE); + doc->UpdateAllViews(); + break; + } + case OGLEDIT_ADD_SHAPE: + case OGLEDIT_ADD_LINE: + { + if (shape) + { + wxClientDC dc(shape->GetCanvas()); + shape->GetCanvas()->PrepareDC(dc); + + shape->Select(FALSE, &dc); + doc->GetDiagram()->RemoveShape(shape); + shape->Unlink(); + deleteShape = TRUE; + } + doc->Modify(TRUE); + doc->UpdateAllViews(); + break; + } + case OGLEDIT_CHANGE_BACKGROUND_COLOUR: + { + if (shape) + { + wxClientDC dc(shape->GetCanvas()); + shape->GetCanvas()->PrepareDC(dc); + + wxBrush *oldBrush = shape->GetBrush(); + shape->SetBrush(shapeBrush); + shapeBrush = oldBrush; + shape->Draw(dc); + + doc->Modify(TRUE); + doc->UpdateAllViews(); + } + break; + } + case OGLEDIT_EDIT_LABEL: + { + if (shape) + { + MyEvtHandler *myHandler = (MyEvtHandler *)shape->GetEventHandler(); + wxString oldLabel(myHandler->label); + myHandler->label = shapeLabel; + shapeLabel = oldLabel; + + wxClientDC dc(shape->GetCanvas()); + shape->GetCanvas()->PrepareDC(dc); + + shape->FormatText(dc, (char*) (const char*) myHandler->label); + shape->Draw(dc); + + doc->Modify(TRUE); + doc->UpdateAllViews(); + } + + break; + } + } + return TRUE; +} + +// Remove each individual line connected to a shape by sending a command. +void DiagramCommand::RemoveLines(wxShape *shape) +{ + wxNode *node = shape->GetLines().First(); + while (node) + { + wxLineShape *line = (wxLineShape *)node->Data(); + doc->GetCommandProcessor()->Submit(new DiagramCommand("Cut", OGLEDIT_CUT, doc, NULL, 0.0, 0.0, line->Selected(), line)); + + node = shape->GetLines().First(); + } +} + +/* + * MyEvtHandler: an event handler class for all shapes + */ + +void MyEvtHandler::OnLeftClick(float x, float y, int keys, int attachment) +{ + wxClientDC dc(GetShape()->GetCanvas()); + GetShape()->GetCanvas()->PrepareDC(dc); + + if (keys == 0) + { + // Selection is a concept the library knows about + if (GetShape()->Selected()) + { + GetShape()->Select(FALSE, &dc); + GetShape()->GetCanvas()->Redraw(dc); // Redraw because bits of objects will be are missing + } + else + { + // Ensure no other shape is selected, to simplify Undo/Redo code + bool redraw = FALSE; + wxNode *node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->First(); + while (node) + { + wxShape *eachShape = (wxShape *)node->Data(); + if (eachShape->GetParent() == NULL) + { + if (eachShape->Selected()) + { + eachShape->Select(FALSE, &dc); + redraw = TRUE; + } + } + node = node->Next(); + } + GetShape()->Select(TRUE, &dc); + if (redraw) + GetShape()->GetCanvas()->Redraw(dc); + } + } + else if (keys & KEY_CTRL) + { + // Do something for CONTROL + } + else + { + wxGetApp().frame->SetStatusText(label); + } +} + +/* + * Implement connection of two shapes by right-dragging between them. + */ + +void MyEvtHandler::OnBeginDragRight(float x, float y, int keys, int attachment) +{ + // Force attachment to be zero for now. Eventually we can deal with + // the actual attachment point, e.g. a rectangle side if attachment mode is on. + attachment = 0; + + wxClientDC dc(GetShape()->GetCanvas()); + GetShape()->GetCanvas()->PrepareDC(dc); + + wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + dc.SetLogicalFunction(wxXOR); + dc.SetPen(dottedPen); + float xp, yp; + GetShape()->GetAttachmentPosition(attachment, &xp, &yp); + dc.DrawLine(xp, yp, x, y); + GetShape()->GetCanvas()->CaptureMouse(); +} + +void MyEvtHandler::OnDragRight(bool draw, float x, float y, int keys, int attachment) +{ + // Force attachment to be zero for now + attachment = 0; + + wxClientDC dc(GetShape()->GetCanvas()); + GetShape()->GetCanvas()->PrepareDC(dc); + + wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT); + dc.SetLogicalFunction(wxXOR); + dc.SetPen(dottedPen); + float xp, yp; + GetShape()->GetAttachmentPosition(attachment, &xp, &yp); + dc.DrawLine(xp, yp, x, y); +} + +void MyEvtHandler::OnEndDragRight(float x, float y, int keys, int attachment) +{ + GetShape()->GetCanvas()->ReleaseMouse(); + MyCanvas *canvas = (MyCanvas *)GetShape()->GetCanvas(); + + // Check if we're on an object + int new_attachment; + wxShape *otherShape = canvas->FindFirstSensitiveShape(x, y, &new_attachment, OP_DRAG_RIGHT); + + if (otherShape && !otherShape->IsKindOf(CLASSINFO(wxLineShape))) + { + canvas->view->GetDocument()->GetCommandProcessor()->Submit( + new DiagramCommand("wxLineShape", OGLEDIT_ADD_LINE, (DiagramDocument *)canvas->view->GetDocument(), CLASSINFO(wxLineShape), + 0.0, 0.0, FALSE, NULL, GetShape(), otherShape)); + } +} + +void MyEvtHandler::OnEndSize(float x, float y) +{ + wxClientDC dc(GetShape()->GetCanvas()); + GetShape()->GetCanvas()->PrepareDC(dc); + + GetShape()->FormatText(dc, (char*) (const char*) label); +} + +/* + * Diagram + */ + +bool MyDiagram::OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr) +{ + wxDiagram::OnShapeSave(db, shape, expr); + MyEvtHandler *handler = (MyEvtHandler *)shape.GetEventHandler(); + expr.AddAttributeValueString("label", handler->label); + return TRUE; +} + +bool MyDiagram::OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr) +{ + wxDiagram::OnShapeLoad(db, shape, expr); + char *label = NULL; + expr.AssignAttributeValue("label", &label); + MyEvtHandler *handler = new MyEvtHandler(&shape, &shape, wxString(label)); + shape.SetEventHandler(handler); + + if (label) + delete[] label; + return TRUE; +} + +/* + * New shapes + */ + +IMPLEMENT_DYNAMIC_CLASS(wxRoundedRectangleShape, wxRectangleShape) + +wxRoundedRectangleShape::wxRoundedRectangleShape(float w, float h): + wxRectangleShape(w, h) +{ + // 0.3 of the smaller rectangle dimension + SetCornerRadius((float) -0.3); +} + +IMPLEMENT_DYNAMIC_CLASS(wxDiamondShape, wxPolygonShape) + +wxDiamondShape::wxDiamondShape(float w, float h): + wxPolygonShape() +{ + // wxPolygonShape::SetSize relies on the shape having non-zero + // size initially. + if (w == 0.0) + w = 60.0; + if (h == 0.0) + h = 60.0; + + wxList *thePoints = new wxList; + wxRealPoint *point = new wxRealPoint(0.0, (-h/2.0)); + thePoints->Append((wxObject*) point); + + point = new wxRealPoint((w/2.0), 0.0); + thePoints->Append((wxObject*) point); + + point = new wxRealPoint(0.0, (h/2.0)); + thePoints->Append((wxObject*) point); + + point = new wxRealPoint((-w/2.0), 0.0); + thePoints->Append((wxObject*) point); + + Create(thePoints); +} diff --git a/utils/ogl/samples/ogledit/doc.h b/utils/ogl/samples/ogledit/doc.h new file mode 100644 index 0000000000..63f2678183 --- /dev/null +++ b/utils/ogl/samples/ogledit/doc.h @@ -0,0 +1,172 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: doc.h +// Purpose: Document classes +// Author: Julian Smart +// Modified by: +// Created: 12/07/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _OGLSAMPLE_DOC_H_ +#define _OGLSAMPLE_DOC_H_ + +#ifdef __GNUG__ +// #pragma interface +#endif + +#include +#include +#include + +#include "ogl.h" + +/* + * Override a few members for this application + */ + +class MyDiagram: public wxDiagram +{ + public: + MyDiagram(void) {} + bool OnShapeSave(wxExprDatabase& db, wxShape& shape, wxExpr& expr); + bool OnShapeLoad(wxExprDatabase& db, wxShape& shape, wxExpr& expr); +}; + +/* + * A few new shape classes so we have a 1:1 mapping + * between palette symbol and unique class + */ + +class wxRoundedRectangleShape: public wxRectangleShape +{ + DECLARE_DYNAMIC_CLASS(wxRoundedRectangleShape) + private: + public: + wxRoundedRectangleShape(float w = 0.0, float h = 0.0); +}; + +class wxDiamondShape: public wxPolygonShape +{ + DECLARE_DYNAMIC_CLASS(wxDiamondShape) + private: + public: + wxDiamondShape(float w = 0.0, float h = 0.0); +}; + +/* + * All shape event behaviour is routed through this handler, so we don't + * have to derive from each shape class. We plug this in to each shape. + */ + +class MyEvtHandler: public wxShapeEvtHandler +{ + public: + wxString label; + MyEvtHandler(wxShapeEvtHandler *prev = NULL, wxShape *shape = NULL, const wxString& lab = ""):wxShapeEvtHandler(prev, shape) + { + label = lab; + } + ~MyEvtHandler(void) + { + } + void OnLeftClick(float x, float y, int keys = 0, int attachment = 0); + void OnBeginDragRight(float x, float y, int keys = 0, int attachment = 0); + void OnDragRight(bool draw, float x, float y, int keys = 0, int attachment = 0); + void OnEndDragRight(float x, float y, int keys = 0, int attachment = 0); + void OnEndSize(float x, float y); +}; + +/* + * A diagram document, which contains a diagram. + */ + +class DiagramDocument: public wxDocument +{ + DECLARE_DYNAMIC_CLASS(DiagramDocument) + private: + public: + MyDiagram diagram; + + DiagramDocument(void); + ~DiagramDocument(void); + + ostream& SaveObject(ostream& stream); + istream& LoadObject(istream& stream); + + inline wxDiagram *GetDiagram() { return &diagram; } + + bool OnCloseDocument(void); +}; + +/* + * Most user interface commands are routed through this, to give us the + * Undo/Redo mechanism. If you add more commands, such as changing the shape colour, + * you will need to add members to 'remember' what the user applied (for 'Do') and what the + * previous state was (for 'Undo'). + * You can have one member for each property to be changed. Assume we also have + * a pointer member wxShape *shape, which is set to the shape being changed. + * Let's assume we're changing the shape colour. Our member for this is shapeColour. + * + * - In 'Do': + * o Set a temporary variable 'temp' to the current colour for 'shape'. + * o Change the colour to the new colour. + * o Set shapeColour to the _old_ colour, 'temp'. + * - In 'Undo': + * o Set a temporary variable 'temp' to the current colour for 'shape'. + * o Change the colour to shapeColour (the old colour). + * o Set shapeColour to 'temp'. + * + * So, as long as we have a pointer to the shape being changed, + * we only need one member variable for each property. + * + * PROBLEM: when an Add shape command is redone, the 'shape' pointer changes. + * Assume, as here, that we keep a pointer to the old shape so we reuse it + * when we recreate. + */ + +class DiagramCommand: public wxCommand +{ + protected: + DiagramDocument *doc; + int cmd; + wxShape *shape; // Pointer to the shape we're acting on + wxShape *fromShape; + wxShape *toShape; + wxClassInfo *shapeInfo; + float x; + float y; + bool selected; + bool deleteShape; + + // Storage for property commands + wxBrush *shapeBrush; + wxPen *shapePen; + wxString shapeLabel; + public: + // Multi-purpose constructor for creating, deleting shapes + DiagramCommand(char *name, int cmd, DiagramDocument *ddoc, wxClassInfo *shapeInfo = NULL, + float x = 0.0, float y = 0.0, bool sel = FALSE, wxShape *theShape = NULL, wxShape *fs = NULL, wxShape *ts = NULL); + + // Property-changing command constructors + DiagramCommand(char *name, int cmd, DiagramDocument *ddoc, wxBrush *backgroundColour, wxShape *theShape); + DiagramCommand(char *name, int cmd, DiagramDocument *ddoc, const wxString& lab, wxShape *theShape); + + ~DiagramCommand(void); + + bool Do(void); + bool Undo(void); + + inline void SetShape(wxShape *s) { shape = s; } + inline wxShape *GetShape(void) { return shape; } + inline wxShape *GetFromShape(void) { return fromShape; } + inline wxShape *GetToShape(void) { return toShape; } + inline wxClassInfo *GetShapeInfo(void) { return shapeInfo; } + inline bool GetSelected(void) { return selected; } + + void RemoveLines(wxShape *shape); +}; + +#endif + // _OGLSAMPLE_DOC_H_ diff --git a/utils/ogl/samples/ogledit/makefile.b32 b/utils/ogl/samples/ogledit/makefile.b32 new file mode 100644 index 0000000000..ffe204cf46 --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.b32 @@ -0,0 +1,88 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1996 +# Updated: +# Copyright: (c) 1996 +# +# "%W% %G%" +# +# Makefile : Builds OGL example for BC++, 32-bit. + +!if "$(BCCDIR)" == "" +!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4 +!endif + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +!ifndef FINAL +FINAL=0 +!endif + +WXDIR = $(WXWIN) +!include $(WXDIR)\src\makeb32.env + +THISDIR = $(WXDIR)\utils\ogl\samples\ogledit + +OGLDIR = ..\.. # $(WXDIR)\utils\ogl # Command line too long! +OGLINC = $(OGLDIR)\src +OGLLIB = $(WXDIR)\lib\ogl.lib + +WXLIB = $(WXDIR)\lib\wx32.lib +LIBS=$(WXLIB) $(OGLLIB) cw32 import32 +INC=/I$(OGLINC) +CFG=$(WXDIR)\src\wxwin32.cfg + +!if "$(FINAL)" == "0" +LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +OPT = -Od +DEBUG_FLAGS= -v -DDEBUG=$(DEBUG) +!else +LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +OPT = -O2 +DEBUG_FLAGS = -DDEBUG=$(DEBUG) +!endif + +CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) + +OBJECTS = ogledit.obj doc.obj view.obj palette.obj + +all: ogl ogledit.exe + +ogl: + cd $(OGLDIR)\src + make -f makefile.b32 + cd $(THISDIR) + +ogledit.exe: $(WXLIB) $(OBJECTS) ogledit.def ogledit.res + tlink32 $(LINKFLAGS) @&&! +c0w32.obj $(OBJECTS) +ogledit +nul +$(LIBS) +ogledit.def +! + brc32 -K ogledit.res + +.$(SRCSUFF).obj: + bcc32 $(CPPFLAGS) $(INC) -c {$< } + +ogledit.obj: ogledit.$(SRCSUFF) + +doc.obj: doc.$(SRCSUFF) + +view.obj: view.$(SRCSUFF) + +palette.obj: palette.$(SRCSUFF) + +ogledit.res : ogledit.rc $(WXDIR)\include\msw\wx.rc + brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa ogledit + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.rws diff --git a/utils/ogl/samples/ogledit/makefile.bcc b/utils/ogl/samples/ogledit/makefile.bcc new file mode 100644 index 0000000000..0b94f0ab24 --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.bcc @@ -0,0 +1,87 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1996 +# Updated: +# Copyright: (c) 1996 +# +# "%W% %G%" +# +# Makefile : Builds OGL example for BC++, 16-bit. + +!if "$(BCCDIR)" == "" +!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4 +!endif + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +!ifndef FINAL +FINAL=0 +!endif + +WXDIR = $(WXWIN) +!include $(WXDIR)\src\makebcc.env + +THISDIR = $(WXDIR)\utils\ogl\samples\ogledit + +OGLDIR = $(WXDIR)\utils\ogl +OGLINC = $(OGLDIR)\src +OGLLIB = $(OGLDIR)\lib\ogl.lib + +WXLIB = $(WXDIR)\lib\wx.lib +LIBS=$(WXLIB) $(OGLLIB) mathwl cwl import +INC=/I$(OGLINC) +CFG=$(WXDIR)\src\wxwin.cfg + +!if "$(FINAL)" == "0" +LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib +OPT = -Od +DEBUG_FLAGS= -v +!else +LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib +OPT = -O2 +DEBUG_FLAGS = +!endif +CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) + +OBJECTS = ogledit.obj doc.obj view.obj palette.obj + +all: ogl ogledit.exe + +ogl: + cd $(OGLDIR)\src + make -f makefile.bcc + cd $(THISDIR) + +ogledit.exe: $(WXLIB) $(OBJECTS) ogledit.def ogledit.res + tlink $(LINKFLAGS) @&&! +c0wl.obj $(OBJECTS) +ogledit +nul +$(LIBS) +ogledit.def +! + rc -30 -K ogledit.res + +.$(SRCSUFF).obj: + bcc $(CPPFLAGS) $(INC) -c {$< } + +ogledit.obj: ogledit.$(SRCSUFF) + +doc.obj: doc.$(SRCSUFF) + +view.obj: view.$(SRCSUFF) + +palette.obj: palette.$(SRCSUFF) + +ogledit.res : ogledit.rc $(WXDIR)\include\wx\msw\wx.rc + rc -r /i$(BCCDIR)\include /i$(WXDIR)\include ogledit + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.rws diff --git a/utils/ogl/samples/ogledit/makefile.dos b/utils/ogl/samples/ogledit/makefile.dos new file mode 100644 index 0000000000..34eb326437 --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.dos @@ -0,0 +1,103 @@ +# +# File: makefile.dos +# Author: Julian Smart +# Created: 1995 +# Updated: +# Copyright: (c) 1995, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds OGLEdit example (MSVC++ 1.5). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +WXDIR = $(WXWIN) + +!include $(WXDIR)\src\makemsc.env + +THISDIR = $(WXDIR)\utils\ogl\samples\ogledit +WXLIB = $(WXDIR)\lib\wx.lib + +OGLDIR = $(WXDIR)\utils\ogl +OGLINC = $(OGLDIR)\src +OGLLIB = $(OGLDIR)\lib\ogl.lib + +LIBS=$(WXLIB) $(OGLLIB) oldnames libw llibcew commdlg shell ddeml + +EXTRAFLAGS=/I$(OGLINC) + +OBJECTS = ogledit.obj doc.obj view.obj palette.obj + +all: ogledit.exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.dos + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.dos clean + cd $(THISDIR) + +ogl: + cd $(OGLDIR)\src + nmake -f makefile.dos FINAL=$(FINAL) + cd $(THISDIR) + +prologio: + cd $(PROLOGDIR)\src + nmake -f makefile.dos FINAL=$(FINAL) + cd $(THISDIR) + +ogledit.exe: $(WXDIR)\src\msw\dummy.obj $(WXLIB) $(OBJECTS) $(OGLLIB) ogledit.def ogledit.res + link $(LINKFLAGS) @<< +$(WXDIR)\src\msw\dummy.obj $(OBJECTS), +ogledit, +NUL, +$(LIBS), +ogledit.def +; +<< + rc -30 -K ogledit.res + +ogledit.obj: ogledit.h ogledit.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +view.obj: view.h view.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +doc.obj: doc.h doc.$(SRCSUFF) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +palette.obj: view.h doc.h ogledit.h palette.$(SRCSUFF) $(DUMMYOBJ) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +ogledit.res : ogledit.rc $(WXDIR)\include\msw\wx.rc + rc -r /dFAFA_LIB /i$(WXDIR)\contrib\fafa /i$(WXDIR)\include\msw ogledit + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase *.map + -erase *.sbr + -erase *.pdb + +cleanogl: + cd $(OGLDIR)\src + nmake -f makefile.dos clean + cd $(THISDIR) + +cleanall: + cd $(OGLDIR)\src + nmake -f makefile.dos clean + cd $(THISDIR) \ No newline at end of file diff --git a/utils/ogl/samples/ogledit/makefile.nt b/utils/ogl/samples/ogledit/makefile.nt new file mode 100644 index 0000000000..f49a7ed70b --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.nt @@ -0,0 +1,95 @@ +# +# File: makefile.nt +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds docview example (MS VC++). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +!include $(WXDIR)\src\ntwxwin.mak + +THISDIR = $(WXDIR)\utils\ogl\samples\ogledit + +OGLDIR = $(WXDIR)\utils\ogl +OGLINC = $(OGLDIR)\src +OGLLIB = $(WXDIR)\lib\ogl.lib + +PROGRAM=ogledit + +EXTRALIBS=$(OGLLIB) +EXTRAINC=/I$(OGLINC) + +OBJECTS = $(PROGRAM).obj doc.obj view.obj palette.obj + +$(PROGRAM): $(PROGRAM).exe + +all: $(PROGRAM).exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.nt FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.nt clean + cd $(THISDIR) + +ogl: + cd $(OGLDIR)\src + nmake -f makefile.nt FINAL=$(FINAL) + cd $(THISDIR) + +$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(OBJECTS) $(OGLLIB) $(PROGRAM).res + $(link) @<< +-out:$(PROGRAM).exe +$(LINKFLAGS) +$(DUMMYOBJ) $(OBJECTS) $(PROGRAM).res +$(LIBS) +<< + +$(PROGRAM).obj: $(PROGRAM).h doc.h view.h palette.h $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +doc.obj: view.h doc.h doc.$(SRCSUFF) ogledit.h $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +view.obj: view.h doc.h view.$(SRCSUFF) ogledit.h $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +palette.obj: view.h doc.h ogledit.h palette.$(SRCSUFF) $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc ogl.ico + $(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc + + +cleanogl: + cd $(OGLDIR)\src + nmake -f makefile.nt clean + cd $(THISDIR) + +clean: + -erase *.obj + -erase *.sbr + -erase *.exe + -erase *.res + -erase *.map + -erase *.pdb + diff --git a/utils/ogl/samples/ogledit/makefile.sc b/utils/ogl/samples/ogledit/makefile.sc new file mode 100644 index 0000000000..03da92bcd0 --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.sc @@ -0,0 +1,33 @@ +# Symantec C++ makefile for docview example +# NOTE that peripheral libraries are now dealt in main wxWindows makefile. + +WXDIR = $(WXWIN) +include $(WXDIR)\src\makesc.env + +WXLIB = $(WXDIR)\lib\wx.lib +INCDIR = $(WXDIR)\include +MSWINC = $(INCDIR)\msw +BASEINC = $(INCDIR)\base + +INCLUDE=$(BASEINC);$(MSWINC) + +LIBS=$(WXLIB) libw.lib commdlg.lib shell.lib + +OBJECTS=docview.obj view.obj doc.obj + +.$(SRCSUFF).obj: + *$(CC) -c $(CFLAGS) -I$(INCLUDE) $< + +.rc.res: + *$(RC) -r -I$(INCLUDE) $< + +docview.exe: $(OBJECTS) docview.def docview.res + *$(CC) $(LDFLAGS) -o$@ $(OBJECTS) docview.def $(LIBS) + *$(RC) -k docview.res + +clean: + -del *.obj + -del *.exe + -del *.res + -del *.map + -del *.rws diff --git a/utils/ogl/samples/ogledit/makefile.unx b/utils/ogl/samples/ogledit/makefile.unx new file mode 100644 index 0000000000..a813dbceb0 --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.unx @@ -0,0 +1,79 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile for docview example (UNIX). + +WXDIR = ../../../.. + +# All common UNIX compiler flags and options are now in +# this central makefile. +include $(WXDIR)/src/make.env + +OGLDIR = $(WXDIR)/utils/ogl +OGLINC = $(OGLDIR)/src +OGLLIB = $(OGLDIR)/lib/libogl$(GUISUFFIX).a + +OBJECTS = $(OBJDIR)/ogledit.$(OBJSUFF) $(OBJDIR)/view.$(OBJSUFF) $(OBJDIR)/doc.$(OBJSUFF) $(OBJDIR)/palette.$(OBJSUFF) + +LDFLAGS = $(XLIB) -L$(WXDIR)/lib -L$(OGLDIR)/lib -L$(MFDIR)/lib + +XVIEWLDLIBS = -logl_ol -lwx_ol -lxview -lolgx -lX11 -lm $(COMPLIBS) +MOTIFLDLIBS = -logl_motif -lwx_motif -lXm -lXt -lX11 -lm $(COMPLIBS) +HPLDLIBS = -logl_motif -lwx_hp -lXm -lXt -lX11 -lm $(COMPLIBS) + +CPPFLAGS = -I$(OGLINC) -I$(PROLOGINC) -I$(MFINC) $(XINCLUDE) $(INC) $(GUI) -DDEBUG='$(DEBUG)' $(DEBUGFLAGS) $(WARN) $(OPTIONS) -DPROLOGIO + +.SUFFIXES: + +all: $(OBJDIR) ogledit$(GUISUFFIX) + +wx_motif: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx motif + +wx_ol: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview +motif: + $(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' XVIEW_LINK= + +xview: + $(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol CC=$(CC) OPTIONS='$(OPTIONS)' DEBUG='$(DEBUG)' WARN='$(WARN)' XLIB='$(XLIB)' XINCLUDE='$(XINCLUDE)' + +hp: + $(MAKE) -f makefile,unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='' WARN='-w' \ + XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' LDLIBS='$(HPLDLIBS)' + +$(OBJDIR): + mkdir $(OBJDIR) + +ogledit$(GUISUFFIX): $(OBJECTS) $(WXLIB) + $(CC) $(LDFLAGS) -o ogledit$(GUISUFFIX) $(OBJECTS) $(XVIEW_LINK) $(LDLIBS) + +$(OBJDIR)/ogledit.$(OBJSUFF): ogledit.$(SRCSUFF) ogledit.h doc.h view.h palette.h + $(CC) -c $(CPPFLAGS) -o $@ ogledit.$(SRCSUFF) + +$(OBJDIR)/doc.$(OBJSUFF): doc.$(SRCSUFF) doc.h + $(CC) -c $(CPPFLAGS) -o $@ doc.$(SRCSUFF) + +$(OBJDIR)/view.$(OBJSUFF): view.$(SRCSUFF) view.h + $(CC) -c $(CPPFLAGS) -o $@ view.$(SRCSUFF) + +$(OBJDIR)/palette.$(OBJSUFF): palette.$(SRCSUFF) palette.h + $(CC) -c $(CPPFLAGS) -o $@ palette.$(SRCSUFF) + +clean_motif: + $(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany + +clean_ol: + $(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany + +clean_hp: + $(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany + +cleanany: + rm -f $(OBJECTS) ogledit(GUISUFFIX) core diff --git a/utils/ogl/samples/ogledit/makefile.vms b/utils/ogl/samples/ogledit/makefile.vms new file mode 100644 index 0000000000..1a64fc7f30 --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.vms @@ -0,0 +1,44 @@ +#************************************************************************ +# Makefile for DOCVIEW under VMS +# by Stefan Hammes +# (incomplete) update history: +# 09.06.95 +#************************************************************************ + +#************************************************************************ +# Definition section +# (cave: definitions and includes must begin with ',') +#************************************************************************ + +APPOPTS = +APPDEFS = +APPINCS = + +#************************************************************************ +# Module section +#************************************************************************ + +# Name of main module +MAIN = docview + +# Object modules of the application. +OBJS = docview.obj view.obj doc.obj +OBJLIST =docview.obj,view.obj,doc.obj + +.include [--.src]makevms.env + +# main dependency +$(MAIN).exe : $(OBJS) + $(LINK) $(LINKFLAGS) /exec=$(MAIN).exe $(OBJLIST),$(WXLIB)/lib,$(OPTSFILE)/option + - purge *.exe + +#************************************************************************ +# Header file depedencies following +#************************************************************************ + +docview.$(OBJSUFF) : docview.$(SRCSUFF) docview.h doc.h view.h + +doc.$(OBJSUFF) : doc.$(SRCSUFF) doc.h + +view.$(OBJSUFF) : view.$(SRCSUFF) view.h + diff --git a/utils/ogl/samples/ogledit/makefile.wat b/utils/ogl/samples/ogledit/makefile.wat new file mode 100644 index 0000000000..bafa16f3a5 --- /dev/null +++ b/utils/ogl/samples/ogledit/makefile.wat @@ -0,0 +1,43 @@ +# +# Makefile for WATCOM +# +# Created by D.Chubraev, chubraev@iem.ee.ethz.ch +# 8 Nov 1994 +# + +WXDIR = ..\.. + +!include $(WXDIR)\src\makewat.env + +WXLIB = $(WXDIR)\lib +NAME = docview +LNK = $(name).lnk +OBJS = $(name).obj doc.obj view.obj + +all: $(name).exe + +$(name).exe : $(OBJS) $(name).res $(LNK) $(WXLIB)\wx$(LEVEL).lib + wlink @$(LNK) + $(BINDCOMMAND) $(name).res + +$(name).res : $(name).rc $(WXDIR)\include\msw\wx.rc + $(RC) $(RESFLAGS1) $(name).rc + +$(LNK) : makefile.wat + %create $(LNK) + @%append $(LNK) debug all + @%append $(LNK) system $(LINKOPTION) + @%append $(LNK) $(MINDATA) + @%append $(LNK) $(MAXDATA) + @%append $(LNK) $(STACK) + @%append $(LNK) name $(name) + @%append $(LNK) file $(WXLIB)\wx$(LEVEL).lib + @for %i in ($(EXTRALIBS)) do @%append $(LNK) file %i + @for %i in ($(OBJS)) do @%append $(LNK) file %i + +thing: .SYMBOLIC + echo $(WATLIBDIR) + +clean: .SYMBOLIC + -erase *.obj *.bak *.err *.pch *.lib *.lnk *.res *.exe *.rex + diff --git a/utils/ogl/samples/ogledit/ogl.ico b/utils/ogl/samples/ogledit/ogl.ico new file mode 100644 index 0000000000000000000000000000000000000000..7cb092e04ca745bdd3cc3b856ef367d67440d9b6 GIT binary patch literal 766 zcmc&wu@S;B3{*H*6oiU8C1a$}U|EBX+EaKGN~)YT5dXsA62iezaJ((a@0VrSA`M2@ z?S;5*L=K2YSO@E2jU;#g+G`9Vm@*9a0FR}VQV=P4OmXK5hQTfJ?_p0zQX3l<1>H@1 za@*z{)srd{Ky${zR3l;HkX7L*=X1zNcyJHBb*uX7JQL>iSNHqWpVr4ld+12nCh*gU pUjfiy4R#{%p4~W(7sSd*u~B)__q_F`KC3s~$BX$d9}ww(bT>1!mTdq4 literal 0 HcmV?d00001 diff --git a/utils/ogl/samples/ogledit/ogledit.cpp b/utils/ogl/samples/ogledit/ogledit.cpp new file mode 100644 index 0000000000..cc18d2d2c1 --- /dev/null +++ b/utils/ogl/samples/ogledit/ogledit.cpp @@ -0,0 +1,211 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: ogledit.cpp +// Purpose: OGLEdit sample app +// Author: Julian Smart +// Modified by: +// Created: 12/07/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// #pragma implementation +#endif + +// For compilers that support precompilation, includes "wx.h". +#include + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include +#endif + +#if !USE_DOC_VIEW_ARCHITECTURE +#error You must set USE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h! +#endif + +#include "ogledit.h" +#include "palette.h" +#include "doc.h" +#include "view.h" + +// A macro needed for some compilers (AIX) that need 'main' to be defined +// in the application itself. +IMPLEMENT_APP(MyApp) + +// This statement initialises the whole application +MyApp myApp; + +MyApp::MyApp(void) +{ + frame = NULL; +} + +// The `main program' equivalent, creating the windows and returning the +// main frame +bool MyApp::OnInit(void) +{ + wxOGLInitialize(); + + //// Create a document manager + wxDocManager *myDocManager = new wxDocManager; + + //// Create a template relating drawing documents to their views + (void) new wxDocTemplate(myDocManager, "Diagram", "*.dia", "", "dia", "Diagram Doc", "Diagram View", + CLASSINFO(DiagramDocument), CLASSINFO(DiagramView)); + + // If we've only got one window, we only get to edit + // one document at a time. + myDocManager->SetMaxDocsOpen(1); + + //// Create the main frame window + frame = new MyFrame(myDocManager, NULL, "OGLEdit Demo", wxPoint(0, 0), wxSize(500, 400), wxDEFAULT_FRAME_STYLE); + + //// Give it an icon +#ifdef __WXMSW__ + frame->SetIcon(wxIcon("ogl_icn")); +#endif +#ifdef __X__ + frame->SetIcon(wxIcon("ogl.xbm")); +#endif + + //// Make a menubar + wxMenu *file_menu = new wxMenu; + wxMenu *edit_menu = NULL; + + file_menu->Append(wxID_NEW, "&New..."); + file_menu->Append(wxID_OPEN, "&Open..."); + + file_menu->Append(wxID_CLOSE, "&Close"); + file_menu->Append(wxID_SAVE, "&Save"); + file_menu->Append(wxID_SAVEAS, "Save &As..."); + file_menu->AppendSeparator(); + file_menu->Append(wxID_PRINT, "&Print..."); + file_menu->Append(wxID_PRINT_SETUP, "Print &Setup..."); + file_menu->Append(wxID_PREVIEW, "Print Pre&view"); + + edit_menu = new wxMenu; + edit_menu->Append(wxID_UNDO, "&Undo"); + edit_menu->Append(wxID_REDO, "&Redo"); + edit_menu->AppendSeparator(); + edit_menu->Append(OGLEDIT_CUT, "&Cut"); + edit_menu->AppendSeparator(); + edit_menu->Append(OGLEDIT_CHANGE_BACKGROUND_COLOUR, "Change &background colour"); + edit_menu->Append(OGLEDIT_EDIT_LABEL, "Edit &label"); + + frame->editMenu = edit_menu; + + file_menu->AppendSeparator(); + file_menu->Append(wxID_EXIT, "E&xit"); + + // A nice touch: a history of files visited. Use this menu. + myDocManager->FileHistoryUseMenu(file_menu); + + wxMenu *help_menu = new wxMenu; + help_menu->Append(OGLEDIT_ABOUT, "&About"); + + wxMenuBar *menu_bar = new wxMenuBar; + + menu_bar->Append(file_menu, "&File"); + if (edit_menu) + menu_bar->Append(edit_menu, "&Edit"); + menu_bar->Append(help_menu, "&Help"); + + frame->canvas = frame->CreateCanvas(NULL, frame); + frame->palette = myApp.CreatePalette(frame); + myDocManager->CreateDocument("", wxDOC_NEW); + + //// Associate the menu bar with the frame + frame->SetMenuBar(menu_bar); + + frame->CreateStatusBar(1); + + frame->Centre(wxBOTH); + frame->Show(TRUE); + + return TRUE; +} + +/* + * This is the top-level window of the application. + */ + +IMPLEMENT_CLASS(MyFrame, wxDocParentFrame) + +BEGIN_EVENT_TABLE(MyFrame, wxDocParentFrame) + EVT_MENU(OGLEDIT_ABOUT, MyFrame::OnAbout) + EVT_SIZE(MyFrame::OnSize) +END_EVENT_TABLE() + +MyFrame::MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, + const wxPoint& pos, const wxSize& size, long type): + wxDocParentFrame(manager, frame, -1, title, pos, size, type) +{ + canvas = NULL; + palette = NULL; + editMenu = NULL; +} + +void MyFrame::OnSize(wxSizeEvent& event) +{ + if (canvas && palette) + { + int cw, ch; + GetClientSize(&cw, &ch); + int paletteX = 0; + int paletteY = 0; + int paletteW = 30; + int paletteH = ch; + int canvasX = paletteX + paletteW; + int canvasY = 0; + int canvasW = cw - paletteW; + int canvasH = ch; + + palette->SetSize(paletteX, paletteY, paletteW, paletteH); + canvas->SetSize(canvasX, canvasY, canvasW, canvasH); + } +} + +bool MyFrame::OnClose(void) +{ + if (wxDocParentFrame::OnClose()) + { + wxOGLCleanUp(); + return TRUE; + } + else + return FALSE; +} + +// Intercept menu commands +void MyFrame::OnAbout(wxCommandEvent& event) +{ + (void)wxMessageBox("OGLEdit Demo\nTo draw a shape, select a shape on the toolbar and left-click on the canvas.\nTo draw a line, right-drag between shapes.\nFor further details, see the OGL manual.\n (c) Julian Smart 1996", "About OGLEdit"); +} + +// Creates a canvas. Called by OnInit as a child of the main window +MyCanvas *MyFrame::CreateCanvas(wxView *view, wxFrame *parent) +{ + int width, height; + parent->GetClientSize(&width, &height); + + // Non-retained canvas + MyCanvas *canvas = new MyCanvas(view, parent, -1, wxPoint(0, 0), wxSize(width, height), 0); + wxCursor *cursor = new wxCursor(wxCURSOR_HAND); + canvas->SetCursor(cursor); + + // Give it scrollbars + canvas->SetScrollbars(20, 20, 50, 50); + + return canvas; +} + +MyFrame *GetMainFrame(void) +{ + return myApp.frame; +} + diff --git a/utils/ogl/samples/ogledit/ogledit.def b/utils/ogl/samples/ogledit/ogledit.def new file mode 100644 index 0000000000..d587ce5556 --- /dev/null +++ b/utils/ogl/samples/ogledit/ogledit.def @@ -0,0 +1,8 @@ +NAME OGLEdit +DESCRIPTION 'OGL Editor Sample' +EXETYPE WINDOWS +STUB 'WINSTUB.EXE' +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE +HEAPSIZE 1024 +STACKSIZE 8192 diff --git a/utils/ogl/samples/ogledit/ogledit.h b/utils/ogl/samples/ogledit/ogledit.h new file mode 100644 index 0000000000..c44195b6a7 --- /dev/null +++ b/utils/ogl/samples/ogledit/ogledit.h @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: ogledit.h +// Purpose: OGL sample +// Author: Julian Smart +// Modified by: +// Created: 12/07/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// #pragma interface +#endif + +#ifndef _OGLSAMPLE_OGLEDIT_H_ +#define _OGLSAMPLE_OGLEDIT_H_ + +#include + +// Define a new application +class MyFrame; +class EditorToolPalette; +class MyApp: public wxApp +{ + public: + MyFrame *frame; + + MyApp(void); + bool OnInit(void); + + // Palette stuff + EditorToolPalette *CreatePalette(wxFrame *parent); +}; + +DECLARE_APP(MyApp) + +// Define a new frame +class MyCanvas; +class MyFrame: public wxDocParentFrame +{ + DECLARE_CLASS(MyFrame) + public: + wxMenu *editMenu; + + MyCanvas *canvas; + EditorToolPalette *palette; + + MyFrame(wxDocManager *manager, wxFrame *parent, const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE); + + MyCanvas *CreateCanvas(wxView *view, wxFrame *parent); + void OnSize(wxSizeEvent& event); + bool OnClose(void); + void OnAbout(wxCommandEvent& event); + +DECLARE_EVENT_TABLE() +}; + +extern MyFrame *GetMainFrame(void); + +// Menu/undo/redo commands + +#define OGLEDIT_CUT 1 +#define OGLEDIT_ADD_SHAPE 2 +#define OGLEDIT_ADD_LINE 3 +#define OGLEDIT_EDIT_LABEL 4 +#define OGLEDIT_CHANGE_BACKGROUND_COLOUR 5 + +#define OGLEDIT_ABOUT 100 + +#endif + // _OGLSAMPLE_OGLEDIT_H_ diff --git a/utils/ogl/samples/ogledit/ogledit.rc b/utils/ogl/samples/ogledit/ogledit.rc new file mode 100644 index 0000000000..fc2d538d65 --- /dev/null +++ b/utils/ogl/samples/ogledit/ogledit.rc @@ -0,0 +1,10 @@ +ogl_icn ICON ogl.ico + +TOOL1 BITMAP "bitmaps/tool1.bmp" +TOOL2 BITMAP "bitmaps/tool2.bmp" +TOOL3 BITMAP "bitmaps/tool3.bmp" +TOOL4 BITMAP "bitmaps/tool4.bmp" +ARROWTOOL BITMAP "bitmaps/arrow.bmp" + +#include "wx/msw/wx.rc" + diff --git a/utils/ogl/samples/ogledit/palette.cpp b/utils/ogl/samples/ogledit/palette.cpp new file mode 100644 index 0000000000..255f0decbc --- /dev/null +++ b/utils/ogl/samples/ogledit/palette.cpp @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: palette.cpp +// Purpose: OGLEdit palette +// Author: Julian Smart +// Modified by: +// Created: 12/07/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// #pragma implementation +#endif + +// For compilers that support precompilation, includes "wx.h". +#include + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include +#endif + +#include + +#include +#include +#include + +#include "doc.h" +#include "view.h" +#include "ogledit.h" +#include "palette.h" + +/* + * Object editor tool palette + * + */ + +EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size, + long style): + TOOLPALETTECLASS(parent, -1, pos, size, style) +{ + currentlySelected = -1; + + SetMaxRowsCols(1000, 1); +} + +bool EditorToolPalette::OnLeftClick(int toolIndex, bool toggled) +{ + // BEGIN mutual exclusivity code + if (toggled && (currentlySelected != -1) && (toolIndex != currentlySelected)) + ToggleTool(currentlySelected, FALSE); + + if (toggled) + currentlySelected = toolIndex; + else if (currentlySelected == toolIndex) + currentlySelected = -1; + // END mutual exclusivity code + + return TRUE; +} + +void EditorToolPalette::OnMouseEnter(int toolIndex) +{ +} + +void EditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags) +{ + TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags); +} + +EditorToolPalette *MyApp::CreatePalette(wxFrame *parent) +{ + // Load palette bitmaps +#ifdef __WXMSW__ + wxBitmap PaletteTool1("TOOL1"); + wxBitmap PaletteTool2("TOOL2"); + wxBitmap PaletteTool3("TOOL3"); + wxBitmap PaletteTool4("TOOL4"); + wxBitmap PaletteArrow("ARROWTOOL"); +#endif +#ifdef __X__ + wxBitmap PaletteTool1(tool1_bits, tool1_width, tool1_height); + wxBitmap PaletteTool2(tool2_bits, tool2_width, tool2_height); + wxBitmap PaletteTool3(tool3_bits, tool3_width, tool3_height); + wxBitmap PaletteTool4(tool4_bits, tool4_width, tool4_height); + wxBitmap PaletteArrow(arrow_bits, arrow_width, arrow_height); +#endif + + EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL); + + palette->SetMargins(2, 2); + +#ifdef __WXMSW__ + if (palette->IsKindOf(CLASSINFO(wxToolBar95))) + ((wxToolBar95 *)palette)->SetToolBitmapSize(wxSize(22, 22)); +#endif + + palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, "Pointer"); + palette->AddTool(PALETTE_TOOL1, PaletteTool1, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 1"); + palette->AddTool(PALETTE_TOOL2, PaletteTool2, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 2"); + palette->AddTool(PALETTE_TOOL3, PaletteTool3, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 3"); + palette->AddTool(PALETTE_TOOL4, PaletteTool4, wxNullBitmap, TRUE, 0, -1, NULL, "Tool 4"); + + palette->Realize(); + + palette->ToggleTool(PALETTE_ARROW, TRUE); + palette->currentlySelected = PALETTE_ARROW; + return palette; +} + diff --git a/utils/ogl/samples/ogledit/palette.h b/utils/ogl/samples/ogledit/palette.h new file mode 100644 index 0000000000..6159266230 --- /dev/null +++ b/utils/ogl/samples/ogledit/palette.h @@ -0,0 +1,58 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: palette.h +// Purpose: OGL sample palette +// Author: Julian Smart +// Modified by: +// Created: 12/07/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _OGLSAMPLE_PALETTE_H_ +#define _OGLSAMPLE_PALETTE_H_ + +#ifdef __GNUG__ +// #pragma interface +#endif + +#include +#include +#include + +/* + * Object editor tool palette + * + */ + +// TODO for wxWin: wxToolBar95 cannot be moved to a non-0,0 position! +// Needs to have a parent window... +// So use a simple toolbar at present. +#define TOOLPALETTECLASS wxToolBarSimple + +class EditorToolPalette: public TOOLPALETTECLASS +{ + public: + int currentlySelected; + + EditorToolPalette(wxWindow *parent, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxTB_VERTICAL); + bool OnLeftClick(int toolIndex, bool toggled); + void OnMouseEnter(int toolIndex); + void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO); +}; + +#define PALETTE_TOOL1 1 +#define PALETTE_TOOL2 2 +#define PALETTE_TOOL3 3 +#define PALETTE_TOOL4 4 +#define PALETTE_TOOL5 5 +#define PALETTE_TOOL6 6 +#define PALETTE_TOOL7 7 +#define PALETTE_TOOL8 8 +#define PALETTE_TOOL9 9 +#define PALETTE_ARROW 10 + +#endif + // _OGLSAMPLE_PALETTE_H_ diff --git a/utils/ogl/samples/ogledit/view.cpp b/utils/ogl/samples/ogledit/view.cpp new file mode 100644 index 0000000000..485392c833 --- /dev/null +++ b/utils/ogl/samples/ogledit/view.cpp @@ -0,0 +1,264 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: view.cpp +// Purpose: Implements view functionality in OGLEdit +// Author: Julian Smart +// Modified by: +// Created: 12/07/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +// #pragma implementation +#endif + +// For compilers that support precompilation, includes "wx.h". +#include + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include +#endif + +#include + +#if !USE_DOC_VIEW_ARCHITECTURE +#error You must set USE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h! +#endif + +#include "ogledit.h" +#include "doc.h" +#include "view.h" +#include "palette.h" + +IMPLEMENT_DYNAMIC_CLASS(DiagramView, wxView) + +BEGIN_EVENT_TABLE(DiagramView, wxView) + EVT_MENU(OGLEDIT_CUT, DiagramView::OnCut) + EVT_MENU(OGLEDIT_CHANGE_BACKGROUND_COLOUR, DiagramView::OnChangeBackgroundColour) + EVT_MENU(OGLEDIT_EDIT_LABEL, DiagramView::OnEditLabel) +END_EVENT_TABLE() + +// What to do when a view is created. Creates actual +// windows for displaying the view. +bool DiagramView::OnCreate(wxDocument *doc, long flags) +{ + frame = GetMainFrame(); + canvas = GetMainFrame()->canvas; + canvas->view = this; + + SetFrame(frame); + Activate(TRUE); + + // Initialize the edit menu Undo and Redo items + doc->GetCommandProcessor()->SetEditMenu(((MyFrame *)frame)->editMenu); + doc->GetCommandProcessor()->Initialize(); + + wxShapeCanvas *shapeCanvas = (wxShapeCanvas *)canvas; + DiagramDocument *diagramDoc = (DiagramDocument *)doc; + shapeCanvas->SetDiagram(diagramDoc->GetDiagram()); + diagramDoc->GetDiagram()->SetCanvas(shapeCanvas); + + return TRUE; +} + +// Sneakily gets used for default print/preview +// as well as drawing on the screen. +void DiagramView::OnDraw(wxDC *dc) +{ +} + +void DiagramView::OnUpdate(wxView *sender, wxObject *hint) +{ + if (canvas) + canvas->Refresh(); +} + +// Clean up windows used for displaying the view. +bool DiagramView::OnClose(bool deleteWindow) +{ + if (!GetDocument()->Close()) + return FALSE; + + DiagramDocument *diagramDoc = (DiagramDocument *)GetDocument(); + diagramDoc->GetDiagram()->SetCanvas(NULL); + + canvas->Clear(); + canvas->SetDiagram(NULL); + canvas->view = NULL; + canvas = NULL; + + wxString s = wxTheApp->GetAppName(); + if (frame) + frame->SetTitle(s); + + SetFrame(NULL); + + Activate(FALSE); + + return TRUE; +} + +wxShape *DiagramView::FindSelectedShape(void) +{ + DiagramDocument *doc = (DiagramDocument *)GetDocument(); + wxShape *theShape = NULL; + wxNode *node = doc->GetDiagram()->GetShapeList()->First(); + while (node) + { + wxShape *eachShape = (wxShape *)node->Data(); + if ((eachShape->GetParent() == NULL) && eachShape->Selected()) + { + theShape = eachShape; + node = NULL; + } + else node = node->Next(); + } + return theShape; +} + +void DiagramView::OnCut(wxCommandEvent& event) +{ + DiagramDocument *doc = (DiagramDocument *)GetDocument(); + + wxShape *theShape = FindSelectedShape(); + if (theShape) + doc->GetCommandProcessor()->Submit(new DiagramCommand("Cut", OGLEDIT_CUT, doc, NULL, 0.0, 0.0, TRUE, theShape)); +} + +void DiagramView::OnChangeBackgroundColour(wxCommandEvent& event) +{ + DiagramDocument *doc = (DiagramDocument *)GetDocument(); + + wxShape *theShape = FindSelectedShape(); + if (theShape) + { + wxColourData data; + data.SetChooseFull(TRUE); + data.SetColour(theShape->GetBrush()->GetColour()); + + wxColourDialog *dialog = new wxColourDialog(frame, &data); + wxBrush *theBrush = NULL; + if (dialog->ShowModal() == wxID_OK) + { + wxColourData retData = dialog->GetColourData(); + wxColour col = retData.GetColour(); + theBrush = wxTheBrushList->FindOrCreateBrush(col, wxSOLID); + } + dialog->Close(); + + if (theBrush) + doc->GetCommandProcessor()->Submit(new DiagramCommand("Change colour", OGLEDIT_CHANGE_BACKGROUND_COLOUR, doc, + theBrush, theShape)); + } +} + +void DiagramView::OnEditLabel(wxCommandEvent& event) +{ + wxShape *theShape = FindSelectedShape(); + if (theShape) + { + wxString newLabel = wxGetTextFromUser("Enter new label", "Shape Label", ((MyEvtHandler *)theShape->GetEventHandler())->label); + GetDocument()->GetCommandProcessor()->Submit(new DiagramCommand("Edit label", OGLEDIT_EDIT_LABEL, (DiagramDocument*) GetDocument(), newLabel, theShape)); + } +} + +/* + * Window implementations + */ + +BEGIN_EVENT_TABLE(MyCanvas, wxShapeCanvas) + EVT_MOUSE_EVENTS(MyCanvas::OnMouseEvent) + EVT_PAINT(MyCanvas::OnPaint) +END_EVENT_TABLE() + +// Define a constructor for my canvas +MyCanvas::MyCanvas(wxView *v, wxWindow *parent, wxWindowID id, const wxPoint& pos, + const wxSize& size, long style): + wxShapeCanvas(parent, id, pos, size, style) +{ + view = v; +} + +MyCanvas::~MyCanvas(void) +{ +} + +void MyCanvas::OnLeftClick(float x, float y, int keys) +{ + EditorToolPalette *palette = wxGetApp().frame->palette; + wxClassInfo *info = NULL; + switch (palette->currentlySelected) + { + case PALETTE_TOOL1: + { + info = CLASSINFO(wxRectangleShape); + break; + } + case PALETTE_TOOL2: + { + info = CLASSINFO(wxRoundedRectangleShape); + break; + } + case PALETTE_TOOL3: + { + info = CLASSINFO(wxEllipseShape); + break; + } + case PALETTE_TOOL4: + { + info = CLASSINFO(wxDiamondShape); + break; + } + default: + break; + } + if (info) + { + view->GetDocument()->GetCommandProcessor()->Submit(new DiagramCommand(info->GetClassName(), OGLEDIT_ADD_SHAPE, (DiagramDocument *)view->GetDocument(), info, + x, y)); + } +} + +void MyCanvas::OnRightClick(float x, float y, int keys) +{ +} + +void MyCanvas::OnDragLeft(bool draw, float x, float y, int keys) +{ +} + +void MyCanvas::OnBeginDragLeft(float x, float y, int keys) +{ +} + +void MyCanvas::OnEndDragLeft(float x, float y, int keys) +{ +} + +void MyCanvas::OnDragRight(bool draw, float x, float y, int keys) +{ +} + +void MyCanvas::OnBeginDragRight(float x, float y, int keys) +{ +} + +void MyCanvas::OnEndDragRight(float x, float y, int keys) +{ +} + +void MyCanvas::OnMouseEvent(wxMouseEvent& event) +{ + wxShapeCanvas::OnMouseEvent(event); +} + +void MyCanvas::OnPaint(wxPaintEvent& event) +{ +// if (GetDiagram()) + wxShapeCanvas::OnPaint(event); +} diff --git a/utils/ogl/samples/ogledit/view.h b/utils/ogl/samples/ogledit/view.h new file mode 100644 index 0000000000..e49855bc6f --- /dev/null +++ b/utils/ogl/samples/ogledit/view.h @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: view.h +// Purpose: View-related classes +// Author: Julian Smart +// Modified by: +// Created: 12/07/98 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _OGLSAMPLE_VIEW_H_ +#define _OGLSAMPLE_VIEW_H_ + +#ifdef __GNUG__ +// #pragma interface "view.h" +#endif + +#include "doc.h" +#include "ogl.h" + +class MyCanvas: public wxShapeCanvas +{ +// DECLARE_DYNAMIC_CLASS(wxShapeCanvas) + protected: + public: + wxView *view; + + MyCanvas(wxView *view, wxWindow *parent = NULL, wxWindowID id = -1, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long style = wxRETAINED); + ~MyCanvas(void); + + void OnMouseEvent(wxMouseEvent& event); + void OnPaint(wxPaintEvent& event); + + virtual void OnLeftClick(float x, float y, int keys = 0); + virtual void OnRightClick(float x, float y, int keys = 0); + + virtual void OnDragLeft(bool draw, float x, float y, int keys=0); // Erase if draw false + virtual void OnBeginDragLeft(float x, float y, int keys=0); + virtual void OnEndDragLeft(float x, float y, int keys=0); + + virtual void OnDragRight(bool draw, float x, float y, int keys=0); // Erase if draw false + virtual void OnBeginDragRight(float x, float y, int keys=0); + virtual void OnEndDragRight(float x, float y, int keys=0); + +DECLARE_EVENT_TABLE() +}; + +class DiagramView: public wxView +{ + DECLARE_DYNAMIC_CLASS(DiagramView) + private: + public: + wxFrame *frame; + MyCanvas *canvas; + + DiagramView(void) { canvas = NULL; frame = NULL; }; + ~DiagramView(void) {}; + + bool OnCreate(wxDocument *doc, long flags); + void OnDraw(wxDC *dc); + void OnUpdate(wxView *sender, wxObject *hint = NULL); + bool OnClose(bool deleteWindow = TRUE); + + wxShape *FindSelectedShape(void); + +// void OnMenuCommand(int cmd); + + void OnCut(wxCommandEvent& event); + void OnChangeBackgroundColour(wxCommandEvent& event); + void OnEditLabel(wxCommandEvent& event); + +DECLARE_EVENT_TABLE() +}; + +#endif + // _OGLSAMPLE_VIEW_H_ diff --git a/utils/ogl/src/basic.h b/utils/ogl/src/basic.h index ad433d4bca..c096b8ff3f 100644 --- a/utils/ogl/src/basic.h +++ b/utils/ogl/src/basic.h @@ -102,8 +102,8 @@ class wxShapeRegion; class wxShape; #ifdef PROLOGIO -class wxExpr; -class wxDatabase; +class WXDLLEXPORT wxExpr; +class WXDLLEXPORT wxExprDatabase; #endif class wxShapeEvtHandler: public wxObject -- 2.45.2