Added OGL to contrib
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
39
contrib/samples/ogl/ogledit/Makefile
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 2000 Julian Smart
|
||||
#
|
||||
# Makefile for OGL demo (GTK version)
|
||||
#
|
||||
# This makefile requires wxWindows/GTK to be
|
||||
# installed (possibly using "make install")
|
||||
# on your system.
|
||||
#
|
||||
|
||||
CPP = gcc
|
||||
CC = gcc
|
||||
WXCONFIG=../../../../wx-config
|
||||
WXINCLUDE=-I../../../../include -I../../../include
|
||||
WXLIB=-L../../../../lib -L../../../lib
|
||||
|
||||
OBJECTS=ogledit.o palette.o doc.o view.o
|
||||
|
||||
ogledit: $(OBJECTS)
|
||||
$(CPP) -o ogledit $(OBJECTS) `$(WXCONFIG) --libs` $(WXLIB) -logl
|
||||
|
||||
ogledit.o: ogledit.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c ogledit.cpp
|
||||
|
||||
palette.o: palette.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c palette.cpp
|
||||
|
||||
doc.o: doc.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c doc.cpp
|
||||
|
||||
view.o: view.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c view.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o ogledit
|
BIN
contrib/samples/ogl/ogledit/bitmaps/arrow.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
contrib/samples/ogl/ogledit/bitmaps/arrow.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *arrow_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"####### ##############",
|
||||
"####### #############",
|
||||
"####### ############",
|
||||
"####### ###########",
|
||||
"####### ##########",
|
||||
"####### #########",
|
||||
"####### ########",
|
||||
"####### #######",
|
||||
"####### ##########",
|
||||
"####### # ##########",
|
||||
"####### ### #########",
|
||||
"########### #########",
|
||||
"############ ########",
|
||||
"############ ########",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
contrib/samples/ogl/ogledit/bitmaps/tool1.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
contrib/samples/ogl/ogledit/bitmaps/tool1.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *tool1_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"# ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ##",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
contrib/samples/ogl/ogledit/bitmaps/tool2.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
contrib/samples/ogl/ogledit/bitmaps/tool2.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *tool2_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"#### #####",
|
||||
"### ::::::::::::: ####",
|
||||
"## ::::::::::::::: ###",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"## ::::::::::::::: ###",
|
||||
"### ::::::::::::: ####",
|
||||
"#### #####",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
contrib/samples/ogl/ogledit/bitmaps/tool3.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
contrib/samples/ogl/ogledit/bitmaps/tool3.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *tool3_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"####### ########",
|
||||
"#### ::::::: #####",
|
||||
"### ::::::::::::: ####",
|
||||
"## ::::::::::::::: ###",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"# ::::::::::::::::: ##",
|
||||
"## ::::::::::::::: ###",
|
||||
"### ::::::::::::: ####",
|
||||
"#### ::::::: #####",
|
||||
"###### ########",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
contrib/samples/ogl/ogledit/bitmaps/tool4.bmp
Normal file
After Width: | Height: | Size: 382 B |
44
contrib/samples/ogl/ogledit/bitmaps/tool4.xpm
Normal file
@@ -0,0 +1,44 @@
|
||||
/* XPM */
|
||||
static char *tool4_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"22 22 16 1",
|
||||
" c Gray0",
|
||||
". c #bf0000",
|
||||
"X c #00bf00",
|
||||
"o c #bfbf00",
|
||||
"O c #0000bf",
|
||||
"+ c #bf00bf",
|
||||
"@ c #00bfbf",
|
||||
"# c #c0c0c0",
|
||||
"$ c #808080",
|
||||
"% c Red",
|
||||
"& c Green",
|
||||
"* c Yellow",
|
||||
"= c Blue",
|
||||
"- c Magenta",
|
||||
"; c Cyan",
|
||||
": c Gray100",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"########## ##########",
|
||||
"######### :: #########",
|
||||
"######## :::: ########",
|
||||
"####### :::::: #######",
|
||||
"###### :::::::: ######",
|
||||
"##### :::::::::: #####",
|
||||
"#### :::::::::::: ####",
|
||||
"### :::::::::::::: ###",
|
||||
"### :::::::::::::: ###",
|
||||
"#### :::::::::::: ####",
|
||||
"##### :::::::::: #####",
|
||||
"###### :::::::: ######",
|
||||
"####### :::::: #######",
|
||||
"######## :::: ########",
|
||||
"######### :: #########",
|
||||
"########## ##########",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
611
contrib/samples/ogl/ogledit/doc.cpp
Normal file
@@ -0,0 +1,611 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: doc.cpp
|
||||
// Purpose: Implements document 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 <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#if !wxUSE_DOC_VIEW_ARCHITECTURE
|
||||
#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
|
||||
#endif
|
||||
|
||||
#include <wx/wxexpr.h>
|
||||
#include "ogledit.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
#include <iostream.h>
|
||||
#endif
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(DiagramDocument, wxDocument)
|
||||
|
||||
DiagramDocument::DiagramDocument(void)
|
||||
{
|
||||
}
|
||||
|
||||
DiagramDocument::~DiagramDocument(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool DiagramDocument::OnCloseDocument(void)
|
||||
{
|
||||
diagram.DeleteAllShapes();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
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;
|
||||
}
|
||||
#else
|
||||
|
||||
wxOutputStream& DiagramDocument::SaveObject(wxOutputStream& stream)
|
||||
{
|
||||
wxDocument::SaveObject(stream);
|
||||
char buf[400];
|
||||
(void) wxGetTempFileName("diag", buf);
|
||||
|
||||
diagram.SaveFile(buf);
|
||||
|
||||
wxTransferFileToStream(buf, stream);
|
||||
|
||||
wxRemoveFile(buf);
|
||||
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
wxInputStream& DiagramDocument::LoadObject(wxInputStream& stream)
|
||||
{
|
||||
wxDocument::LoadObject(stream);
|
||||
|
||||
|
||||
char buf[400];
|
||||
(void) wxGetTempFileName("diag", buf);
|
||||
|
||||
wxTransferStreamToFile(stream, buf);
|
||||
|
||||
diagram.DeleteAllShapes();
|
||||
diagram.LoadFile(buf);
|
||||
wxRemoveFile(buf);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Implementation of drawing command
|
||||
*/
|
||||
|
||||
DiagramCommand::DiagramCommand(char *name, int command, DiagramDocument *ddoc, wxClassInfo *info, double xx, double 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(double x, double 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(double x, double 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(OGLRBLF);
|
||||
dc.SetPen(dottedPen);
|
||||
double xp, yp;
|
||||
GetShape()->GetAttachmentPosition(attachment, &xp, &yp);
|
||||
dc.DrawLine((long) xp, (long) yp, (long) x, (long) y);
|
||||
GetShape()->GetCanvas()->CaptureMouse();
|
||||
}
|
||||
|
||||
void MyEvtHandler::OnDragRight(bool draw, double x, double 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(OGLRBLF);
|
||||
dc.SetPen(dottedPen);
|
||||
double xp, yp;
|
||||
GetShape()->GetAttachmentPosition(attachment, &xp, &yp);
|
||||
dc.DrawLine((long) xp, (long) yp, (long) x, (long) y);
|
||||
}
|
||||
|
||||
void MyEvtHandler::OnEndDragRight(double x, double 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(double x, double 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(double w, double h):
|
||||
wxRectangleShape(w, h)
|
||||
{
|
||||
// 0.3 of the smaller rectangle dimension
|
||||
SetCornerRadius((double) -0.3);
|
||||
}
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDiamondShape, wxPolygonShape)
|
||||
|
||||
wxDiamondShape::wxDiamondShape(double w, double 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);
|
||||
}
|
182
contrib/samples/ogl/ogledit/doc.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <wx/docview.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/wxexpr.h>
|
||||
|
||||
#include <wx/ogl/ogl.h>
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
class ostream;
|
||||
class istream;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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(double w = 0.0, double h = 0.0);
|
||||
};
|
||||
|
||||
class wxDiamondShape: public wxPolygonShape
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxDiamondShape)
|
||||
private:
|
||||
public:
|
||||
wxDiamondShape(double w = 0.0, double 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(double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnBeginDragRight(double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnDragRight(bool draw, double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnEndDragRight(double x, double y, int keys = 0, int attachment = 0);
|
||||
void OnEndSize(double x, double y);
|
||||
};
|
||||
|
||||
/*
|
||||
* A diagram document, which contains a diagram.
|
||||
*/
|
||||
|
||||
class DiagramDocument: public wxDocument
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(DiagramDocument)
|
||||
private:
|
||||
public:
|
||||
MyDiagram diagram;
|
||||
|
||||
DiagramDocument(void);
|
||||
~DiagramDocument(void);
|
||||
|
||||
#if wxUSE_STD_IOSTREAM
|
||||
virtual ostream& SaveObject(ostream& stream);
|
||||
virtual istream& LoadObject(istream& stream);
|
||||
#else
|
||||
virtual wxOutputStream& SaveObject(wxOutputStream& stream);
|
||||
virtual wxInputStream& LoadObject(wxInputStream& stream);
|
||||
#endif
|
||||
|
||||
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;
|
||||
double x;
|
||||
double 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,
|
||||
double x = 0.0, double 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_
|
18
contrib/samples/ogl/ogledit/makefile.b32
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds sample for 32-bit BC++
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=ogledit
|
||||
EXTRALIBS=$(WXDIR)\contrib\lib\ogl.lib
|
||||
# EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src
|
||||
OBJECTS = $(TARGET).obj doc.obj view.obj palette.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
21
contrib/samples/ogl/ogledit/makefile.bcc
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# File: makefile.bcc
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
#
|
||||
# Builds a BC++ 16-bit sample
|
||||
|
||||
!if "$(WXWIN)" == ""
|
||||
!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx
|
||||
!endif
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=ogledit
|
||||
EXTRALIBS=$(WXDIR)\contrib\lib\ogl.lib
|
||||
# EXTRACPPFLAGS=-I$(WXDIR)\utils\ogl\src
|
||||
OBJECTS = $(TARGET).obj doc.obj view.obj palette.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|
88
contrib/samples/ogl/ogledit/makefile.dos
Normal file
@@ -0,0 +1,88 @@
|
||||
#
|
||||
# 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)\contrib\samples\ogl\ogledit
|
||||
WXLIB = $(WXDIR)\contrib\lib\wx.lib
|
||||
OGLLIB = $(WXDIR)\contrib\lib\ogl.lib
|
||||
|
||||
LIBS=$(WXLIB) $(OGLLIB) oldnames libw llibcew commdlg shell ddeml
|
||||
|
||||
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)\include /i$(WXDIR)\contrib\include ogledit
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase *.exe
|
||||
-erase *.res
|
||||
-erase *.map
|
||||
-erase *.sbr
|
||||
-erase *.pdb
|
18
contrib/samples/ogl/ogledit/makefile.g95
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# File: makefile.g95
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) Julian Smart, 1999
|
||||
#
|
||||
# Makefile for wxWindows sample (Cygwin/Mingw32).
|
||||
|
||||
WXDIR = ../../../..
|
||||
|
||||
TARGET=ogledit
|
||||
# EXTRACPPFLAGS=-I../../src
|
||||
EXTRALIBS=-logl
|
||||
OBJECTS = $(TARGET).o doc.o view.o palette.o
|
||||
|
||||
include $(WXDIR)/src/makeprog.g95
|
||||
|
20
contrib/samples/ogl/ogledit/makefile.unx
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# File: makefile.unx
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
# Updated:
|
||||
# Copyright: (c) 1998 Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile for OGLEdit example (UNIX).
|
||||
|
||||
PROGRAM=ogledit
|
||||
|
||||
OBJECTS=$(PROGRAM).o doc.o view.o palette.o
|
||||
|
||||
# EXTRACPPFLAGS=-I$(WXDIR)/contrib/include
|
||||
EXTRALDLIBS=-logl$(GUISUFFIX)
|
||||
|
||||
include ../../../../src/makeprog.env
|
||||
|
29
contrib/samples/ogl/ogledit/makefile.vc
Normal file
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# File: makefile.vc
|
||||
# Author: Julian Smart
|
||||
# Created: 1993
|
||||
# Updated:
|
||||
# Copyright: (c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds ogledit example (MS VC++).
|
||||
# Use FINAL=1 argument to nmake to build final version with no debugging
|
||||
# info
|
||||
|
||||
# Set WXDIR for your system
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
PROGRAM=ogledit
|
||||
FINAL=0
|
||||
|
||||
!if "$(FINAL)" == "0"
|
||||
EXTRALIBS=$(WXDIR)\contrib\lib\ogl_d.lib
|
||||
!else
|
||||
EXTRALIBS=$(WXDIR)\contrib\lib\ogl.lib
|
||||
!endif
|
||||
|
||||
OBJECTS = $(PROGRAM).obj doc.obj view.obj palette.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.vc
|
||||
|
44
contrib/samples/ogl/ogledit/makefile.vms
Normal file
@@ -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
|
||||
|
15
contrib/samples/ogl/ogledit/makefile.wat
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# Makefile for WATCOM
|
||||
#
|
||||
# Created by D.Chubraev, chubraev@iem.ee.ethz.ch
|
||||
# 8 Nov 1994
|
||||
#
|
||||
|
||||
WXDIR = $(%WXWIN)
|
||||
|
||||
PROGRAM = ogledit
|
||||
EXTRALIBS = $(WXDIR)\contrib\lib\ogl.lib
|
||||
OBJECTS = $(PROGRAM).obj doc.obj view.obj palette.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.wat
|
||||
|
BIN
contrib/samples/ogl/ogledit/ogl.ico
Normal file
After Width: | Height: | Size: 766 B |
45
contrib/samples/ogl/ogledit/ogl.xpm
Normal file
@@ -0,0 +1,45 @@
|
||||
/* XPM */
|
||||
static char * ogl_xpm[] = {
|
||||
/* width height ncolors chars_per_pixel */
|
||||
"32 32 7 1",
|
||||
/* colors */
|
||||
" s None c None",
|
||||
". c #000000",
|
||||
"+ c #000080",
|
||||
"@ c #ff0000",
|
||||
"# c #00ff00",
|
||||
"$ c #00ffff",
|
||||
"% c #ffffff",
|
||||
/* pixels */
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%............%%%%%%........%%%%%",
|
||||
"%.@@@@@@@@@@.%%%%..$$$$$$$$..%%%",
|
||||
"%.@@@@@@@@@@.%%%.$$$$$$$$$$$$.%%",
|
||||
"%.@@@@@@@@@@.+++.$$$$$$$$$$$$.%%",
|
||||
"%.@@@@@@@@@@.+++.$$$$$$$$$$$$.%%",
|
||||
"%.@@@@@@@@@@.%%%.$$$$$$$$$$$$.%%",
|
||||
"%.@@@@@@@@@@.%%%%..$$$$$$$$..%%%",
|
||||
"%............%%%%%.........%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%++%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%+.%%%%%%%%%%%%%%++%%%%%%%%",
|
||||
"%%%%%%.+.%%%%%%%%%%%%.++..%%%%%%",
|
||||
"%%%%%.+++.%%%%%%%%%..#####..%%%%",
|
||||
"%%%%.+++++.%%%%%%%.#########.%%%",
|
||||
"%%%.+++++++.%%%%%%.#########.%%%",
|
||||
"%%.+++++++++.%%%%.###########.%%",
|
||||
"%.+++++++++++.++++###########.%%",
|
||||
"%%.+++++++++.+++++###########.%%",
|
||||
"%%%.+++++++.%%%%%%.#########.%%%",
|
||||
"%%%%.+++++.%%%%%%%.#########.%%%",
|
||||
"%%%%%.+++.%%%%%%%%%..#####..%%%%",
|
||||
"%%%%%%.+.%%%%%%%%%%%%.....%%%%%%",
|
||||
"%%%%%%%.%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%",
|
||||
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"};
|
213
contrib/samples/ogl/ogledit/ogledit.cpp
Normal file
@@ -0,0 +1,213 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#if !wxUSE_DOC_VIEW_ARCHITECTURE
|
||||
#error You must set wxUSE_DOC_VIEW_ARCHITECTURE to 1 in wx_setup.h!
|
||||
#endif
|
||||
|
||||
#include "ogledit.h"
|
||||
#include "palette.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
#include "ogl.xpm"
|
||||
#endif
|
||||
|
||||
// A macro needed for some compilers (AIX) that need 'main' to be defined
|
||||
// in the application itself.
|
||||
IMPLEMENT_APP(MyApp)
|
||||
|
||||
MyApp::MyApp(void)
|
||||
{
|
||||
frame = NULL;
|
||||
myDocManager= NULL;
|
||||
}
|
||||
|
||||
// The `main program' equivalent, creating the windows and returning the
|
||||
// main frame
|
||||
bool MyApp::OnInit(void)
|
||||
{
|
||||
wxOGLInitialize();
|
||||
|
||||
//// Create a document manager
|
||||
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
|
||||
frame->SetIcon(wxICON(ogl));
|
||||
|
||||
//// 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 = wxGetApp().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;
|
||||
}
|
||||
|
||||
int MyApp::OnExit(void)
|
||||
{
|
||||
wxOGLCleanUp();
|
||||
delete myDocManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
EVT_CLOSE(MyFrame::OnCloseWindow)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void MyFrame::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
wxDocParentFrame::OnCloseWindow(event);
|
||||
if (!event.GetVeto())
|
||||
{
|
||||
wxOGLCleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
canvas->SetCursor(wxCursor(wxCURSOR_HAND));
|
||||
|
||||
// Give it scrollbars
|
||||
canvas->SetScrollbars(20, 20, 50, 50);
|
||||
|
||||
return canvas;
|
||||
}
|
||||
|
||||
MyFrame *GetMainFrame(void)
|
||||
{
|
||||
return wxGetApp().frame;
|
||||
}
|
||||
|
8
contrib/samples/ogl/ogledit/ogledit.def
Normal file
@@ -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
|
77
contrib/samples/ogl/ogledit/ogledit.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <wx/docview.h>
|
||||
|
||||
// Define a new application
|
||||
class MyFrame;
|
||||
class EditorToolPalette;
|
||||
class MyApp: public wxApp
|
||||
{
|
||||
public:
|
||||
MyFrame *frame;
|
||||
wxDocManager* myDocManager;
|
||||
|
||||
MyApp(void);
|
||||
bool OnInit(void);
|
||||
int OnExit(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);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
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_
|
10
contrib/samples/ogl/ogledit/ogledit.rc
Normal file
@@ -0,0 +1,10 @@
|
||||
ogl 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"
|
||||
|
121
contrib/samples/ogl/ogledit/palette.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/toolbar.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include "ogledit.h"
|
||||
#include "palette.h"
|
||||
|
||||
// Include pixmaps
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
#include "bitmaps/arrow.xpm"
|
||||
#include "bitmaps/tool1.xpm"
|
||||
#include "bitmaps/tool2.xpm"
|
||||
#include "bitmaps/tool3.xpm"
|
||||
#include "bitmaps/tool4.xpm"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Object editor tool palette
|
||||
*
|
||||
*/
|
||||
|
||||
EditorToolPalette::EditorToolPalette(wxWindow* parent, const wxPoint& pos, const wxSize& size,
|
||||
long style):
|
||||
TOOLPALETTECLASS(parent, -1, pos, size, style)
|
||||
{
|
||||
currentlySelected = -1;
|
||||
|
||||
#if 1 // ndef __WXGTK__
|
||||
SetMaxRowsCols(1000, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
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");
|
||||
#elif defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
wxBitmap PaletteTool1(tool1_xpm);
|
||||
wxBitmap PaletteTool2(tool2_xpm);
|
||||
wxBitmap PaletteTool3(tool3_xpm);
|
||||
wxBitmap PaletteTool4(tool4_xpm);
|
||||
wxBitmap PaletteArrow(arrow_xpm);
|
||||
#endif
|
||||
|
||||
EditorToolPalette *palette = new EditorToolPalette(parent, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL);
|
||||
|
||||
palette->SetMargins(2, 2);
|
||||
palette->SetToolBitmapSize(wxSize(22, 22));
|
||||
|
||||
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;
|
||||
}
|
||||
|
66
contrib/samples/ogl/ogledit/palette.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <wx/wx.h>
|
||||
#include <wx/string.h>
|
||||
#if 0 // def __WXGTK__
|
||||
#include <wx/toolbar.h>
|
||||
#else
|
||||
#include <wx/tbarsmpl.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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.
|
||||
#if 0 // def __WXGTK__
|
||||
#define TOOLPALETTECLASS wxToolBar
|
||||
#else
|
||||
#define TOOLPALETTECLASS wxToolBarSimple
|
||||
#endif
|
||||
|
||||
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_
|
337
contrib/samples/ogl/ogledit/view.cpp
Normal file
@@ -0,0 +1,337 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/colordlg.h>
|
||||
|
||||
#if !wxUSE_DOC_VIEW_ARCHITECTURE
|
||||
#error You must set wxUSE_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;
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
|
||||
/* You might use THIS code if you were scaling
|
||||
* graphics of known size to fit on the page.
|
||||
*/
|
||||
int 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 ((long) posX, (long) 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
view = v;
|
||||
}
|
||||
|
||||
MyCanvas::~MyCanvas(void)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnLeftClick(double x, double 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(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnDragLeft(bool draw, double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnBeginDragLeft(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnEndDragLeft(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnDragRight(bool draw, double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnBeginDragRight(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnEndDragRight(double x, double y, int keys)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnMouseEvent(wxMouseEvent& event)
|
||||
{
|
||||
wxShapeCanvas::OnMouseEvent(event);
|
||||
}
|
||||
|
||||
void MyCanvas::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
// if (GetDiagram())
|
||||
wxShapeCanvas::OnPaint(event);
|
||||
}
|
79
contrib/samples/ogl/ogledit/view.h
Normal file
@@ -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 <wx/ogl/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(double x, double y, int keys = 0);
|
||||
virtual void OnRightClick(double x, double y, int keys = 0);
|
||||
|
||||
virtual void OnDragLeft(bool draw, double x, double y, int keys=0); // Erase if draw false
|
||||
virtual void OnBeginDragLeft(double x, double y, int keys=0);
|
||||
virtual void OnEndDragLeft(double x, double y, int keys=0);
|
||||
|
||||
virtual void OnDragRight(bool draw, double x, double y, int keys=0); // Erase if draw false
|
||||
virtual void OnBeginDragRight(double x, double y, int keys=0);
|
||||
virtual void OnEndDragRight(double x, double 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_
|
57
contrib/samples/ogl/studio/Makefile
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# File: Makefile
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: (c) 2000 Julian Smart
|
||||
#
|
||||
# Makefile for OGL demo (GTK version)
|
||||
#
|
||||
# This makefile requires wxWindows/GTK to be
|
||||
# installed (possibly using "make install")
|
||||
# on your system.
|
||||
#
|
||||
|
||||
CPP = gcc
|
||||
CC = gcc
|
||||
WXCONFIG=../../../../wx-config
|
||||
WXINCLUDE=-I../../../../include -I../../../include
|
||||
WXLIB=-L../../../../lib -L../../../lib
|
||||
|
||||
OBJECTS=studio.o cspalette.o csprint.o dialogs.o doc.o mainfrm.o project.o shapes.o symbols.o view.o
|
||||
|
||||
studio: $(OBJECTS)
|
||||
$(CPP) -o studio $(OBJECTS) `$(WXCONFIG) --libs` $(WXLIB) -logl
|
||||
|
||||
studio.o: studio.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c studio.cpp
|
||||
|
||||
cspalette.o: cspalette.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c cspalette.cpp
|
||||
|
||||
doc.o: doc.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c doc.cpp
|
||||
|
||||
view.o: view.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c view.cpp
|
||||
|
||||
dialogs.o: dialogs.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c dialogs.cpp
|
||||
|
||||
mainfrm.o: mainfrm.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c mainfrm.cpp
|
||||
|
||||
project.o: project.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c project.cpp
|
||||
|
||||
shapes.o: shapes.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c shapes.cpp
|
||||
|
||||
symbols.o: symbols.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c symbols.cpp
|
||||
|
||||
csprint.o: csprint.cpp
|
||||
$(CPP) `$(WXCONFIG) --cflags` -I../../src $(WXINCLUDE) -c csprint.cpp
|
||||
|
||||
clean:
|
||||
rm -f *.o studio
|
BIN
contrib/samples/ogl/studio/bitmaps/alignb.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/alignb.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *alignb_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ........",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" ..... .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" ..... ........",
|
||||
" ",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/alignl.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/alignl.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *alignl_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ...... ",
|
||||
" .XXXX. ",
|
||||
" .XXXX. ",
|
||||
" .XXXX. ",
|
||||
" ...... ",
|
||||
" ",
|
||||
" ",
|
||||
" ........... ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" ........... ",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/alignr.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/alignr.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *alignr_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ...... ",
|
||||
" .XXXX. ",
|
||||
" .XXXX. ",
|
||||
" .XXXX. ",
|
||||
" ...... ",
|
||||
" ",
|
||||
" ",
|
||||
" ........... ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" ........... ",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/alignt.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/alignt.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *alignt_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ..... ........",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" ..... .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" ........",
|
||||
" ",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/arrow.bmp
Normal file
After Width: | Height: | Size: 382 B |
31
contrib/samples/ogl/studio/bitmaps/arrow.xpm
Normal file
@@ -0,0 +1,31 @@
|
||||
/* XPM */
|
||||
static char *arrow_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 22 22 2 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #c0c0c0",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"#######.##############",
|
||||
"#######..#############",
|
||||
"#######...############",
|
||||
"#######....###########",
|
||||
"#######.....##########",
|
||||
"#######......#########",
|
||||
"#######.......########",
|
||||
"#######........#######",
|
||||
"#######.....##########",
|
||||
"#######..#..##########",
|
||||
"#######.###..#########",
|
||||
"###########..#########",
|
||||
"############..########",
|
||||
"############..########",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/bitmap1.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
contrib/samples/ogl/studio/bitmaps/bitmap2.bmp
Normal file
After Width: | Height: | Size: 238 B |
BIN
contrib/samples/ogl/studio/bitmaps/copy.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/copy.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *copy_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 4 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Gray100",
|
||||
"o c #000080",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ...... ",
|
||||
" .XXXX.. ",
|
||||
" .XXXX.X. ",
|
||||
" .X..X.oooooo ",
|
||||
" .XXXXXoXXXXoo ",
|
||||
" .X....oXXXXoXo ",
|
||||
" .XXXXXoX..Xoooo",
|
||||
" .X....oXXXXXXXo",
|
||||
" .XXXXXoX.....Xo",
|
||||
" ......oXXXXXXXo",
|
||||
" oX.....Xo",
|
||||
" oXXXXXXXo",
|
||||
" ooooooooo",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/copysize.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/copysize.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *copysize_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
/* pixels */
|
||||
" ",
|
||||
".......... ... ",
|
||||
".XXXXXXXX. . ",
|
||||
".XXXXXXXX. . ",
|
||||
".XXXXXXXX. .....",
|
||||
".XXXXXXXX. ... ",
|
||||
".......... . ",
|
||||
" ",
|
||||
" . . . . . . ",
|
||||
" ",
|
||||
" . ...... . ",
|
||||
" .XXXX. ",
|
||||
" . ...... . ",
|
||||
" ",
|
||||
" . . . . . . "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/cut.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/cut.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *cut_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c #000080",
|
||||
/* pixels */
|
||||
" ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" .. .. ",
|
||||
" . . ",
|
||||
" ... ",
|
||||
" . ",
|
||||
" X.X ",
|
||||
" X XXX ",
|
||||
" XXX X X ",
|
||||
" X X X X ",
|
||||
" X X X X ",
|
||||
" X X XX ",
|
||||
" XX "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/cutpoint.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/cutpoint.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *cutpoint_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 3 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #800000",
|
||||
"a c #c0c0c0",
|
||||
/* pixels */
|
||||
"aaaaaaaaaaaaaaaa",
|
||||
"aaaaaaaaaaaaaaaa",
|
||||
"aa#aaaaaaaaa#aaa",
|
||||
"aaa#aaaaaaa#aaaa",
|
||||
"aaaa#aaaaa#aaaaa",
|
||||
"aaaaa#...#aaaaaa",
|
||||
"aaaaaa#.#.aaaaaa",
|
||||
".......#........",
|
||||
"aaaaaa#.#.aaaaaa",
|
||||
"aaaaa#...#aaaaaa",
|
||||
"aaaa#aaaaa#aaaaa",
|
||||
"aaa#aaaaaaa#aaaa",
|
||||
"aa#aaaaaaaaa#aaa",
|
||||
"aaaaaaaaaaaaaaaa",
|
||||
"aaaaaaaaaaaaaaaa"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/help.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/help.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *help_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c #008080",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ...... ",
|
||||
" .XXXXX.. ",
|
||||
" .XX...XX.. ",
|
||||
" .X.. .X.. ",
|
||||
" .X.. .XX.. ",
|
||||
" .. .XX.. ",
|
||||
" .XX.. ",
|
||||
" .X.. ",
|
||||
" .X.. ",
|
||||
" .X.. ",
|
||||
" .. ",
|
||||
" .XX.. ",
|
||||
" .XX.. ",
|
||||
" ... "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/helpcs.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/helpcs.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *helpcs_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 2 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #c0c0c0",
|
||||
/* pixels */
|
||||
"################",
|
||||
".########.....##",
|
||||
"..######..###..#",
|
||||
"...####..####...",
|
||||
"....###..####...",
|
||||
".....###..###..#",
|
||||
"......######..##",
|
||||
".......####..###",
|
||||
"........##..####",
|
||||
".....#####..####",
|
||||
"..#..###########",
|
||||
".###..####...###",
|
||||
"####..####...###",
|
||||
"#####..#########",
|
||||
"#####..#########"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/horiz.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/horiz.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *horiz_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ..... ",
|
||||
" .XXX. ",
|
||||
" .XXX. ",
|
||||
" .XXX. ",
|
||||
" ..... ",
|
||||
" ",
|
||||
" ",
|
||||
" ........... ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" ........... ",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/linearrow.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/linearrow.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *linearrow_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 3 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #800000",
|
||||
"a c #c0c0c0",
|
||||
/* pixels */
|
||||
"aaaaaaaaaaaaaaaa",
|
||||
"aaaaa#aaaaaaaaaa",
|
||||
"aaaaa##aaaaaaaaa",
|
||||
"aaaaa###aaaaaaaa",
|
||||
"aaaaa####aaaaaaa",
|
||||
"aaaaa#####aaaaaa",
|
||||
".....######.....",
|
||||
".....######.....",
|
||||
"aaaaa#####aaaaaa",
|
||||
"aaaaa####aaaaaaa",
|
||||
"aaaaa###aaaaaaaa",
|
||||
"aaaaa##aaaaaaaaa",
|
||||
"aaaaa#aaaaaaaaaa",
|
||||
"aaaaaaaaaaaaaaaa",
|
||||
"aaaaaaaaaaaaaaaa"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/new.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/new.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *new_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Gray100",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ........ ",
|
||||
" .XXXXXX.. ",
|
||||
" .XXXXXX.X. ",
|
||||
" .XXXXXX.... ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" .XXXXXXXXX. ",
|
||||
" ........... ",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/newpoint.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/newpoint.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *newpoint_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 3 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #c0c0c0",
|
||||
"a c #ffff00",
|
||||
/* pixels */
|
||||
"#######a########",
|
||||
"###a###a###a####",
|
||||
"####a##a##a#####",
|
||||
"#####a#a#a######",
|
||||
"################",
|
||||
"##aaa#....#aaa##",
|
||||
"######....######",
|
||||
"................",
|
||||
"######....######",
|
||||
"######....######",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/open.bmp
Normal file
After Width: | Height: | Size: 238 B |
26
contrib/samples/ogl/studio/bitmaps/open.xpm
Normal file
@@ -0,0 +1,26 @@
|
||||
/* XPM */
|
||||
static char *open_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 5 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
"o c Gray100",
|
||||
"O c #bfbf00",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ... ",
|
||||
" . . .",
|
||||
" ..",
|
||||
" ... ...",
|
||||
" .XoX....... ",
|
||||
" .oXoXoXoXo. ",
|
||||
" .XoXoXoXoX. ",
|
||||
" .oXoX..........",
|
||||
" .XoX.OOOOOOOOO.",
|
||||
" .oo.OOOOOOOOO. ",
|
||||
" .X.OOOOOOOOO. ",
|
||||
" ..OOOOOOOOO. ",
|
||||
" ........... ",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/paste.bmp
Normal file
After Width: | Height: | Size: 238 B |
27
contrib/samples/ogl/studio/bitmaps/paste.xpm
Normal file
@@ -0,0 +1,27 @@
|
||||
/* XPM */
|
||||
static char *paste_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 6 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
"o c #808080",
|
||||
"O c #000080",
|
||||
"+ c Gray100",
|
||||
/* pixels */
|
||||
" ",
|
||||
" .... ",
|
||||
" .....XX..... ",
|
||||
".ooo.X..X.ooo. ",
|
||||
".oo. .oo. ",
|
||||
".oo........oo. ",
|
||||
".oooooooooooo. ",
|
||||
".oooooOOOOOOO. ",
|
||||
".oooooO+++++OO ",
|
||||
".oooooO+++++O+O ",
|
||||
".oooooO+OOO+OOO ",
|
||||
".oooooO+++++++O ",
|
||||
".oooooO+OOOOO+O ",
|
||||
" .....O+++++++O ",
|
||||
" OOOOOOOOO "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/preview.bmp
Normal file
After Width: | Height: | Size: 238 B |
26
contrib/samples/ogl/studio/bitmaps/preview.xpm
Normal file
@@ -0,0 +1,26 @@
|
||||
/* XPM */
|
||||
static char *preview_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 5 1",
|
||||
" c Black",
|
||||
". c None",
|
||||
"X c Gray100",
|
||||
"o c #808080",
|
||||
"O c Cyan",
|
||||
/* pixels */
|
||||
" .......",
|
||||
" XXXXXXX ......",
|
||||
" XXXXXXX . .....",
|
||||
" XXXXXXX ....",
|
||||
" XXXXXXXXXX ....",
|
||||
" XXXXXXX ....",
|
||||
" XXXXXX o..o ...",
|
||||
" XXXXX oOO.oo ..",
|
||||
" XXXXX .O..o. ..",
|
||||
" XXXXX ....o. ..",
|
||||
" XXXXX o..Ooo ..",
|
||||
" XXXXXX o..o o..",
|
||||
" XXXXXXX o .",
|
||||
" XXXXXXXXXX . ",
|
||||
" .. "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/print.bmp
Normal file
After Width: | Height: | Size: 238 B |
26
contrib/samples/ogl/studio/bitmaps/print.xpm
Normal file
@@ -0,0 +1,26 @@
|
||||
/* XPM */
|
||||
static char *print_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 5 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Gray100",
|
||||
"o c #808000",
|
||||
"O c Yellow",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ......... ",
|
||||
" .XXXXXXXX. ",
|
||||
" .X.....X. ",
|
||||
" .XXXXXXXX. ",
|
||||
" .X.....X.... ",
|
||||
" .XXXXXXXX. . .",
|
||||
" .......... . ..",
|
||||
". . . .",
|
||||
"............. .",
|
||||
". ooo . . ",
|
||||
". OOO ... ",
|
||||
"............. . ",
|
||||
" . . . ",
|
||||
" ........... "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/redo.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/redo.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *redo_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 3 1",
|
||||
/* colors */
|
||||
". c #000080",
|
||||
"# c #c0c0c0",
|
||||
"a c #808080",
|
||||
/* pixels */
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"###a....########",
|
||||
"##a.####..###.##",
|
||||
"##.#######.#..##",
|
||||
"##.########...##",
|
||||
"##.#######....##",
|
||||
"##a.#####.....##",
|
||||
"###.a###########",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/save.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/save.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *save_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 4 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c #808000",
|
||||
"o c #808080",
|
||||
/* pixels */
|
||||
" ",
|
||||
" .............. ",
|
||||
" .X. . . ",
|
||||
" .X. ... ",
|
||||
" .X. .X. ",
|
||||
" .X. .X. ",
|
||||
" .X. .X. ",
|
||||
" .X. .X. ",
|
||||
" .XX........oX. ",
|
||||
" .XXXXXXXXXXXX. ",
|
||||
" .XX.........X. ",
|
||||
" .XX...... .X. ",
|
||||
" .XX...... .X. ",
|
||||
" .XX...... .X. ",
|
||||
" ............. "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/straight.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/straight.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *straight_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 2 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #c0c0c0",
|
||||
/* pixels */
|
||||
"################",
|
||||
".........#######",
|
||||
".........#######",
|
||||
"#######..#######",
|
||||
"#######..#######",
|
||||
"#######..#######",
|
||||
"#######..#######",
|
||||
"#######..#######",
|
||||
"#######..#######",
|
||||
"#######..#######",
|
||||
"#######..#######",
|
||||
"#######..#######",
|
||||
"#######.........",
|
||||
"#######.........",
|
||||
"################"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/texttool.bmp
Normal file
After Width: | Height: | Size: 382 B |
31
contrib/samples/ogl/studio/bitmaps/texttool.xpm
Normal file
@@ -0,0 +1,31 @@
|
||||
/* XPM */
|
||||
static char *texttool_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 22 22 2 1",
|
||||
/* colors */
|
||||
". c #000000",
|
||||
"# c #c0c0c0",
|
||||
/* pixels */
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"##########..##########",
|
||||
"##########..##########",
|
||||
"#########....#########",
|
||||
"#########....#########",
|
||||
"########.....#########",
|
||||
"########..#...########",
|
||||
"#######..##...########",
|
||||
"#######..###...#######",
|
||||
"######.........#######",
|
||||
"######..####...#######",
|
||||
"######.######...######",
|
||||
"#####..######...######",
|
||||
"####....####......####",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################",
|
||||
"######################"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/tick.bmp
Normal file
After Width: | Height: | Size: 220 B |
BIN
contrib/samples/ogl/studio/bitmaps/tick.xpm
Normal file
BIN
contrib/samples/ogl/studio/bitmaps/toback.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/toback.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *toback_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 4 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c #808080",
|
||||
"o c Yellow",
|
||||
/* pixels */
|
||||
" ....... ",
|
||||
" .XXXXX. ",
|
||||
" .XXXXX...... ",
|
||||
" .XXXXX.oooo. ",
|
||||
" .XXXXX.oooo. ",
|
||||
" .XXXXX.oooo. ",
|
||||
" .......oooo. ",
|
||||
" .oooo.......",
|
||||
" .oooo.XXXXX.",
|
||||
" .oooo.XXXXX.",
|
||||
" ......XXXXX.",
|
||||
" .XXXXX.",
|
||||
" .XXXXX.",
|
||||
" .......",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/tofront.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/tofront.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *tofront_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 4 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c #808080",
|
||||
"o c Yellow",
|
||||
/* pixels */
|
||||
" ....... ",
|
||||
" .XXXXX. ",
|
||||
" .XX......... ",
|
||||
" .XX.ooooooo. ",
|
||||
" .XX.ooooooo. ",
|
||||
" .XX.ooooooo. ",
|
||||
" ....ooooooo. ",
|
||||
" .ooooooo....",
|
||||
" .ooooooo.XX.",
|
||||
" .ooooooo.XX.",
|
||||
" .........XX.",
|
||||
" .XXXXX.",
|
||||
" .XXXXX.",
|
||||
" .......",
|
||||
" "
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/undo.bmp
Normal file
After Width: | Height: | Size: 238 B |
25
contrib/samples/ogl/studio/bitmaps/undo.xpm
Normal file
@@ -0,0 +1,25 @@
|
||||
/* XPM */
|
||||
static char *undo_xpm[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 16 15 3 1",
|
||||
/* colors */
|
||||
". c #000080",
|
||||
"# c #c0c0c0",
|
||||
"a c #808080",
|
||||
/* pixels */
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"########....a###",
|
||||
"##.###..####.a##",
|
||||
"##..#.#######.##",
|
||||
"##...########.##",
|
||||
"##....#######.##",
|
||||
"##.....#####.a##",
|
||||
"###########a.###",
|
||||
"################",
|
||||
"################",
|
||||
"################",
|
||||
"################"
|
||||
};
|
BIN
contrib/samples/ogl/studio/bitmaps/vert.bmp
Normal file
After Width: | Height: | Size: 238 B |
24
contrib/samples/ogl/studio/bitmaps/vert.xpm
Normal file
@@ -0,0 +1,24 @@
|
||||
/* XPM */
|
||||
static char *vert_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 15 3 1",
|
||||
" c None",
|
||||
". c Black",
|
||||
"X c Yellow",
|
||||
/* pixels */
|
||||
" ",
|
||||
" ........",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" ..... .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" .XXX. .XXXXXX.",
|
||||
" ..... .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" .XXXXXX.",
|
||||
" ........",
|
||||
" ",
|
||||
" "
|
||||
};
|
153
contrib/samples/ogl/studio/cspalette.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cspalette.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 <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/laywin.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include "studio.h"
|
||||
#include "cspalette.h"
|
||||
#include "symbols.h"
|
||||
|
||||
#if defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
#include "bitmaps/arrow.xpm"
|
||||
#include "bitmaps/texttool.xpm"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Object editor tool palette
|
||||
*
|
||||
*/
|
||||
|
||||
csEditorToolPalette::csEditorToolPalette(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||
long style):
|
||||
TOOLPALETTECLASS(parent, id, pos, size, style)
|
||||
{
|
||||
m_currentlySelected = -1;
|
||||
|
||||
SetMaxRowsCols(1, 1000);
|
||||
}
|
||||
|
||||
bool csEditorToolPalette::OnLeftClick(int toolIndex, bool toggled)
|
||||
{
|
||||
// BEGIN mutual exclusivity code
|
||||
if (toggled && (m_currentlySelected != -1) && (toolIndex != m_currentlySelected))
|
||||
ToggleTool(m_currentlySelected, FALSE);
|
||||
|
||||
if (toggled)
|
||||
m_currentlySelected = toolIndex;
|
||||
else if (m_currentlySelected == toolIndex)
|
||||
m_currentlySelected = -1;
|
||||
// END mutual exclusivity code
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void csEditorToolPalette::OnMouseEnter(int toolIndex)
|
||||
{
|
||||
wxString msg("");
|
||||
if (toolIndex == PALETTE_ARROW)
|
||||
msg = "Pointer";
|
||||
else if (toolIndex != -1)
|
||||
{
|
||||
csSymbol* symbol = wxGetApp().GetSymbolDatabase()->FindSymbol(toolIndex);
|
||||
if (symbol)
|
||||
msg = symbol->GetName();
|
||||
}
|
||||
((wxFrame*) wxGetApp().GetTopWindow())->SetStatusText(msg);
|
||||
}
|
||||
|
||||
void csEditorToolPalette::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
TOOLPALETTECLASS::SetSize(x, y, width, height, sizeFlags);
|
||||
}
|
||||
|
||||
void csEditorToolPalette::SetSelection(int sel)
|
||||
{
|
||||
if ((sel != m_currentlySelected) && (m_currentlySelected != -1))
|
||||
{
|
||||
ToggleTool(m_currentlySelected, FALSE);
|
||||
}
|
||||
m_currentlySelected = sel;
|
||||
ToggleTool(m_currentlySelected, TRUE);
|
||||
}
|
||||
|
||||
bool csApp::CreatePalette(wxFrame *parent)
|
||||
{
|
||||
// First create a layout window
|
||||
wxSashLayoutWindow* win = new wxSashLayoutWindow(parent, ID_LAYOUT_WINDOW_PALETTE, wxDefaultPosition, wxSize(200, 30), wxNO_BORDER|wxSW_3D|wxCLIP_CHILDREN);
|
||||
win->SetDefaultSize(wxSize(10000, 40));
|
||||
win->SetOrientation(wxLAYOUT_HORIZONTAL);
|
||||
win->SetAlignment(wxLAYOUT_TOP);
|
||||
win->SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
win->SetSashVisible(wxSASH_BOTTOM, TRUE);
|
||||
|
||||
m_diagramPaletteSashWindow = win;
|
||||
|
||||
m_diagramPaletteSashWindow->Show(FALSE);
|
||||
|
||||
// Load palette bitmaps
|
||||
#ifdef __WXMSW__
|
||||
wxBitmap PaletteArrow("arrowtool");
|
||||
wxBitmap TextTool("texttool");
|
||||
#elif defined(__WXGTK__) || defined(__WXMOTIF__)
|
||||
wxBitmap PaletteArrow(arrow_xpm);
|
||||
wxBitmap TextTool(texttool_xpm);
|
||||
#endif
|
||||
|
||||
csEditorToolPalette *palette = new csEditorToolPalette(m_diagramPaletteSashWindow, ID_DIAGRAM_PALETTE, wxPoint(0, 0), wxSize(-1, -1), wxTB_HORIZONTAL|wxNO_BORDER);
|
||||
|
||||
palette->SetMargins(2, 2);
|
||||
|
||||
palette->SetToolBitmapSize(wxSize(32, 32));
|
||||
|
||||
palette->AddTool(PALETTE_ARROW, PaletteArrow, wxNullBitmap, TRUE, 0, -1, NULL, "Pointer");
|
||||
palette->AddTool(PALETTE_TEXT_TOOL, TextTool, wxNullBitmap, TRUE, 0, -1, NULL, "Text");
|
||||
|
||||
wxNode* node = GetSymbolDatabase()->GetSymbols().First();
|
||||
while (node)
|
||||
{
|
||||
csSymbol* symbol = (csSymbol*) node->Data();
|
||||
wxBitmap* bitmap = GetSymbolDatabase()->CreateToolBitmap(symbol);
|
||||
palette->AddTool(symbol->GetToolId(), *bitmap, wxNullBitmap, TRUE, 0, -1, NULL, symbol->GetName());
|
||||
|
||||
delete bitmap;
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
palette->Realize();
|
||||
|
||||
palette->SetSelection(PALETTE_ARROW);
|
||||
m_diagramPalette = palette;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
57
contrib/samples/ogl/studio/cspalette.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: cspalette.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 _STUDIO_CSPALETTE_H_
|
||||
#define _STUDIO_CSPALETTE_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/tbarsmpl.h>
|
||||
|
||||
/*
|
||||
* 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 csEditorToolPalette: public TOOLPALETTECLASS
|
||||
{
|
||||
public:
|
||||
|
||||
csEditorToolPalette(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTB_VERTICAL);
|
||||
|
||||
bool OnLeftClick(int toolIndex, bool toggled);
|
||||
void OnMouseEnter(int toolIndex);
|
||||
|
||||
inline int GetSelection() const { return m_currentlySelected; }
|
||||
void SetSelection(int sel);
|
||||
|
||||
void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
|
||||
protected:
|
||||
int m_currentlySelected;
|
||||
};
|
||||
|
||||
#define PALETTE_ARROW 200
|
||||
#define PALETTE_TEXT_TOOL 201
|
||||
|
||||
#endif
|
||||
// _STUDIO_CSPALETTE_H_
|
320
contrib/samples/ogl/studio/csprint.cpp
Normal file
@@ -0,0 +1,320 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: csprint.cpp
|
||||
// Purpose: Printing and clipboard functionality
|
||||
// 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 <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/wxexpr.h>
|
||||
#include <wx/clipbrd.h>
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include <wx/metafile.h>
|
||||
#endif
|
||||
|
||||
#include "studio.h"
|
||||
#include "doc.h"
|
||||
#include "shapes.h"
|
||||
#include "view.h"
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDiagramClipboard, wxDiagram)
|
||||
|
||||
// Copy selection
|
||||
bool wxDiagramClipboard::Copy(wxDiagram* diagram)
|
||||
{
|
||||
DeleteAllShapes();
|
||||
|
||||
return DoCopy(diagram, this, FALSE, NULL);
|
||||
}
|
||||
|
||||
// Copy contents to the diagram, with new ids.
|
||||
|
||||
bool wxDiagramClipboard::Paste(wxDiagram* diagram, wxDC* dc, int offsetX, int offsetY)
|
||||
{
|
||||
return DoCopy(this, diagram, TRUE, dc, offsetX, offsetY);
|
||||
}
|
||||
|
||||
// Universal copy function (to or from clipboard).
|
||||
// TODO:
|
||||
// Note that this only works for non-composites so far (nested shapes
|
||||
// don't have their old-to-new object mappings stored).
|
||||
// Also, lines don't yet get their attachment points moved to the new offset position
|
||||
// if they have more than 2 points.
|
||||
bool wxDiagramClipboard::DoCopy(wxDiagram* diagramFrom, wxDiagram* diagramTo, bool newIds,
|
||||
wxDC* dc, int offsetX, int offsetY)
|
||||
{
|
||||
OnStartCopy(diagramTo);
|
||||
|
||||
wxHashTable mapping(wxKEY_INTEGER);
|
||||
|
||||
// First copy all node shapes.
|
||||
wxList* shapeList = diagramFrom->GetShapeList();
|
||||
wxNode* node = shapeList->First();
|
||||
while (node)
|
||||
{
|
||||
wxShape* shape = (wxShape*) node->Data();
|
||||
if (((diagramFrom == this) || shape->Selected()) && !shape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxShape* newShape = shape->CreateNewCopy();
|
||||
newShape->GetLines().Clear();
|
||||
if (newIds)
|
||||
{
|
||||
newShape->AssignNewIds();
|
||||
}
|
||||
mapping.Put((long) shape, (wxObject*) newShape);
|
||||
|
||||
newShape->SetX(newShape->GetX() + offsetX);
|
||||
newShape->SetY(newShape->GetY() + offsetY);
|
||||
|
||||
OnAddShape(diagramTo, newShape, dc);
|
||||
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
node = shapeList->First();
|
||||
while (node)
|
||||
{
|
||||
wxShape* shape = (wxShape*) node->Data();
|
||||
if (((diagramFrom == this) || shape->Selected()) && shape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxLineShape* lineShape = (wxLineShape*) shape;
|
||||
// Only copy a line if its ends are selected too.
|
||||
if ((diagramFrom == this) || (lineShape->GetTo()->Selected() && lineShape->GetFrom()->Selected()))
|
||||
{
|
||||
wxLineShape* newShape = (wxLineShape*) shape->CreateNewCopy();
|
||||
mapping.Put((long) shape, (wxObject*) newShape);
|
||||
|
||||
if (newIds)
|
||||
newShape->AssignNewIds();
|
||||
|
||||
wxShape* fromShape = (wxShape*) mapping.Get((long) lineShape->GetFrom());
|
||||
wxShape* toShape = (wxShape*) mapping.Get((long) lineShape->GetTo());
|
||||
|
||||
wxASSERT_MSG( (fromShape != NULL), "Could not find 'from' shape");
|
||||
wxASSERT_MSG( (toShape != NULL), "Could not find 'to' shape");
|
||||
|
||||
fromShape->AddLine(newShape, toShape, newShape->GetAttachmentFrom(),
|
||||
newShape->GetAttachmentTo());
|
||||
|
||||
OnAddShape(diagramTo, newShape, dc);
|
||||
|
||||
}
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
// Now make sure line ordering is correct
|
||||
node = shapeList->First();
|
||||
while (node)
|
||||
{
|
||||
wxShape* shape = (wxShape*) node->Data();
|
||||
if (((diagramFrom == this) || shape->Selected()) && !shape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxShape* newShape = (wxShape*) mapping.Get((long) shape);
|
||||
|
||||
// Make a list of all the new lines, in the same order as the old lines.
|
||||
// Then apply the list of new lines to the shape.
|
||||
wxList newLines;
|
||||
wxNode* lineNode = shape->GetLines().First();
|
||||
while (lineNode)
|
||||
{
|
||||
wxLineShape* lineShape = (wxLineShape*) lineNode->Data();
|
||||
if ((diagramFrom == this) || (lineShape->GetTo()->Selected() && lineShape->GetFrom()->Selected()))
|
||||
{
|
||||
wxLineShape* newLineShape = (wxLineShape*) mapping.Get((long) lineShape);
|
||||
|
||||
wxASSERT_MSG( (newLineShape != NULL), "Could not find new line shape");
|
||||
|
||||
newLines.Append(newLineShape);
|
||||
}
|
||||
|
||||
lineNode = lineNode->Next();
|
||||
}
|
||||
|
||||
if (newLines.Number() > 0)
|
||||
newShape->ApplyAttachmentOrdering(newLines);
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
OnEndCopy(diagramTo);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// Draw contents to a Windows metafile device context and a bitmap, and copy
|
||||
// these to the Windows clipboard
|
||||
bool wxDiagramClipboard::CopyToClipboard(double scale)
|
||||
{
|
||||
// Make a metafile DC
|
||||
wxMetaFileDC mfDC;
|
||||
if (mfDC.Ok())
|
||||
{
|
||||
mfDC.SetUserScale(scale, scale);
|
||||
|
||||
// Draw on metafile DC
|
||||
Redraw(mfDC);
|
||||
|
||||
int printWidth = mfDC.MaxX() - mfDC.MinX();
|
||||
int printHeight = mfDC.MaxY() - mfDC.MinY();
|
||||
int maxX = (int)mfDC.MaxX();
|
||||
int maxY = (int)mfDC.MaxY();
|
||||
wxMetaFile *mf = mfDC.Close();
|
||||
|
||||
// Set to a bitmap memory DC
|
||||
wxBitmap *newBitmap = new wxBitmap((int)(maxX + 10), (int)(maxY + 10));
|
||||
if (!newBitmap->Ok())
|
||||
{
|
||||
delete newBitmap;
|
||||
|
||||
char buf[200];
|
||||
sprintf(buf, "Sorry, could not allocate clipboard bitmap (%dx%d)", (maxX+10), (maxY+10));
|
||||
wxMessageBox(buf, "Clipboard copy problem");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wxMemoryDC memDC;
|
||||
memDC.SelectObject(*newBitmap);
|
||||
memDC.Clear();
|
||||
|
||||
// Now draw on memory bitmap DC
|
||||
Redraw(memDC);
|
||||
|
||||
memDC.SelectObject(wxNullBitmap);
|
||||
|
||||
// Open clipboard and set the data
|
||||
if (wxOpenClipboard())
|
||||
{
|
||||
wxEmptyClipboard();
|
||||
|
||||
// Copy the bitmap to the clipboard
|
||||
wxSetClipboardData(wxDF_BITMAP, newBitmap, 0, 0);
|
||||
|
||||
#if 0 // TODO: replace this code (wxEnhMetaFile doesn't have SetClipboard)
|
||||
if (mf)
|
||||
{
|
||||
// Copy the metafile to the clipboard
|
||||
// Allow a small margin
|
||||
bool success = mf->SetClipboard((int)(mfDC.MaxX() + 15), (int)(mfDC.MaxY() + 15));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Close clipboard
|
||||
wxCloseClipboard();
|
||||
}
|
||||
|
||||
delete newBitmap;
|
||||
delete mf;
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
// __WXMSW__
|
||||
|
||||
// Override this to e.g. have the shape added through a Do/Undo command system.
|
||||
// By default, we'll just add it directly to the destination diagram.
|
||||
bool wxDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxDC* dc)
|
||||
{
|
||||
diagramTo->AddShape(newShape);
|
||||
|
||||
if (dc && (diagramTo != this))
|
||||
{
|
||||
newShape->Select(TRUE, dc);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* csDiagramClipboard
|
||||
*/
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(csDiagramClipboard, wxDiagramClipboard)
|
||||
|
||||
// Start/end copying
|
||||
bool csDiagramClipboard::OnStartCopy(wxDiagram* diagramTo)
|
||||
{
|
||||
// Do nothing if copying to the clipboard
|
||||
if (diagramTo == this)
|
||||
return TRUE;
|
||||
|
||||
// Deselect all objects initially.
|
||||
|
||||
csDiagram* diagram = (csDiagram*) diagramTo;
|
||||
csDiagramDocument* doc = diagram->GetDocument();
|
||||
((csDiagramView*)doc->GetFirstView())->SelectAll(FALSE);
|
||||
|
||||
m_currentCmd = new csDiagramCommand("Paste", doc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csDiagramClipboard::OnEndCopy(wxDiagram* diagramTo)
|
||||
{
|
||||
// Do nothing if copying to the clipboard
|
||||
if (diagramTo == this)
|
||||
return TRUE;
|
||||
|
||||
csDiagram* diagram = (csDiagram*) diagramTo;
|
||||
csDiagramDocument* doc = diagram->GetDocument();
|
||||
|
||||
if (m_currentCmd)
|
||||
{
|
||||
if (m_currentCmd->GetStates().Number() == 0)
|
||||
{
|
||||
delete m_currentCmd;
|
||||
}
|
||||
else
|
||||
{
|
||||
doc->GetCommandProcessor()->Submit(m_currentCmd);
|
||||
m_currentCmd = NULL;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Use the command framework to add the shapes, if we're copying to a diagram and
|
||||
// not the clipboard.
|
||||
bool csDiagramClipboard::OnAddShape(wxDiagram* diagramTo, wxShape* newShape, wxDC* dc)
|
||||
{
|
||||
if (diagramTo == this)
|
||||
{
|
||||
diagramTo->AddShape(newShape);
|
||||
}
|
||||
else
|
||||
{
|
||||
csDiagram* diagram = (csDiagram*) diagramTo;
|
||||
csDiagramDocument* doc = diagram->GetDocument();
|
||||
|
||||
if (newShape->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
m_currentCmd->AddState(new csCommandState(ID_CS_ADD_LINE_SELECT, newShape, NULL));
|
||||
else
|
||||
m_currentCmd->AddState(new csCommandState(ID_CS_ADD_SHAPE_SELECT, newShape, NULL));
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
525
contrib/samples/ogl/studio/dialogs.cpp
Normal file
@@ -0,0 +1,525 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialogs.cpp
|
||||
// Purpose: Implements Studio dialogs
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma implementation
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/resource.h>
|
||||
#include "dialogs.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include "studio.h"
|
||||
#include "studio_resources.h"
|
||||
|
||||
IMPLEMENT_CLASS(csLabelEditingDialog, wxDialog)
|
||||
|
||||
BEGIN_EVENT_TABLE(csLabelEditingDialog, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, csLabelEditingDialog::OnOK)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csLabelEditingDialog::csLabelEditingDialog(wxWindow* parent)
|
||||
{
|
||||
LoadFromResource(parent, "shape_label_dialog");
|
||||
|
||||
// Accelerators
|
||||
wxAcceleratorEntry entries[1];
|
||||
entries[0].Set(wxACCEL_CTRL, WXK_RETURN, wxID_OK);
|
||||
wxAcceleratorTable accel(1, entries);
|
||||
SetAcceleratorTable(accel);
|
||||
|
||||
Centre();
|
||||
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
// textCtrl->SetAcceleratorTable(accel);
|
||||
|
||||
textCtrl->SetFocus();
|
||||
}
|
||||
|
||||
void csLabelEditingDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
SetShapeLabel(textCtrl->GetValue());
|
||||
|
||||
wxDialog::OnOK(event);
|
||||
}
|
||||
|
||||
void csLabelEditingDialog::SetShapeLabel(const wxString& label)
|
||||
{
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
m_label = label;
|
||||
|
||||
textCtrl->SetValue(label);
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(csSettingsDialog, wxDialog)
|
||||
|
||||
BEGIN_EVENT_TABLE(csSettingsDialog, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, csSettingsDialog::OnOK)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#define PROPERTY_DIALOG_WIDTH 400
|
||||
#define PROPERTY_DIALOG_HEIGHT 400
|
||||
|
||||
// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor
|
||||
|
||||
csSettingsDialog::csSettingsDialog(wxWindow* parent):
|
||||
wxDialog(parent, -1, "Settings", wxPoint(0, 0), wxSize(PROPERTY_DIALOG_WIDTH, PROPERTY_DIALOG_HEIGHT))
|
||||
{
|
||||
m_generalSettings = NULL;
|
||||
m_diagramSettings = NULL;
|
||||
|
||||
m_notebook = new wxNotebook(this, ID_PROPERTY_NOTEBOOK,
|
||||
wxPoint(2, 2), wxSize(PROPERTY_DIALOG_WIDTH - 4, PROPERTY_DIALOG_HEIGHT - 4));
|
||||
|
||||
m_generalSettings = new wxPanel;
|
||||
|
||||
bool success = m_generalSettings->LoadFromResource(m_notebook, "general_settings_dialog");
|
||||
wxASSERT_MSG( (success), "Could not load general settings panel.");
|
||||
m_notebook->AddPage(m_generalSettings, "General", TRUE);
|
||||
|
||||
m_diagramSettings = new wxPanel;
|
||||
|
||||
success = m_diagramSettings->LoadFromResource(m_notebook, "diagram_settings_dialog");
|
||||
wxASSERT_MSG( (success), "Could not load diagram settings panel.");
|
||||
m_notebook->AddPage(m_diagramSettings, "Diagram");
|
||||
|
||||
int largeButtonWidth = 70;
|
||||
int largeButtonHeight = 22;
|
||||
|
||||
wxButton* okButton = new wxButton(this, wxID_OK, "OK", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
wxButton* cancelButton = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
wxButton* helpButton = new wxButton(this, wxID_HELP, "Help", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
|
||||
// Constraints for the notebook
|
||||
wxLayoutConstraints *c = new wxLayoutConstraints;
|
||||
c->top.SameAs (this, wxTop, 5);
|
||||
c->left.SameAs (this, wxLeft, 5);
|
||||
c->right.SameAs (this, wxRight, 5);
|
||||
c->bottom.SameAs (cancelButton, wxTop, 5);
|
||||
m_notebook->SetConstraints(c);
|
||||
|
||||
// Constraints for the Help button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (this, wxRight, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
helpButton->SetConstraints(c);
|
||||
|
||||
// Constraints for the Cancel button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (helpButton, wxLeft, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
cancelButton->SetConstraints(c);
|
||||
|
||||
// Constraints for the OK button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (cancelButton, wxLeft, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
okButton->SetConstraints(c);
|
||||
|
||||
okButton->SetDefault();
|
||||
okButton->SetFocus();
|
||||
|
||||
Layout();
|
||||
Centre(wxBOTH);
|
||||
}
|
||||
|
||||
void csSettingsDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
wxDialog::OnOK(event);
|
||||
}
|
||||
|
||||
bool csSettingsDialog::TransferDataToWindow()
|
||||
{
|
||||
wxTextCtrl* gridSpacing = (wxTextCtrl*) m_diagramSettings->FindWindow(ID_GRID_SPACING);
|
||||
wxASSERT_MSG( (gridSpacing != (wxTextCtrl*) NULL), "Could not find grid spacing control.");
|
||||
|
||||
wxChoice* gridStyle = (wxChoice*) m_diagramSettings->FindWindow(ID_GRID_STYLE);
|
||||
wxASSERT_MSG( (gridStyle != (wxChoice*) NULL), "Could not find grid style control.");
|
||||
|
||||
gridStyle->SetSelection(wxGetApp().GetGridStyle());
|
||||
|
||||
wxString str;
|
||||
str.Printf("%d", wxGetApp().GetGridSpacing());
|
||||
gridSpacing->SetValue(str);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csSettingsDialog::TransferDataFromWindow()
|
||||
{
|
||||
wxTextCtrl* gridSpacing = (wxTextCtrl*) m_diagramSettings->FindWindow(ID_GRID_SPACING);
|
||||
wxASSERT_MSG( (gridSpacing != (wxTextCtrl*) NULL), "Could not find grid spacing control.");
|
||||
|
||||
wxChoice* gridStyle = (wxChoice*) m_diagramSettings->FindWindow(ID_GRID_STYLE);
|
||||
wxASSERT_MSG( (gridStyle != (wxChoice*) NULL), "Could not find grid style control.");
|
||||
|
||||
wxGetApp().SetGridStyle(gridStyle->GetSelection());
|
||||
wxGetApp().SetGridSpacing(atoi(gridSpacing->GetValue()));
|
||||
|
||||
if (wxGetApp().GetGridStyle() == csGRID_STYLE_DOTTED)
|
||||
{
|
||||
wxMessageBox("Dotted grid style not yet implemented.", "Studio", wxICON_EXCLAMATION);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Apply settings to all open diagram documents
|
||||
wxNode* node = wxGetApp().GetDocManager()->GetDocuments().First();
|
||||
while (node)
|
||||
{
|
||||
wxDocument* doc = (wxDocument*) node->Data();
|
||||
if (doc->IsKindOf(CLASSINFO(csDiagramDocument)))
|
||||
{
|
||||
csDiagramDocument* diagramDoc = (csDiagramDocument*) doc;
|
||||
wxDiagram* diagram = (wxDiagram*) diagramDoc->GetDiagram();
|
||||
|
||||
diagram->SetGridSpacing((double) wxGetApp().GetGridSpacing());
|
||||
switch (wxGetApp().GetGridStyle())
|
||||
{
|
||||
case csGRID_STYLE_NONE:
|
||||
{
|
||||
diagram->SetSnapToGrid(FALSE);
|
||||
break;
|
||||
}
|
||||
case csGRID_STYLE_INVISIBLE:
|
||||
{
|
||||
diagram->SetSnapToGrid(TRUE);
|
||||
break;
|
||||
}
|
||||
case csGRID_STYLE_DOTTED:
|
||||
{
|
||||
// TODO (not implemented in OGL)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shape properties dialog (tabbed)
|
||||
*/
|
||||
|
||||
|
||||
IMPLEMENT_CLASS(csShapePropertiesDialog, wxDialog)
|
||||
|
||||
BEGIN_EVENT_TABLE(csShapePropertiesDialog, wxDialog)
|
||||
EVT_BUTTON(wxID_OK, csShapePropertiesDialog::OnOK)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#define SHAPE_PROPERTY_DIALOG_WIDTH 400
|
||||
#define SHAPE_PROPERTY_DIALOG_HEIGHT 400
|
||||
|
||||
// For 400x400 settings dialog, size your panels to about 375x325 in dialog editor
|
||||
|
||||
csShapePropertiesDialog::csShapePropertiesDialog(wxWindow* parent, const wxString& title,
|
||||
wxPanel* attributeDialog, const wxString& attributeDialogName):
|
||||
wxDialog(parent, -1, title, wxPoint(0, 0), wxSize(SHAPE_PROPERTY_DIALOG_WIDTH, SHAPE_PROPERTY_DIALOG_HEIGHT))
|
||||
{
|
||||
m_attributeDialog = attributeDialog;
|
||||
m_alternativeAttributeDialog = NULL;
|
||||
m_generalPropertiesDialog = NULL;
|
||||
|
||||
m_notebook = new wxNotebook(this, ID_SHAPE_PROPERTY_NOTEBOOK,
|
||||
wxPoint(2, 2), wxSize(SHAPE_PROPERTY_DIALOG_WIDTH - 4, SHAPE_PROPERTY_DIALOG_HEIGHT - 4));
|
||||
|
||||
m_generalPropertiesDialog = new csGeneralShapePropertiesDialog;
|
||||
bool success = m_generalPropertiesDialog->LoadFromResource(m_notebook, "general_shape_properties_dialog");
|
||||
wxASSERT_MSG( (success), "Could not load general properties panel.");
|
||||
m_notebook->AddPage(m_generalPropertiesDialog, "General");
|
||||
|
||||
success = m_attributeDialog->LoadFromResource(m_notebook, attributeDialogName);
|
||||
if (!success)
|
||||
{
|
||||
wxMessageBox("Could not load the attribute dialog for this shape.", "Studio", wxICON_EXCLAMATION);
|
||||
delete m_attributeDialog;
|
||||
m_attributeDialog = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_notebook->AddPage(m_attributeDialog, "Attributes");
|
||||
}
|
||||
|
||||
// Try the alternative dialog (test code)
|
||||
wxString str(attributeDialogName);
|
||||
str += "1";
|
||||
m_alternativeAttributeDialog = new wxPanel;
|
||||
success = m_alternativeAttributeDialog->LoadFromResource(m_notebook, str);
|
||||
if (success)
|
||||
{
|
||||
m_notebook->AddPage(m_alternativeAttributeDialog, "Attributes (alternative)");
|
||||
}
|
||||
else
|
||||
{
|
||||
delete m_alternativeAttributeDialog;
|
||||
m_alternativeAttributeDialog = NULL;
|
||||
}
|
||||
|
||||
int largeButtonWidth = 70;
|
||||
int largeButtonHeight = 22;
|
||||
|
||||
wxButton* okButton = new wxButton(this, wxID_OK, "OK", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
wxButton* cancelButton = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
wxButton* helpButton = new wxButton(this, wxID_HELP, "Help", wxPoint(0, 0), wxSize(largeButtonWidth, largeButtonHeight));
|
||||
|
||||
// Constraints for the notebook
|
||||
wxLayoutConstraints *c = new wxLayoutConstraints;
|
||||
c->top.SameAs (this, wxTop, 5);
|
||||
c->left.SameAs (this, wxLeft, 5);
|
||||
c->right.SameAs (this, wxRight, 5);
|
||||
c->bottom.SameAs (helpButton, wxTop, 5);
|
||||
m_notebook->SetConstraints(c);
|
||||
|
||||
// Constraints for the Help button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (this, wxRight, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
helpButton->SetConstraints(c);
|
||||
|
||||
// Constraints for the Cancel button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (helpButton, wxLeft, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
cancelButton->SetConstraints(c);
|
||||
|
||||
// Constraints for the OK button
|
||||
c = new wxLayoutConstraints;
|
||||
c->width.AsIs();
|
||||
c->height.AsIs();
|
||||
c->right.SameAs (cancelButton, wxLeft, 5);
|
||||
c->bottom.SameAs (this, wxBottom, 5);
|
||||
okButton->SetConstraints(c);
|
||||
|
||||
okButton->SetDefault();
|
||||
okButton->SetFocus();
|
||||
|
||||
SetDefaults();
|
||||
|
||||
Layout();
|
||||
Centre(wxBOTH);
|
||||
}
|
||||
|
||||
void csShapePropertiesDialog::OnOK(wxCommandEvent& event)
|
||||
{
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) m_generalPropertiesDialog->FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
m_generalPropertiesDialog->SetShapeLabel(textCtrl->GetValue());
|
||||
|
||||
wxDialog::OnOK(event);
|
||||
}
|
||||
|
||||
// Set some suitable defaults in the attribute dialogs (in the first instance,
|
||||
// just set all wxChoices to the first element)
|
||||
void csShapePropertiesDialog::SetDefaults()
|
||||
{
|
||||
if (!m_attributeDialog)
|
||||
return;
|
||||
|
||||
wxNode* node = m_attributeDialog->GetChildren().First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* child = (wxWindow*) node->Data();
|
||||
if (child->IsKindOf(CLASSINFO(wxChoice)))
|
||||
{
|
||||
wxChoice* choice = (wxChoice*) child;
|
||||
choice->SetSelection(0);
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
if (!m_alternativeAttributeDialog)
|
||||
return;
|
||||
|
||||
node = m_alternativeAttributeDialog->GetChildren().First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* child = (wxWindow*) node->Data();
|
||||
if (child->IsKindOf(CLASSINFO(wxChoice)))
|
||||
{
|
||||
wxChoice* choice = (wxChoice*) child;
|
||||
choice->SetSelection(0);
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* csGeneralShapePropertiesDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csGeneralShapePropertiesDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csGeneralShapePropertiesDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csGeneralShapePropertiesDialog::csGeneralShapePropertiesDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void csGeneralShapePropertiesDialog::SetShapeLabel(const wxString& label)
|
||||
{
|
||||
wxTextCtrl* textCtrl = (wxTextCtrl*) FindWindow(ID_LABELTEXT);
|
||||
wxASSERT( (textCtrl != NULL) );
|
||||
|
||||
m_label = label;
|
||||
|
||||
textCtrl->SetValue(label);
|
||||
}
|
||||
|
||||
/*
|
||||
* csThinRectangleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csThinRectangleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csThinRectangleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csThinRectangleDialog::csThinRectangleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csWideRectangleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csWideRectangleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csWideRectangleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csWideRectangleDialog::csWideRectangleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csTriangleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csTriangleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csTriangleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csTriangleDialog::csTriangleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csSemiCircleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csSemiCircleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csSemiCircleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csSemiCircleDialog::csSemiCircleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csCircleDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csCircleDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csCircleDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csCircleDialog::csCircleDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csCircleShadowDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csCircleShadowDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csCircleShadowDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csCircleShadowDialog::csCircleShadowDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csOctagonDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csOctagonDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csOctagonDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csOctagonDialog::csOctagonDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csGroupDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csGroupDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csGroupDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csGroupDialog::csGroupDialog()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* csTextBoxDialog
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(csTextBoxDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(csTextBoxDialog, wxPanel)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csTextBoxDialog::csTextBoxDialog()
|
||||
{
|
||||
}
|
||||
|
||||
|
248
contrib/samples/ogl/studio/dialogs.h
Normal file
@@ -0,0 +1,248 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialogs.h
|
||||
// Purpose: Miscellaneous dialogs
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 12/07/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _STUDIO_DIALOGS_H_
|
||||
#define _STUDIO_DIALOGS_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
/*
|
||||
* Label editing dialog (about to become obsolete)
|
||||
*/
|
||||
|
||||
class csLabelEditingDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS(csLabelEditingDialog)
|
||||
public:
|
||||
csLabelEditingDialog(wxWindow* parent);
|
||||
|
||||
void SetShapeLabel(const wxString& label);
|
||||
inline wxString GetShapeLabel() const { return m_label; }
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
protected:
|
||||
wxString m_label;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* Settings dialog (tabbed)
|
||||
*/
|
||||
|
||||
class csSettingsDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS(csSettingsDialog)
|
||||
public:
|
||||
csSettingsDialog(wxWindow* parent);
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
virtual bool TransferDataToWindow();
|
||||
virtual bool TransferDataFromWindow();
|
||||
|
||||
protected:
|
||||
|
||||
wxPanel* m_generalSettings;
|
||||
wxPanel* m_diagramSettings;
|
||||
wxNotebook* m_notebook;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#define ID_PROPERTY_NOTEBOOK 1000
|
||||
#define ID_GENERAL_SETTINGS 1002
|
||||
#define ID_DIAGRAM_SETTINGS 1003
|
||||
|
||||
/*
|
||||
* csGeneralShapePropertiesDialog
|
||||
* Name, description etc.
|
||||
*/
|
||||
|
||||
class csGeneralShapePropertiesDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csGeneralShapePropertiesDialog)
|
||||
public:
|
||||
csGeneralShapePropertiesDialog();
|
||||
|
||||
void SetShapeLabel(const wxString& label);
|
||||
inline wxString GetShapeLabel() const { return m_label; }
|
||||
|
||||
protected:
|
||||
wxString m_label;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* Shape properties dialog (tabbed)
|
||||
*/
|
||||
|
||||
class csShapePropertiesDialog: public wxDialog
|
||||
{
|
||||
DECLARE_CLASS(csShapePropertiesDialog)
|
||||
public:
|
||||
csShapePropertiesDialog(wxWindow* parent, const wxString& title, wxPanel* attributeDialog, const wxString& attributeDialogName);
|
||||
|
||||
void OnOK(wxCommandEvent& event);
|
||||
|
||||
// Set some suitable defaults in the attribute dialogs (in the first instance,
|
||||
// just set all wxChoices to the first element)
|
||||
void SetDefaults();
|
||||
|
||||
// Accessors
|
||||
csGeneralShapePropertiesDialog* GetGeneralPropertiesDialog() const { return m_generalPropertiesDialog; }
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Attributes, specific to each shape
|
||||
wxPanel* m_attributeDialog;
|
||||
wxPanel* m_alternativeAttributeDialog;
|
||||
|
||||
// General properties, same for each shape, e.g. name/description
|
||||
csGeneralShapePropertiesDialog* m_generalPropertiesDialog;
|
||||
|
||||
wxNotebook* m_notebook;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#define ID_SHAPE_PROPERTY_NOTEBOOK 1000
|
||||
|
||||
//// Specific attribute-editing panel classes below here
|
||||
|
||||
/*
|
||||
* csThinRectangleDialog
|
||||
*/
|
||||
|
||||
class csThinRectangleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csThinRectangleDialog)
|
||||
public:
|
||||
csThinRectangleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csWideRectangleDialog
|
||||
*/
|
||||
|
||||
class csWideRectangleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csWideRectangleDialog)
|
||||
public:
|
||||
csWideRectangleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csTriangleDialog
|
||||
*/
|
||||
|
||||
class csTriangleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csTriangleDialog)
|
||||
public:
|
||||
csTriangleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csSemiCircleDialog
|
||||
*/
|
||||
|
||||
class csSemiCircleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csSemiCircleDialog)
|
||||
public:
|
||||
csSemiCircleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csCircleDialog
|
||||
*/
|
||||
|
||||
class csCircleDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csCircleDialog)
|
||||
public:
|
||||
csCircleDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csCircleShadowDialog
|
||||
*/
|
||||
|
||||
class csCircleShadowDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csCircleShadowDialog)
|
||||
public:
|
||||
csCircleShadowDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csOctagonDialog
|
||||
*/
|
||||
|
||||
class csOctagonDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csOctagonDialog)
|
||||
public:
|
||||
csOctagonDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csGroupDialog
|
||||
*/
|
||||
|
||||
class csGroupDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csGroupDialog)
|
||||
public:
|
||||
csGroupDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* csTextBoxDialog
|
||||
*/
|
||||
|
||||
class csTextBoxDialog: public wxPanel
|
||||
{
|
||||
DECLARE_CLASS(csTextBoxDialog)
|
||||
public:
|
||||
csTextBoxDialog();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
// _STUDIO_DIALOGS_H_
|
598
contrib/samples/ogl/studio/doc.cpp
Normal file
@@ -0,0 +1,598 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: doc.cpp
|
||||
// Purpose: Implements document functionality
|
||||
// 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 <wx/wxprec.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#include <wx/wxexpr.h>
|
||||
|
||||
#include "studio.h"
|
||||
#include "doc.h"
|
||||
#include "view.h"
|
||||
#include <wx/ogl/basicp.h>
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(csDiagramDocument, wxDocument)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4355)
|
||||
#endif
|
||||
|
||||
csDiagramDocument::csDiagramDocument():m_diagram(this)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default:4355)
|
||||
#endif
|
||||
|
||||
csDiagramDocument::~csDiagramDocument()
|
||||
{
|
||||
}
|
||||
|
||||
bool csDiagramDocument::OnCloseDocument()
|
||||
{
|
||||
m_diagram.DeleteAllShapes();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csDiagramDocument::OnSaveDocument(const wxString& file)
|
||||
{
|
||||
if (file == "")
|
||||
return FALSE;
|
||||
|
||||
if (!m_diagram.SaveFile(file))
|
||||
{
|
||||
wxString msgTitle;
|
||||
if (wxTheApp->GetAppName() != "")
|
||||
msgTitle = wxTheApp->GetAppName();
|
||||
else
|
||||
msgTitle = wxString("File error");
|
||||
|
||||
(void)wxMessageBox("Sorry, could not open this file for saving.", msgTitle, wxOK | wxICON_EXCLAMATION,
|
||||
GetDocumentWindow());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Modify(FALSE);
|
||||
SetFilename(file);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csDiagramDocument::OnOpenDocument(const wxString& file)
|
||||
{
|
||||
if (!OnSaveModified())
|
||||
return FALSE;
|
||||
|
||||
wxString msgTitle;
|
||||
if (wxTheApp->GetAppName() != "")
|
||||
msgTitle = wxTheApp->GetAppName();
|
||||
else
|
||||
msgTitle = wxString("File error");
|
||||
|
||||
m_diagram.DeleteAllShapes();
|
||||
if (!m_diagram.LoadFile(file))
|
||||
{
|
||||
(void)wxMessageBox("Sorry, could not open this file.", msgTitle, wxOK|wxICON_EXCLAMATION,
|
||||
GetDocumentWindow());
|
||||
return FALSE;
|
||||
}
|
||||
SetFilename(file, TRUE);
|
||||
Modify(FALSE);
|
||||
UpdateAllViews();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implementation of drawing command
|
||||
*/
|
||||
|
||||
csDiagramCommand::csDiagramCommand(const wxString& name, csDiagramDocument *doc,
|
||||
csCommandState* onlyState):
|
||||
wxCommand(TRUE, name)
|
||||
{
|
||||
m_doc = doc;
|
||||
|
||||
if (onlyState)
|
||||
{
|
||||
AddState(onlyState);
|
||||
}
|
||||
}
|
||||
|
||||
csDiagramCommand::~csDiagramCommand()
|
||||
{
|
||||
wxNode* node = m_states.First();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
delete state;
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
void csDiagramCommand::AddState(csCommandState* state)
|
||||
{
|
||||
state->m_doc = m_doc;
|
||||
// state->m_cmd = m_cmd;
|
||||
m_states.Append(state);
|
||||
}
|
||||
|
||||
// Insert a state at the beginning of the list
|
||||
void csDiagramCommand::InsertState(csCommandState* state)
|
||||
{
|
||||
state->m_doc = m_doc;
|
||||
// state->m_cmd = m_cmd;
|
||||
m_states.Insert(state);
|
||||
}
|
||||
|
||||
// Schedule all lines connected to the states to be cut.
|
||||
void csDiagramCommand::RemoveLines()
|
||||
{
|
||||
wxNode* node = m_states.First();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
wxShape* shape = state->GetShapeOnCanvas();
|
||||
wxASSERT( (shape != NULL) );
|
||||
|
||||
wxNode *node1 = shape->GetLines().First();
|
||||
while (node1)
|
||||
{
|
||||
wxLineShape *line = (wxLineShape *)node1->Data();
|
||||
if (!FindStateByShape(line))
|
||||
{
|
||||
csCommandState* newState = new csCommandState(ID_CS_CUT, NULL, line);
|
||||
InsertState(newState);
|
||||
}
|
||||
|
||||
node1 = node1->Next();
|
||||
}
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
csCommandState* csDiagramCommand::FindStateByShape(wxShape* shape)
|
||||
{
|
||||
wxNode* node = m_states.First();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
if (shape == state->GetShapeOnCanvas() || shape == state->GetSavedState())
|
||||
return state;
|
||||
node = node->Next();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool csDiagramCommand::Do()
|
||||
{
|
||||
wxNode* node = m_states.First();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
if (!state->Do())
|
||||
return FALSE;
|
||||
node = node->Next();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csDiagramCommand::Undo()
|
||||
{
|
||||
// Undo in reverse order, so e.g. shapes get added
|
||||
// back before the lines do.
|
||||
wxNode* node = m_states.Last();
|
||||
while (node)
|
||||
{
|
||||
csCommandState* state = (csCommandState*) node->Data();
|
||||
if (!state->Undo())
|
||||
return FALSE;
|
||||
node = node->Previous();
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
csCommandState::csCommandState(int cmd, wxShape* savedState, wxShape* shapeOnCanvas)
|
||||
{
|
||||
m_cmd = cmd;
|
||||
m_doc = NULL;
|
||||
m_savedState = savedState;
|
||||
m_shapeOnCanvas = shapeOnCanvas;
|
||||
m_linePositionFrom = 0;
|
||||
m_linePositionTo = 0;
|
||||
}
|
||||
|
||||
csCommandState::~csCommandState()
|
||||
{
|
||||
if (m_savedState)
|
||||
{
|
||||
m_savedState->SetCanvas(NULL);
|
||||
delete m_savedState;
|
||||
}
|
||||
}
|
||||
|
||||
bool csCommandState::Do()
|
||||
{
|
||||
switch (m_cmd)
|
||||
{
|
||||
case ID_CS_CUT:
|
||||
{
|
||||
// New state is 'nothing' - maybe pass shape ID to state so we know what
|
||||
// we're talking about.
|
||||
// Then save old shape in m_savedState (actually swap pointers)
|
||||
|
||||
wxASSERT( (m_shapeOnCanvas != NULL) );
|
||||
wxASSERT( (m_savedState == NULL) ); // new state will be 'nothing'
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
wxShapeCanvas* canvas = m_shapeOnCanvas->GetCanvas();
|
||||
|
||||
// In case this is a line
|
||||
wxShape* lineFrom = NULL;
|
||||
wxShape* lineTo = NULL;
|
||||
int attachmentFrom = 0, attachmentTo = 0;
|
||||
|
||||
if (m_shapeOnCanvas->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
// Store the from/to info to save in the line shape
|
||||
wxLineShape* lineShape = (wxLineShape*) m_shapeOnCanvas;
|
||||
lineFrom = lineShape->GetFrom();
|
||||
lineTo = lineShape->GetTo();
|
||||
attachmentFrom = lineShape->GetAttachmentFrom();
|
||||
attachmentTo = lineShape->GetAttachmentTo();
|
||||
|
||||
m_linePositionFrom = lineFrom->GetLinePosition(lineShape);
|
||||
m_linePositionTo = lineTo->GetLinePosition(lineShape);
|
||||
}
|
||||
|
||||
m_shapeOnCanvas->Select(FALSE);
|
||||
((csDiagramView*) m_doc->GetFirstView())->SelectShape(m_shapeOnCanvas, FALSE);
|
||||
|
||||
m_shapeOnCanvas->Unlink();
|
||||
|
||||
m_doc->GetDiagram()->RemoveShape(m_shapeOnCanvas);
|
||||
|
||||
m_savedState = m_shapeOnCanvas;
|
||||
|
||||
if (m_savedState->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
// Restore the from/to info for future reference
|
||||
wxLineShape* lineShape = (wxLineShape*) m_savedState;
|
||||
lineShape->SetFrom(lineFrom);
|
||||
lineShape->SetTo(lineTo);
|
||||
lineShape->SetAttachments(attachmentFrom, attachmentTo);
|
||||
|
||||
wxClientDC dc(canvas);
|
||||
canvas->PrepareDC(dc);
|
||||
|
||||
lineFrom->MoveLinks(dc);
|
||||
lineTo->MoveLinks(dc);
|
||||
}
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_ADD_SHAPE:
|
||||
case ID_CS_ADD_SHAPE_SELECT:
|
||||
{
|
||||
// The app has given the command state a new m_savedState
|
||||
// shape, which is the new shape to add to the canvas (but
|
||||
// not actually added until this point).
|
||||
// The new 'saved state' is therefore 'nothing' since there
|
||||
// was nothing there before.
|
||||
|
||||
wxASSERT( (m_shapeOnCanvas == NULL) );
|
||||
wxASSERT( (m_savedState != NULL) );
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
m_shapeOnCanvas = m_savedState;
|
||||
m_savedState = NULL;
|
||||
|
||||
m_doc->GetDiagram()->AddShape(m_shapeOnCanvas);
|
||||
m_shapeOnCanvas->Show(TRUE);
|
||||
|
||||
wxClientDC dc(m_shapeOnCanvas->GetCanvas());
|
||||
m_shapeOnCanvas->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
csEvtHandler *handler = (csEvtHandler *)m_shapeOnCanvas->GetEventHandler();
|
||||
m_shapeOnCanvas->FormatText(dc, handler->m_label);
|
||||
|
||||
m_shapeOnCanvas->Move(dc, m_shapeOnCanvas->GetX(), m_shapeOnCanvas->GetY());
|
||||
|
||||
if (m_cmd == ID_CS_ADD_SHAPE_SELECT)
|
||||
{
|
||||
m_shapeOnCanvas->Select(TRUE, &dc);
|
||||
((csDiagramView*) m_doc->GetFirstView())->SelectShape(m_shapeOnCanvas, TRUE);
|
||||
}
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_ADD_LINE:
|
||||
case ID_CS_ADD_LINE_SELECT:
|
||||
{
|
||||
wxASSERT( (m_shapeOnCanvas == NULL) );
|
||||
wxASSERT( (m_savedState != NULL) );
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
wxLineShape *lineShape = (wxLineShape *)m_savedState;
|
||||
wxASSERT( (lineShape->GetFrom() != NULL) );
|
||||
wxASSERT( (lineShape->GetTo() != NULL) );
|
||||
|
||||
m_shapeOnCanvas = m_savedState;
|
||||
m_savedState = NULL;
|
||||
|
||||
m_doc->GetDiagram()->AddShape(lineShape);
|
||||
|
||||
lineShape->GetFrom()->AddLine(lineShape, lineShape->GetTo(),
|
||||
lineShape->GetAttachmentFrom(), lineShape->GetAttachmentTo());
|
||||
|
||||
lineShape->Show(TRUE);
|
||||
|
||||
wxClientDC dc(lineShape->GetCanvas());
|
||||
lineShape->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
// It won't get drawn properly unless you move both
|
||||
// connected images
|
||||
lineShape->GetFrom()->Move(dc, lineShape->GetFrom()->GetX(), lineShape->GetFrom()->GetY());
|
||||
lineShape->GetTo()->Move(dc, lineShape->GetTo()->GetX(), lineShape->GetTo()->GetY());
|
||||
|
||||
if (m_cmd == ID_CS_ADD_LINE_SELECT)
|
||||
{
|
||||
lineShape->Select(TRUE, &dc);
|
||||
((csDiagramView*) m_doc->GetFirstView())->SelectShape(m_shapeOnCanvas, TRUE);
|
||||
}
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_CHANGE_BACKGROUND_COLOUR:
|
||||
case ID_CS_MOVE:
|
||||
case ID_CS_SIZE:
|
||||
case ID_CS_EDIT_PROPERTIES:
|
||||
case ID_CS_FONT_CHANGE:
|
||||
case ID_CS_ARROW_CHANGE:
|
||||
case ID_CS_ROTATE_CLOCKWISE:
|
||||
case ID_CS_ROTATE_ANTICLOCKWISE:
|
||||
case ID_CS_CHANGE_LINE_ORDERING:
|
||||
case ID_CS_CHANGE_LINE_ATTACHMENT:
|
||||
case ID_CS_ALIGN:
|
||||
case ID_CS_NEW_POINT:
|
||||
case ID_CS_CUT_POINT:
|
||||
case ID_CS_MOVE_LINE_POINT:
|
||||
case ID_CS_STRAIGHTEN:
|
||||
case ID_CS_MOVE_LABEL:
|
||||
{
|
||||
// At this point we have been given a new shape
|
||||
// just like the old one but with a changed colour.
|
||||
// It's now time to apply that change to the
|
||||
// shape on the canvas, saving the old state.
|
||||
// NOTE: this is general enough to work with MOST attribute
|
||||
// changes!
|
||||
|
||||
wxASSERT( (m_shapeOnCanvas != NULL) );
|
||||
wxASSERT( (m_savedState != NULL) ); // This is the new shape with changed colour
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
wxClientDC dc(m_shapeOnCanvas->GetCanvas());
|
||||
m_shapeOnCanvas->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
bool isSelected = m_shapeOnCanvas->Selected();
|
||||
if (isSelected)
|
||||
m_shapeOnCanvas->Select(FALSE, & dc);
|
||||
|
||||
if (m_cmd == ID_CS_SIZE || m_cmd == ID_CS_ROTATE_CLOCKWISE || m_cmd == ID_CS_ROTATE_ANTICLOCKWISE ||
|
||||
m_cmd == ID_CS_CHANGE_LINE_ORDERING || m_cmd == ID_CS_CHANGE_LINE_ATTACHMENT)
|
||||
{
|
||||
m_shapeOnCanvas->Erase(dc);
|
||||
}
|
||||
|
||||
// TODO: make sure the ID is the same. Or, when applying the new state,
|
||||
// don't change the original ID.
|
||||
wxShape* tempShape = m_shapeOnCanvas->CreateNewCopy();
|
||||
|
||||
// Apply the saved state to the shape on the canvas, by copying.
|
||||
m_savedState->CopyWithHandler(*m_shapeOnCanvas);
|
||||
|
||||
// Delete this state now it's been used (m_shapeOnCanvas currently holds this state)
|
||||
delete m_savedState;
|
||||
|
||||
// Remember the previous state
|
||||
m_savedState = tempShape;
|
||||
|
||||
// Redraw the shape
|
||||
|
||||
if (m_cmd == ID_CS_MOVE || m_cmd == ID_CS_ROTATE_CLOCKWISE || m_cmd == ID_CS_ROTATE_ANTICLOCKWISE ||
|
||||
m_cmd == ID_CS_ALIGN)
|
||||
{
|
||||
m_shapeOnCanvas->Move(dc, m_shapeOnCanvas->GetX(), m_shapeOnCanvas->GetY());
|
||||
|
||||
csEvtHandler *handler = (csEvtHandler *)m_shapeOnCanvas->GetEventHandler();
|
||||
m_shapeOnCanvas->FormatText(dc, handler->m_label);
|
||||
m_shapeOnCanvas->Draw(dc);
|
||||
}
|
||||
else if (m_cmd == ID_CS_CHANGE_LINE_ORDERING)
|
||||
{
|
||||
m_shapeOnCanvas->MoveLinks(dc);
|
||||
}
|
||||
else if (m_cmd == ID_CS_CHANGE_LINE_ATTACHMENT)
|
||||
{
|
||||
wxLineShape *lineShape = (wxLineShape *)m_shapeOnCanvas;
|
||||
|
||||
// Have to move both sets of links since we don't know which links
|
||||
// have been affected (unless we compared before and after states).
|
||||
lineShape->GetFrom()->MoveLinks(dc);
|
||||
lineShape->GetTo()->MoveLinks(dc);
|
||||
}
|
||||
else if (m_cmd == ID_CS_SIZE)
|
||||
{
|
||||
double width, height;
|
||||
m_shapeOnCanvas->GetBoundingBoxMax(&width, &height);
|
||||
|
||||
m_shapeOnCanvas->SetSize(width, height);
|
||||
m_shapeOnCanvas->Move(dc, m_shapeOnCanvas->GetX(), m_shapeOnCanvas->GetY());
|
||||
|
||||
m_shapeOnCanvas->Show(TRUE);
|
||||
|
||||
// Recursively redraw links if we have a composite.
|
||||
if (m_shapeOnCanvas->GetChildren().Number() > 0)
|
||||
m_shapeOnCanvas->DrawLinks(dc, -1, TRUE);
|
||||
|
||||
m_shapeOnCanvas->GetEventHandler()->OnEndSize(width, height);
|
||||
}
|
||||
else if (m_cmd == ID_CS_EDIT_PROPERTIES || m_cmd == ID_CS_FONT_CHANGE)
|
||||
{
|
||||
csEvtHandler *handler = (csEvtHandler *)m_shapeOnCanvas->GetEventHandler();
|
||||
m_shapeOnCanvas->FormatText(dc, handler->m_label);
|
||||
m_shapeOnCanvas->Draw(dc);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_shapeOnCanvas->Draw(dc);
|
||||
}
|
||||
|
||||
if (isSelected)
|
||||
m_shapeOnCanvas->Select(TRUE, & dc);
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool csCommandState::Undo()
|
||||
{
|
||||
switch (m_cmd)
|
||||
{
|
||||
case ID_CS_CUT:
|
||||
{
|
||||
wxASSERT( (m_savedState != NULL) );
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
m_doc->GetDiagram()->AddShape(m_savedState);
|
||||
m_shapeOnCanvas = m_savedState;
|
||||
m_savedState = NULL;
|
||||
|
||||
if (m_shapeOnCanvas->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
wxLineShape* lineShape = (wxLineShape*) m_shapeOnCanvas;
|
||||
lineShape->GetFrom()->AddLine(lineShape, lineShape->GetTo(),
|
||||
lineShape->GetAttachmentFrom(), lineShape->GetAttachmentTo(),
|
||||
m_linePositionFrom, m_linePositionTo);
|
||||
|
||||
wxShapeCanvas* canvas = lineShape->GetFrom()->GetCanvas();
|
||||
|
||||
wxClientDC dc(canvas);
|
||||
canvas->PrepareDC(dc);
|
||||
|
||||
lineShape->GetFrom()->MoveLinks(dc);
|
||||
lineShape->GetTo()->MoveLinks(dc);
|
||||
|
||||
}
|
||||
m_shapeOnCanvas->Show(TRUE);
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_ADD_SHAPE:
|
||||
case ID_CS_ADD_LINE:
|
||||
case ID_CS_ADD_SHAPE_SELECT:
|
||||
case ID_CS_ADD_LINE_SELECT:
|
||||
{
|
||||
wxASSERT( (m_shapeOnCanvas != NULL) );
|
||||
wxASSERT( (m_savedState == NULL) );
|
||||
wxASSERT( (m_doc != NULL) );
|
||||
|
||||
// In case this is a line
|
||||
wxShape* lineFrom = NULL;
|
||||
wxShape* lineTo = NULL;
|
||||
int attachmentFrom = 0, attachmentTo = 0;
|
||||
|
||||
if (m_shapeOnCanvas->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
// Store the from/to info to save in the line shape
|
||||
wxLineShape* lineShape = (wxLineShape*) m_shapeOnCanvas;
|
||||
lineFrom = lineShape->GetFrom();
|
||||
lineTo = lineShape->GetTo();
|
||||
attachmentFrom = lineShape->GetAttachmentFrom();
|
||||
attachmentTo = lineShape->GetAttachmentTo();
|
||||
}
|
||||
|
||||
wxClientDC dc(m_shapeOnCanvas->GetCanvas());
|
||||
m_shapeOnCanvas->GetCanvas()->PrepareDC(dc);
|
||||
|
||||
m_shapeOnCanvas->Select(FALSE, &dc);
|
||||
((csDiagramView*) m_doc->GetFirstView())->SelectShape(m_shapeOnCanvas, FALSE);
|
||||
m_doc->GetDiagram()->RemoveShape(m_shapeOnCanvas);
|
||||
m_shapeOnCanvas->Unlink(); // Unlinks the line, if it is a line
|
||||
|
||||
if (m_shapeOnCanvas->IsKindOf(CLASSINFO(wxLineShape)))
|
||||
{
|
||||
// Restore the from/to info for future reference
|
||||
wxLineShape* lineShape = (wxLineShape*) m_shapeOnCanvas;
|
||||
lineShape->SetFrom(lineFrom);
|
||||
lineShape->SetTo(lineTo);
|
||||
lineShape->SetAttachments(attachmentFrom, attachmentTo);
|
||||
}
|
||||
|
||||
m_savedState = m_shapeOnCanvas;
|
||||
m_shapeOnCanvas = NULL;
|
||||
|
||||
m_doc->Modify(TRUE);
|
||||
m_doc->UpdateAllViews();
|
||||
break;
|
||||
}
|
||||
case ID_CS_CHANGE_BACKGROUND_COLOUR:
|
||||
case ID_CS_MOVE:
|
||||
case ID_CS_SIZE:
|
||||
case ID_CS_EDIT_PROPERTIES:
|
||||
case ID_CS_FONT_CHANGE:
|
||||
case ID_CS_ARROW_CHANGE:
|
||||
case ID_CS_ROTATE_CLOCKWISE:
|
||||
case ID_CS_ROTATE_ANTICLOCKWISE:
|
||||
case ID_CS_CHANGE_LINE_ORDERING:
|
||||
case ID_CS_CHANGE_LINE_ATTACHMENT:
|
||||
case ID_CS_ALIGN:
|
||||
case ID_CS_NEW_POINT:
|
||||
case ID_CS_CUT_POINT:
|
||||
case ID_CS_MOVE_LINE_POINT:
|
||||
case ID_CS_STRAIGHTEN:
|
||||
case ID_CS_MOVE_LABEL:
|
||||
{
|
||||
// Exactly like the Do case; we're just swapping states.
|
||||
Do();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
134
contrib/samples/ogl/studio/doc.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// 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 _STUDIO_DOC_H_
|
||||
#define _STUDIO_DOC_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
// #pragma interface
|
||||
#endif
|
||||
|
||||
#include <wx/docview.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/wxexpr.h>
|
||||
|
||||
#include <wx/ogl/ogl.h>
|
||||
#include "shapes.h"
|
||||
|
||||
/*
|
||||
* A diagram document, which contains a diagram.
|
||||
*/
|
||||
|
||||
class csDiagramDocument: public wxDocument
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(csDiagramDocument)
|
||||
public:
|
||||
csDiagramDocument();
|
||||
~csDiagramDocument();
|
||||
|
||||
bool OnSaveDocument(const wxString& file);
|
||||
bool OnOpenDocument(const wxString& file);
|
||||
|
||||
inline wxDiagram *GetDiagram() { return &m_diagram; }
|
||||
|
||||
bool OnCloseDocument();
|
||||
|
||||
protected:
|
||||
csDiagram m_diagram;
|
||||
};
|
||||
|
||||
/*
|
||||
Do/Undo 30/7/98
|
||||
|
||||
1) We have a csCommandState, and in csDiagramCommand you have a list of
|
||||
these. This allows undo to work with several shapes at once.
|
||||
|
||||
2) Instead of storing info about each operation, e.g. separate pens, colours,
|
||||
etc., we simply use a copy of the shape.
|
||||
In csCommandState, we have a pointer to the actual shape in the canvas, m_currentShape.
|
||||
We also have wxShape* m_shapeState which stores the requested or previous state
|
||||
(depending on whether it's before the Do or after the Do.
|
||||
|
||||
- In Do: save a temp copy of the old m_currentShape (i.e. the state just before it's changed).
|
||||
Change the data pointed to by m_currentShape to the new attributes stored in m_shapeState.
|
||||
Now assign the temp copy to m_shapeState, for use in Undo.
|
||||
|
||||
wxShape* temp = m_currentShape->Copy(); // Take a copy of the current state
|
||||
m_currentShape->Set(m_shapeState); // Apply the new state (e.g. moving, changing colour etc.)
|
||||
delete m_shapeState; // Delete the previous 'old state'.
|
||||
m_shapeState = temp; // Remember the new 'old state'.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class csCommandState;
|
||||
class csDiagramCommand: public wxCommand
|
||||
{
|
||||
friend class csCommandState;
|
||||
public:
|
||||
// Multi-purpose constructor for creating, deleting shapes
|
||||
csDiagramCommand(const wxString& name, csDiagramDocument *doc,
|
||||
csCommandState* onlyState = NULL); // Allow for the common case of just one state to change
|
||||
|
||||
~csDiagramCommand();
|
||||
|
||||
bool Do();
|
||||
bool Undo();
|
||||
|
||||
// Add a state to the end of the list
|
||||
void AddState(csCommandState* state);
|
||||
|
||||
// Insert a state at the beginning of the list
|
||||
void InsertState(csCommandState* state);
|
||||
|
||||
// Schedule all lines connected to the states to be cut.
|
||||
void RemoveLines();
|
||||
|
||||
// Find the state that refers to this shape
|
||||
csCommandState* FindStateByShape(wxShape* shape);
|
||||
|
||||
wxList& GetStates() const { return (wxList&) m_states; }
|
||||
|
||||
protected:
|
||||
csDiagramDocument* m_doc;
|
||||
wxList m_states;
|
||||
};
|
||||
|
||||
class csCommandState: public wxObject
|
||||
{
|
||||
friend class csDiagramCommand;
|
||||
public:
|
||||
csCommandState(int cmd, wxShape* savedState, wxShape* shapeOnCanvas);
|
||||
~csCommandState();
|
||||
|
||||
bool Do();
|
||||
bool Undo();
|
||||
|
||||
inline void SetSavedState(wxShape *s) { m_savedState = s; }
|
||||
inline wxShape *GetSavedState() const { return m_savedState; }
|
||||
|
||||
inline void SetShapeOnCanvas(wxShape *s) { m_shapeOnCanvas = s; }
|
||||
inline wxShape *GetShapeOnCanvas() const { return m_shapeOnCanvas; }
|
||||
protected:
|
||||
wxShape* m_savedState; // Previous state, for restoring on Undo
|
||||
wxShape* m_shapeOnCanvas; // The actual shape on the canvas
|
||||
csDiagramDocument* m_doc;
|
||||
int m_cmd;
|
||||
|
||||
// These store the line ordering for the shapes at either end,
|
||||
// so an un-cut line can restore the ordering properly. Otherwise
|
||||
// it just adds the line at an arbitrary position.
|
||||
int m_linePositionFrom;
|
||||
int m_linePositionTo;
|
||||
};
|
||||
|
||||
#endif
|
||||
// _STUDIO_DOC_H_
|
276
contrib/samples/ogl/studio/mainfrm.cpp
Normal file
@@ -0,0 +1,276 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mainfrm.cpp
|
||||
// Purpose: Studio main frame
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 27/7/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#include "wx/mdi.h"
|
||||
#endif
|
||||
|
||||
#include "wx/laywin.h"
|
||||
|
||||
#include "studio.h"
|
||||
#include "view.h"
|
||||
#include "doc.h"
|
||||
#include "cspalette.h"
|
||||
#include "mainfrm.h"
|
||||
#include "dialogs.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(csFrame, wxDocMDIParentFrame)
|
||||
EVT_MENU(ID_CS_ABOUT, csFrame::OnAbout)
|
||||
EVT_MENU(wxID_EXIT, csFrame::OnQuit)
|
||||
EVT_MENU(wxID_HELP, csFrame::OnHelp)
|
||||
EVT_MENU(ID_CS_SETTINGS, csFrame::OnSettings)
|
||||
EVT_SIZE(csFrame::OnSize)
|
||||
EVT_SASH_DRAGGED(ID_LAYOUT_WINDOW_PALETTE, csFrame::OnSashDragPaletteWindow)
|
||||
EVT_SASH_DRAGGED(ID_LAYOUT_WINDOW_PROJECT, csFrame::OnSashDragProjectWindow)
|
||||
EVT_IDLE(csFrame::OnIdle)
|
||||
EVT_UPDATE_UI(wxID_PRINT, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_PREVIEW, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_SAVE, csFrame::OnSaveUpdate)
|
||||
EVT_UPDATE_UI(wxID_SAVEAS, csFrame::OnSaveUpdate)
|
||||
EVT_UPDATE_UI(wxID_UNDO, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_REDO, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_CUT, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_COPY, csFrame::OnUpdateDisable)
|
||||
EVT_UPDATE_UI(wxID_PASTE, csFrame::OnUpdateDisable)
|
||||
EVT_CLOSE(csFrame::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
// Define my frame constructor
|
||||
csFrame::csFrame(wxDocManager* manager, wxFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
|
||||
long style):
|
||||
wxDocMDIParentFrame(manager, parent, id, title, pos, size, style, "frame")
|
||||
{
|
||||
CreateToolBar(wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL);
|
||||
wxGetApp().InitToolBar(GetToolBar());
|
||||
|
||||
// Accelerators
|
||||
wxAcceleratorEntry entries[4];
|
||||
|
||||
entries[0].Set(wxACCEL_NORMAL, WXK_F1, wxID_HELP);
|
||||
entries[1].Set(wxACCEL_CTRL, 'O', wxID_OPEN);
|
||||
entries[2].Set(wxACCEL_CTRL, 'N', wxID_NEW);
|
||||
entries[3].Set(wxACCEL_CTRL, 'P', wxID_PRINT);
|
||||
|
||||
wxAcceleratorTable accel(4, entries);
|
||||
SetAcceleratorTable(accel);
|
||||
}
|
||||
|
||||
void csFrame::OnHelp(wxCommandEvent& event)
|
||||
{
|
||||
wxGetApp().GetHelpController().DisplayContents();
|
||||
}
|
||||
|
||||
void csFrame::OnSettings(wxCommandEvent& event)
|
||||
{
|
||||
csSettingsDialog* dialog = new csSettingsDialog(this);
|
||||
int ret = dialog->ShowModal();
|
||||
dialog->Destroy();
|
||||
}
|
||||
|
||||
void csFrame::OnQuit(wxCommandEvent& event)
|
||||
{
|
||||
Close(TRUE);
|
||||
}
|
||||
|
||||
void csFrame::OnAbout(wxCommandEvent& event)
|
||||
{
|
||||
(void)wxMessageBox("OGL Studio\n(c) 1999, Julian Smart", "About OGL Studio", wxICON_INFORMATION);
|
||||
}
|
||||
|
||||
void csFrame::OnSashDragPaletteWindow(wxSashEvent& event)
|
||||
{
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_LAYOUT_WINDOW_PALETTE:
|
||||
{
|
||||
wxGetApp().GetDiagramPaletteSashWindow()->SetDefaultSize(wxSize(10000, event.GetDragRect().height));
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
}
|
||||
|
||||
void csFrame::OnSashDragProjectWindow(wxSashEvent& event)
|
||||
{
|
||||
if (event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE)
|
||||
return;
|
||||
|
||||
switch (event.GetId())
|
||||
{
|
||||
case ID_LAYOUT_WINDOW_PROJECT:
|
||||
{
|
||||
wxGetApp().GetProjectSashWindow()->SetDefaultSize(wxSize(event.GetDragRect().width, 10000));
|
||||
break;
|
||||
}
|
||||
}
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
}
|
||||
|
||||
// Define the behaviour for the frame closing
|
||||
// - must delete all frames except for the main one.
|
||||
void csFrame::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
int x, y;
|
||||
GetPosition(& x, & y);
|
||||
wxGetApp().m_mainFramePos = wxPoint(x, y);
|
||||
|
||||
GetSize(& x, & y);
|
||||
wxGetApp().m_mainFrameSize = wxSize(x, y);
|
||||
|
||||
wxDocMDIParentFrame::OnCloseWindow(event);
|
||||
}
|
||||
|
||||
void csFrame::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
}
|
||||
|
||||
// Make sure the correct toolbars are showing for the active view
|
||||
void csFrame::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
wxDocMDIParentFrame::OnIdle(event);
|
||||
|
||||
wxSashLayoutWindow* paletteWin = wxGetApp().GetDiagramPaletteSashWindow();
|
||||
wxSashLayoutWindow* diagramToolBarWin = wxGetApp().GetDiagramToolBarSashWindow();
|
||||
if (!paletteWin || !diagramToolBarWin)
|
||||
return;
|
||||
bool doLayout = FALSE;
|
||||
if (GetActiveChild())
|
||||
{
|
||||
if (!paletteWin->IsShown() || !diagramToolBarWin->IsShown())
|
||||
{
|
||||
paletteWin->Show(TRUE);
|
||||
diagramToolBarWin->Show(TRUE);
|
||||
|
||||
doLayout = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (paletteWin->IsShown() || diagramToolBarWin->IsShown())
|
||||
{
|
||||
paletteWin->Show(FALSE);
|
||||
diagramToolBarWin->Show(FALSE);
|
||||
doLayout = TRUE;
|
||||
}
|
||||
}
|
||||
if (doLayout)
|
||||
{
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame(this);
|
||||
|
||||
#if defined(__WXMSW__) && defined(__WIN95__)
|
||||
// Need to do something else to get it to refresh properly
|
||||
// when a client frame is first displayed; moving the client
|
||||
// window doesn't cause the proper refresh. Just refreshing the
|
||||
// client doesn't work (presumably because it's clipping the
|
||||
// children).
|
||||
// FIXED in wxWindows, by intercepting wxMDIClientWindow::DoSetSize
|
||||
// and checking if the position has changed, before redrawing the
|
||||
// child windows.
|
||||
#if 0
|
||||
wxMDIChildFrame* childFrame = GetActiveChild();
|
||||
if (childFrame)
|
||||
{
|
||||
HWND hWnd = (HWND) childFrame->GetHWND();
|
||||
::RedrawWindow(hWnd, NULL, NULL, RDW_FRAME|RDW_ALLCHILDREN|RDW_INVALIDATE );
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// General handler for disabling items
|
||||
void csFrame::OnUpdateDisable(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable(FALSE);
|
||||
}
|
||||
|
||||
void csFrame::OnSaveUpdate(wxUpdateUIEvent& event)
|
||||
{
|
||||
event.Enable( (GetActiveChild() != NULL) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Child frame
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE(csMDIChildFrame, wxDocMDIChildFrame)
|
||||
EVT_ACTIVATE(csMDIChildFrame::OnActivate)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
csMDIChildFrame::csMDIChildFrame(wxDocument* doc, wxView* view, wxMDIParentFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
|
||||
wxDocMDIChildFrame(doc, view, parent, id, title, pos, size, style)
|
||||
{
|
||||
// Accelerators
|
||||
wxAcceleratorEntry entries[18];
|
||||
|
||||
// Usual editing functions
|
||||
entries[0].Set(wxACCEL_NORMAL, WXK_DELETE, wxID_CLEAR);
|
||||
entries[1].Set(wxACCEL_CTRL, 'X', wxID_CUT);
|
||||
entries[2].Set(wxACCEL_CTRL, 'C', wxID_COPY);
|
||||
entries[3].Set(wxACCEL_SHIFT, WXK_INSERT, wxID_PASTE);
|
||||
entries[4].Set(wxACCEL_CTRL, 'V', wxID_PASTE);
|
||||
entries[5].Set(wxACCEL_CTRL, 'A', ID_CS_SELECT_ALL);
|
||||
|
||||
// Undo/redo
|
||||
entries[6].Set(wxACCEL_CTRL, 'Z', wxID_UNDO);
|
||||
entries[7].Set(wxACCEL_CTRL, 'Y', wxID_REDO);
|
||||
|
||||
// Other
|
||||
entries[8].Set(wxACCEL_NORMAL, WXK_RETURN, ID_CS_EDIT_PROPERTIES);
|
||||
entries[9].Set(wxACCEL_ALT, WXK_RETURN, ID_CS_EDIT_PROPERTIES);
|
||||
entries[10].Set(wxACCEL_CTRL, 'D', wxID_DUPLICATE);
|
||||
entries[11].Set(wxACCEL_NORMAL, WXK_F1, wxID_HELP);
|
||||
|
||||
// File handling
|
||||
entries[12].Set(wxACCEL_CTRL, 'S', wxID_SAVE);
|
||||
entries[13].Set(wxACCEL_NORMAL, WXK_F12, wxID_SAVEAS);
|
||||
entries[14].Set(wxACCEL_CTRL, 'O', wxID_OPEN);
|
||||
entries[15].Set(wxACCEL_CTRL, 'N', wxID_NEW);
|
||||
entries[16].Set(wxACCEL_CTRL, 'P', wxID_PRINT);
|
||||
entries[17].Set(wxACCEL_CTRL, 'W', wxID_CLOSE);
|
||||
|
||||
|
||||
wxAcceleratorTable accel(18, entries);
|
||||
SetAcceleratorTable(accel);
|
||||
}
|
||||
|
||||
void csMDIChildFrame::OnActivate(wxActivateEvent& event)
|
||||
{
|
||||
wxDocMDIChildFrame::OnActivate(event);
|
||||
/*
|
||||
wxSashLayoutWindow* win = wxGetApp().GetDiagramPaletteSashWindow();
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
win->Show(event.GetActive());
|
||||
|
||||
wxLayoutAlgorithm layout;
|
||||
layout.LayoutMDIFrame((wxMDIParentFrame*) GetParent());
|
||||
*/
|
||||
}
|
||||
|
55
contrib/samples/ogl/studio/mainfrm.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: mainfrm.h
|
||||
// Purpose: Studio main window class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 27/7/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _STUDIO_MAINFRM_H_
|
||||
#define _STUDIO_MAINFRM_H_
|
||||
|
||||
#include <wx/docmdi.h>
|
||||
|
||||
class wxSashLayoutWindow;
|
||||
class wxSashEvent;
|
||||
|
||||
class csFrame: public wxDocMDIParentFrame
|
||||
{
|
||||
public:
|
||||
csFrame(wxDocManager *manager, wxFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style);
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
void OnSize(wxSizeEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
void OnNewWindow(wxCommandEvent& event);
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnSashDragPaletteWindow(wxSashEvent& event);
|
||||
void OnSashDragProjectWindow(wxSashEvent& event);
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
void OnHelp(wxCommandEvent& event);
|
||||
void OnSettings(wxCommandEvent& event);
|
||||
|
||||
// General handler for disabling items
|
||||
void OnUpdateDisable(wxUpdateUIEvent& event);
|
||||
void OnSaveUpdate(wxUpdateUIEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class csMDIChildFrame: public wxDocMDIChildFrame
|
||||
{
|
||||
public:
|
||||
csMDIChildFrame(wxDocument* doc, wxView* view, wxMDIParentFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style);
|
||||
|
||||
void OnActivate(wxActivateEvent& event);
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
// _STUDIO_MAINFRM_H_
|
||||
|
18
contrib/samples/ogl/studio/makefile.b32
Normal file
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# File: makefile.b32
|
||||
# Author: Julian Smart
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright:
|
||||
#
|
||||
# Makefile : Builds sample for 32-bit BC++
|
||||
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
TARGET=studio
|
||||
EXTRALIBS=$(WXDIR)\contrib\lib\ogl.lib
|
||||
OBJECTS = $(TARGET).obj doc.obj shapes.obj symbols.obj view.obj cspalette.obj\
|
||||
mainfrm.obj project.obj dialogs.obj csprint.obj
|
||||
|
||||
!include $(WXDIR)\src\makeprog.b32
|
||||
|