1
//////////////////////////////////////////////////////////////////////////
3
// pgAdmin III - PostgreSQL Tools
5
// Portions Copyright (C) 1998 - 2011, Julian Smart
6
// Portions Copyright (C) 2011, The pgAdmin Development Team
7
// This software is released under the PostgreSQL Licence
9
// composit.cpp - Composite OGL class
11
//////////////////////////////////////////////////////////////////////////
18
// Sometimes, objects need to access the whole database to
19
// construct themselves.
20
wxExprDatabase *GlobalwxExprDatabase = NULL;
24
* Division control point
27
class wxDivisionControlPoint: public wxControlPoint
29
DECLARE_DYNAMIC_CLASS(wxDivisionControlPoint)
31
wxDivisionControlPoint() {}
32
wxDivisionControlPoint(wxShapeCanvas *the_canvas, wxShape *object, double size, double the_xoffset, double the_yoffset, int the_type);
33
~wxDivisionControlPoint();
35
void OnDragLeft(bool draw, double x, double y, int keys = 0, int attachment = 0);
36
void OnBeginDragLeft(double x, double y, int keys = 0, int attachment = 0);
37
void OnEndDragLeft(double x, double y, int keys = 0, int attachment = 0);
40
IMPLEMENT_DYNAMIC_CLASS(wxDivisionControlPoint, wxControlPoint)
47
IMPLEMENT_DYNAMIC_CLASS(wxCompositeShape, wxRectangleShape)
49
wxCompositeShape::wxCompositeShape(): wxRectangleShape(10.0, 10.0)
51
// selectable = FALSE;
56
wxCompositeShape::~wxCompositeShape()
58
wxNode *node = m_constraints.GetFirst();
61
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
63
node = node->GetNext();
65
node = m_children.GetFirst();
68
wxShape *object = (wxShape *)node->GetData();
69
wxNode *next = node->GetNext();
76
void wxCompositeShape::OnDraw(wxDC &dc)
78
double x1 = (double)(m_xpos - m_width / 2.0);
79
double y1 = (double)(m_ypos - m_height / 2.0);
81
if (m_shadowMode != SHADOW_NONE)
84
dc.SetBrush(* m_shadowBrush);
85
dc.SetPen(* g_oglTransparentPen);
87
if (m_cornerRadius != 0.0)
88
dc.DrawRoundedRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY),
89
WXROUND(m_width), WXROUND(m_height), m_cornerRadius);
91
dc.DrawRectangle(WXROUND(x1 + m_shadowOffsetX), WXROUND(y1 + m_shadowOffsetY), WXROUND(m_width), WXROUND(m_height));
95
void wxCompositeShape::OnDrawContents(wxDC &dc)
97
wxNode *node = m_children.GetFirst();
100
wxShape *object = (wxShape *)node->GetData();
102
object->DrawLinks(dc);
103
node = node->GetNext();
105
wxShape::OnDrawContents(dc);
108
bool wxCompositeShape::OnMovePre(double x, double y, double oldx, double oldy, bool display)
110
double diffX = x - oldx;
111
double diffY = y - oldy;
112
wxNode *node = m_children.GetFirst();
115
wxShape *object = (wxShape *)node->GetData();
117
object->Move(object->GetX() + diffX, object->GetY() + diffY, display);
119
node = node->GetNext();
124
static double objectStartX = 0.0;
125
static double objectStartY = 0.0;
127
void wxCompositeShape::OnDragLeft(bool WXUNUSED(draw), double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment))
131
m_canvas->Snap(&xx, &yy);
132
double offsetX = xx - objectStartX;
133
double offsetY = yy - objectStartY;
135
wxClientDC dc(GetCanvas());
136
GetCanvas()->PrepareDC(dc);
138
dc.SetLogicalFunction(OGLRBLF);
139
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
140
dc.SetPen(dottedPen);
141
dc.SetBrush((* wxTRANSPARENT_BRUSH));
143
GetEventHandler()->OnDrawOutline(dc, GetX() + offsetX, GetY() + offsetY, GetWidth(), GetHeight());
144
// wxShape::OnDragLeft(draw, x, y, keys, attachment);
147
void wxCompositeShape::OnBeginDragLeft(double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment))
152
wxClientDC dc(GetCanvas());
153
GetCanvas()->PrepareDC(dc);
157
dc.SetLogicalFunction(OGLRBLF);
159
wxPen dottedPen(wxColour(0, 0, 0), 1, wxDOT);
160
dc.SetPen(dottedPen);
161
dc.SetBrush((* wxTRANSPARENT_BRUSH));
162
m_canvas->CaptureMouse();
166
m_canvas->Snap(&xx, &yy);
167
double offsetX = xx - objectStartX;
168
double offsetY = yy - objectStartY;
170
GetEventHandler()->OnDrawOutline(dc, GetX() + offsetX, GetY() + offsetY, GetWidth(), GetHeight());
172
// wxShape::OnBeginDragLeft(x, y, keys, attachment);
175
void wxCompositeShape::OnEndDragLeft(double x, double y, int keys, int WXUNUSED(attachment))
177
// wxShape::OnEndDragLeft(x, y, keys, attachment);
179
wxClientDC dc(GetCanvas());
180
GetCanvas()->PrepareDC(dc);
182
m_canvas->ReleaseMouse();
186
if (m_parent) m_parent->GetEventHandler()->OnEndDragLeft(x, y, keys, 0);
190
dc.SetLogicalFunction(wxCOPY);
193
m_canvas->Snap(&xx, &yy);
194
double offsetX = xx - objectStartX;
195
double offsetY = yy - objectStartY;
197
Move(GetX() + offsetX, GetY() + offsetY);
199
if (m_canvas && !m_canvas->GetQuickEditMode()) m_canvas->Redraw(dc);
202
void wxCompositeShape::OnRightClick(double x, double y, int keys, int WXUNUSED(attachment))
204
// If we get a ctrl-right click, this means send the message to
205
// the division, so we can invoke a user interface for dealing with regions.
208
wxNode *node = m_divisions.GetFirst();
211
wxDivisionShape *division = (wxDivisionShape *)node->GetData();
212
wxNode *next = node->GetNext();
215
if (division->HitTest(x, y, &attach, &dist))
217
division->GetEventHandler()->OnRightClick(x, y, keys, attach);
226
void wxCompositeShape::SetSize(double w, double h, bool recursive)
228
SetAttachmentSize(w, h);
230
double xScale = (double)(w / (wxMax(1.0, GetWidth())));
231
double yScale = (double)(h / (wxMax(1.0, GetHeight())));
236
if (!recursive) return;
238
wxNode *node = m_children.GetFirst();
240
wxClientDC dc(GetCanvas());
241
GetCanvas()->PrepareDC(dc);
243
double xBound, yBound;
246
wxShape *object = (wxShape *)node->GetData();
248
// Scale the position first
249
double newX = (double)(((object->GetX() - GetX()) * xScale) + GetX());
250
double newY = (double)(((object->GetY() - GetY()) * yScale) + GetY());
252
object->Move(newX, newY);
255
// Now set the scaled size
256
object->GetBoundingBoxMin(&xBound, &yBound);
257
object->SetSize(object->GetFixedWidth() ? xBound : xScale * xBound,
258
object->GetFixedHeight() ? yBound : yScale * yBound);
260
node = node->GetNext();
262
SetDefaultRegionSize();
265
void wxCompositeShape::AddChild(wxShape *child, wxShape *addAfter)
267
m_children.Append(child);
268
child->SetParent(this);
271
// Ensure we add at the right position
273
child->RemoveFromCanvas(m_canvas);
274
child->AddToCanvas(m_canvas, addAfter);
278
void wxCompositeShape::RemoveChild(wxShape *child)
280
m_children.DeleteObject(child);
281
m_divisions.DeleteObject(child);
282
RemoveChildFromConstraints(child);
283
child->SetParent(NULL);
286
void wxCompositeShape::DeleteConstraintsInvolvingChild(wxShape *child)
288
wxNode *node = m_constraints.GetFirst();
291
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
292
wxNode *nextNode = node->GetNext();
294
if ((constraint->m_constrainingObject == child) ||
295
constraint->m_constrainedObjects.Member(child))
304
void wxCompositeShape::RemoveChildFromConstraints(wxShape *child)
306
wxNode *node = m_constraints.GetFirst();
309
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
310
wxNode *nextNode = node->GetNext();
312
if (constraint->m_constrainedObjects.Member(child))
313
constraint->m_constrainedObjects.DeleteObject(child);
314
if (constraint->m_constrainingObject == child)
315
constraint->m_constrainingObject = NULL;
317
// Delete the constraint if no participants left
318
if (!constraint->m_constrainingObject)
328
void wxCompositeShape::Copy(wxShape ©)
330
wxRectangleShape::Copy(copy);
332
wxASSERT( copy.IsKindOf(CLASSINFO(wxCompositeShape)) ) ;
334
wxCompositeShape &compositeCopy = (wxCompositeShape &) copy;
336
// Associate old and new copies for compositeCopying constraints and division geometry
337
oglObjectCopyMapping.Append((long)this, &compositeCopy);
340
wxNode *node = m_children.GetFirst();
343
wxShape *object = (wxShape *)node->GetData();
344
wxShape *newObject = object->CreateNewCopy(FALSE, FALSE);
345
if (newObject->GetId() == 0)
346
newObject->SetId(wxNewId());
348
newObject->SetParent(&compositeCopy);
349
compositeCopy.m_children.Append(newObject);
351
// Some m_children may be divisions
352
if (m_divisions.Member(object))
353
compositeCopy.m_divisions.Append(newObject);
355
oglObjectCopyMapping.Append((long)object, newObject);
357
node = node->GetNext();
360
// Copy the constraints
361
node = m_constraints.GetFirst();
364
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
366
wxShape *newConstraining = (wxShape *)(oglObjectCopyMapping.Find((long)constraint->m_constrainingObject)->GetData());
368
wxList newConstrainedList;
369
wxNode *node2 = constraint->m_constrainedObjects.GetFirst();
372
wxShape *constrainedObject = (wxShape *)node2->GetData();
373
wxShape *newConstrained = (wxShape *)(oglObjectCopyMapping.Find((long)constrainedObject)->GetData());
374
newConstrainedList.Append(newConstrained);
375
node2 = node2->GetNext();
378
wxOGLConstraint *newConstraint = new wxOGLConstraint(constraint->m_constraintType, newConstraining,
380
newConstraint->m_constraintId = constraint->m_constraintId;
381
if (!constraint->m_constraintName.IsEmpty())
383
newConstraint->m_constraintName = constraint->m_constraintName;
385
newConstraint->SetSpacing(constraint->m_xSpacing, constraint->m_ySpacing);
386
compositeCopy.m_constraints.Append(newConstraint);
388
node = node->GetNext();
391
// Now compositeCopy the division geometry
392
node = m_divisions.GetFirst();
395
wxDivisionShape *division = (wxDivisionShape *)node->GetData();
396
wxNode *node1 = oglObjectCopyMapping.Find((long)division);
397
wxNode *leftNode = NULL;
398
wxNode *topNode = NULL;
399
wxNode *rightNode = NULL;
400
wxNode *bottomNode = NULL;
401
if (division->GetLeftSide())
402
leftNode = oglObjectCopyMapping.Find((long)division->GetLeftSide());
403
if (division->GetTopSide())
404
topNode = oglObjectCopyMapping.Find((long)division->GetTopSide());
405
if (division->GetRightSide())
406
rightNode = oglObjectCopyMapping.Find((long)division->GetRightSide());
407
if (division->GetBottomSide())
408
bottomNode = oglObjectCopyMapping.Find((long)division->GetBottomSide());
411
wxDivisionShape *newDivision = (wxDivisionShape *)node1->GetData();
413
newDivision->SetLeftSide((wxDivisionShape *)leftNode->GetData());
415
newDivision->SetTopSide((wxDivisionShape *)topNode->GetData());
417
newDivision->SetRightSide((wxDivisionShape *)rightNode->GetData());
419
newDivision->SetBottomSide((wxDivisionShape *)bottomNode->GetData());
421
node = node->GetNext();
425
wxOGLConstraint *wxCompositeShape::AddConstraint(wxOGLConstraint *constraint)
427
m_constraints.Append(constraint);
428
if (constraint->m_constraintId == 0)
429
constraint->m_constraintId = wxNewId();
433
wxOGLConstraint *wxCompositeShape::AddConstraint(int type, wxShape *constraining, wxList &constrained)
435
wxOGLConstraint *constraint = new wxOGLConstraint(type, constraining, constrained);
436
if (constraint->m_constraintId == 0)
437
constraint->m_constraintId = wxNewId();
438
m_constraints.Append(constraint);
442
wxOGLConstraint *wxCompositeShape::AddConstraint(int type, wxShape *constraining, wxShape *constrained)
445
l.Append(constrained);
446
wxOGLConstraint *constraint = new wxOGLConstraint(type, constraining, l);
447
if (constraint->m_constraintId == 0)
448
constraint->m_constraintId = wxNewId();
449
m_constraints.Append(constraint);
453
wxOGLConstraint *wxCompositeShape::FindConstraint(long cId, wxCompositeShape **actualComposite)
455
wxNode *node = m_constraints.GetFirst();
458
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
459
if (constraint->m_constraintId == cId)
462
*actualComposite = this;
465
node = node->GetNext();
467
// If not found, try children.
468
node = m_children.GetFirst();
471
wxShape *child = (wxShape *)node->GetData();
472
if (child->IsKindOf(CLASSINFO(wxCompositeShape)))
474
wxOGLConstraint *constraint = ((wxCompositeShape *)child)->FindConstraint(cId, actualComposite);
478
*actualComposite = (wxCompositeShape *)child;
482
node = node->GetNext();
487
void wxCompositeShape::DeleteConstraint(wxOGLConstraint *constraint)
489
m_constraints.DeleteObject(constraint);
493
void wxCompositeShape::CalculateSize()
495
double maxX = (double) - 999999.9;
496
double maxY = (double) - 999999.9;
497
double minX = (double) 999999.9;
498
double minY = (double) 999999.9;
501
wxNode *node = m_children.GetFirst();
504
wxShape *object = (wxShape *)node->GetData();
506
// Recalculate size of composite objects because may not conform
507
// to size it was set to - depends on the children.
508
object->CalculateSize();
510
object->GetBoundingBoxMax(&w, &h);
511
if ((object->GetX() + (w / 2.0)) > maxX)
512
maxX = (double)(object->GetX() + (w / 2.0));
513
if ((object->GetX() - (w / 2.0)) < minX)
514
minX = (double)(object->GetX() - (w / 2.0));
515
if ((object->GetY() + (h / 2.0)) > maxY)
516
maxY = (double)(object->GetY() + (h / 2.0));
517
if ((object->GetY() - (h / 2.0)) < minY)
518
minY = (double)(object->GetY() - (h / 2.0));
520
node = node->GetNext();
522
m_width = maxX - minX;
523
m_height = maxY - minY;
524
m_xpos = (double)(m_width / 2.0 + minX);
525
m_ypos = (double)(m_height / 2.0 + minY);
528
bool wxCompositeShape::Recompute()
530
int noIterations = 0;
532
while (changed && (noIterations < 500))
534
changed = Constrain();
540
cerr << "Warning: constraint algorithm failed after 500 iterations.\n";
546
bool wxCompositeShape::Constrain()
550
bool changed = FALSE;
551
wxNode *node = m_children.GetFirst();
554
wxShape *object = (wxShape *)node->GetData();
555
if (object->Constrain())
557
node = node->GetNext();
560
node = m_constraints.GetFirst();
563
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
564
if (constraint->Evaluate()) changed = TRUE;
565
node = node->GetNext();
571
void wxCompositeShape::WriteAttributes(wxExpr *clause)
573
wxRectangleShape::WriteAttributes(clause);
575
// clause->AddAttributeValue("selectable", (long)selectable);
577
// Output constraints as constraint1 = (...), constraint2 = (...), etc.
578
int constraintNo = 1;
579
wxChar m_constraintNameBuf[20];
580
wxNode *node = m_constraints.GetFirst();
583
wxOGLConstraint *constraint = (wxOGLConstraint *)node->GetData();
584
wxSprintf(m_constraintNameBuf, _T("constraint%d"), constraintNo);
586
// Each constraint is stored in the form
587
// (type name id xspacing yspacing m_constrainingObjectId constrainedObjectIdList)
588
wxExpr *constraintExpr = new wxExpr(wxExprList);
589
constraintExpr->Append(new wxExpr((long)constraint->m_constraintType));
590
constraintExpr->Append(new wxExpr(wxExprString, constraint->m_constraintName));
591
constraintExpr->Append(new wxExpr(constraint->m_constraintId));
592
constraintExpr->Append(new wxExpr(constraint->m_xSpacing));
593
constraintExpr->Append(new wxExpr(constraint->m_ySpacing));
594
constraintExpr->Append(new wxExpr(constraint->m_constrainingObject->GetId()));
596
wxExpr *objectList = new wxExpr(wxExprList);
597
wxNode *node1 = constraint->m_constrainedObjects.GetFirst();
600
wxShape *obj = (wxShape *)node1->GetData();
601
objectList->Append(new wxExpr(obj->GetId()));
602
node1 = node1->GetNext();
604
constraintExpr->Append(objectList);
606
clause->AddAttributeValue(m_constraintNameBuf, constraintExpr);
608
node = node->GetNext();
612
// Write the ids of all the child images
613
wxExpr *childrenExpr = new wxExpr(wxExprList);
614
node = m_children.GetFirst();
617
wxShape *child = (wxShape *)node->GetData();
618
childrenExpr->Append(new wxExpr(child->GetId()));
619
node = node->GetNext();
621
clause->AddAttributeValue(_T("children"), childrenExpr);
623
// Write the ids of all the division images
624
if (m_divisions.GetCount() > 0)
626
wxExpr *divisionsExpr = new wxExpr(wxExprList);
627
node = m_divisions.GetFirst();
630
wxShape *child = (wxShape *)node->GetData();
631
divisionsExpr->Append(new wxExpr(child->GetId()));
632
node = node->GetNext();
634
clause->AddAttributeValue(_T("divisions"), divisionsExpr);
638
// Problem. Child images are always written AFTER the parent
639
// so as to be able to link up to parent. So we may not be able
640
// to find the constraint participants until we've read everything
641
// in. Need to have another pass for composites.
642
void wxCompositeShape::ReadAttributes(wxExpr *clause)
644
wxRectangleShape::ReadAttributes(clause);
646
// clause->GetAttributeValue("selectable", selectable);
649
void wxCompositeShape::ReadConstraints(wxExpr *clause, wxExprDatabase *database)
651
// Constraints are output as constraint1 = (...), constraint2 = (...), etc.
652
int constraintNo = 1;
653
wxChar m_constraintNameBuf[20];
654
bool haveConstraints = TRUE;
656
while (haveConstraints)
658
wxSprintf(m_constraintNameBuf, _T("constraint%d"), constraintNo);
659
wxExpr *constraintExpr = NULL;
660
clause->GetAttributeValue(m_constraintNameBuf, &constraintExpr);
663
haveConstraints = FALSE;
666
wxString cName = wxEmptyString;
667
wxShape *m_constrainingObject = NULL;
668
wxList m_constrainedObjects;
670
// Each constraint is stored in the form
671
// (type name id xspacing yspacing m_constrainingObjectId constrainedObjectIdList)
673
wxExpr *typeExpr = constraintExpr->Nth(0);
674
wxExpr *nameExpr = constraintExpr->Nth(1);
675
wxExpr *idExpr = constraintExpr->Nth(2);
676
wxExpr *xExpr = constraintExpr->Nth(3);
677
wxExpr *yExpr = constraintExpr->Nth(4);
678
wxExpr *constrainingExpr = constraintExpr->Nth(5);
679
wxExpr *constrainedExpr = constraintExpr->Nth(6);
681
int cType = (int)typeExpr->IntegerValue();
682
double cXSpacing = xExpr->RealValue();
683
double cYSpacing = yExpr->RealValue();
684
cName = nameExpr->StringValue();
685
long cId = idExpr->IntegerValue();
687
wxExpr *objExpr1 = database->HashFind(_T("node_image"), constrainingExpr->IntegerValue());
688
if (objExpr1 && objExpr1->GetClientData())
689
m_constrainingObject = (wxShape *)objExpr1->GetClientData();
691
wxLogFatalError(wxT("Object graphics error: Couldn't find constraining image of composite."));
694
wxExpr *currentIdExpr = constrainedExpr->Nth(i);
695
while (currentIdExpr)
697
long currentId = currentIdExpr->IntegerValue();
698
wxExpr *objExpr2 = database->HashFind(_T("node_image"), currentId);
699
if (objExpr2 && objExpr2->GetClientData())
701
m_constrainedObjects.Append((wxShape *)objExpr2->GetClientData());
705
wxLogFatalError(wxT("Object graphics error: Couldn't find constrained image of composite."));
709
currentIdExpr = constrainedExpr->Nth(i);
711
wxOGLConstraint *newConstraint = AddConstraint(cType, m_constrainingObject, m_constrainedObjects);
712
newConstraint->SetSpacing(cXSpacing, cYSpacing);
713
newConstraint->m_constraintId = cId;
714
newConstraint->m_constraintName = cName;
720
// Make this composite into a container by creating one wxDivisionShape
721
void wxCompositeShape::MakeContainer()
723
wxDivisionShape *division = OnCreateDivision();
724
m_divisions.Append(division);
727
division->SetSize(m_width, m_height);
729
wxClientDC dc(GetCanvas());
730
GetCanvas()->PrepareDC(dc);
732
division->Move(GetX(), GetY());
734
division->Show(TRUE);
737
wxDivisionShape *wxCompositeShape::OnCreateDivision()
739
return new wxDivisionShape;
742
wxShape *wxCompositeShape::FindContainerImage()
744
wxNode *node = m_children.GetFirst();
747
wxShape *child = (wxShape *)node->GetData();
748
if (!m_divisions.Member(child))
750
node = node->GetNext();
755
// Returns TRUE if division is a descendant of this container
756
bool wxCompositeShape::ContainsDivision(wxDivisionShape *division)
758
if (m_divisions.Member(division))
760
wxNode *node = m_children.GetFirst();
763
wxShape *child = (wxShape *)node->GetData();
764
if (child->IsKindOf(CLASSINFO(wxCompositeShape)))
766
bool ans = ((wxCompositeShape *)child)->ContainsDivision(division);
770
node = node->GetNext();
780
IMPLEMENT_DYNAMIC_CLASS(wxDivisionShape, wxCompositeShape)
782
wxDivisionShape::wxDivisionShape()
784
SetSensitivityFilter(OP_CLICK_LEFT | OP_CLICK_RIGHT | OP_DRAG_RIGHT);
785
SetCentreResize(FALSE);
786
SetAttachmentMode(TRUE);
791
m_handleSide = DIVISION_SIDE_NONE;
792
m_leftSidePen = (wxPen *) wxBLACK_PEN;
793
m_topSidePen = (wxPen *) wxBLACK_PEN;
794
m_leftSideColour = wxT("BLACK");
795
m_topSideColour = wxT("BLACK");
796
m_leftSideStyle = wxT("Solid");
797
m_topSideStyle = wxT("Solid");
801
wxDivisionShape::~wxDivisionShape()
805
void wxDivisionShape::OnDraw(wxDC &dc)
807
dc.SetBrush(* wxTRANSPARENT_BRUSH);
808
dc.SetBackgroundMode(wxTRANSPARENT);
810
double x1 = (double)(GetX() - (GetWidth() / 2.0));
811
double y1 = (double)(GetY() - (GetHeight() / 2.0));
812
double x2 = (double)(GetX() + (GetWidth() / 2.0));
813
double y2 = (double)(GetY() + (GetHeight() / 2.0));
815
// Should subtract 1 pixel if drawing under Windows
822
dc.SetPen(* m_leftSidePen);
823
dc.DrawLine(WXROUND(x1), WXROUND(y2), WXROUND(x1), WXROUND(y1));
827
dc.SetPen(* m_topSidePen);
828
dc.DrawLine(WXROUND(x1), WXROUND(y1), WXROUND(x2), WXROUND(y1));
831
// For testing purposes, draw a rectangle so we know
832
// how big the division is.
833
// SetBrush(* wxCYAN_BRUSH);
834
// wxRectangleShape::OnDraw(dc);
837
void wxDivisionShape::OnDrawContents(wxDC &dc)
839
wxCompositeShape::OnDrawContents(dc);
842
bool wxDivisionShape::OnMovePre(double x, double y, double oldx, double oldy, bool display)
844
double diffX = x - oldx;
845
double diffY = y - oldy;
846
wxNode *node = m_children.GetFirst();
849
wxShape *object = (wxShape *)node->GetData();
851
object->Move(object->GetX() + diffX, object->GetY() + diffY, display);
852
node = node->GetNext();
857
void wxDivisionShape::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
859
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
865
m_parent->HitTest(x, y, &attachment, &dist);
866
m_parent->GetEventHandler()->OnDragLeft(draw, x, y, keys, attachment);
870
wxShape::OnDragLeft(draw, x, y, keys, attachment);
873
void wxDivisionShape::OnBeginDragLeft(double x, double y, int keys, int attachment)
875
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
881
m_parent->HitTest(x, y, &attachment, &dist);
882
m_parent->GetEventHandler()->OnBeginDragLeft(x, y, keys, attachment);
887
wxShape::OnBeginDragLeft(x, y, keys, attachment);
890
void wxDivisionShape::OnEndDragLeft(double x, double y, int keys, int attachment)
892
m_canvas->ReleaseMouse();
893
if ((m_sensitivity & OP_DRAG_LEFT) != OP_DRAG_LEFT)
899
m_parent->HitTest(x, y, &attachment, &dist);
900
m_parent->GetEventHandler()->OnEndDragLeft(x, y, keys, attachment);
906
wxClientDC dc(GetCanvas());
907
GetCanvas()->PrepareDC(dc);
909
dc.SetLogicalFunction(wxCOPY);
912
m_canvas->Snap(&m_xpos, &m_ypos);
913
GetEventHandler()->OnMovePre(x, y, m_oldX, m_oldY);
915
ResetControlPoints();
922
void wxDivisionShape::SetSize(double w, double h, bool recursive)
926
wxRectangleShape::SetSize(w, h, recursive);
929
void wxDivisionShape::CalculateSize()
933
void wxDivisionShape::Copy(wxShape ©)
935
wxCompositeShape::Copy(copy);
937
wxASSERT( copy.IsKindOf(CLASSINFO(wxDivisionShape)) ) ;
939
wxDivisionShape &divisionCopy = (wxDivisionShape &) copy;
941
divisionCopy.m_leftSideStyle = m_leftSideStyle;
942
divisionCopy.m_topSideStyle = m_topSideStyle;
943
divisionCopy.m_leftSideColour = m_leftSideColour;
944
divisionCopy.m_topSideColour = m_topSideColour;
946
divisionCopy.m_leftSidePen = m_leftSidePen;
947
divisionCopy.m_topSidePen = m_topSidePen;
948
divisionCopy.m_handleSide = m_handleSide;
950
// Division geometry copying is handled at the wxCompositeShape level.
954
void wxDivisionShape::WriteAttributes(wxExpr *clause)
956
wxCompositeShape::WriteAttributes(clause);
959
clause->AddAttributeValue(_T("left_side"), (long)m_leftSide->GetId());
961
clause->AddAttributeValue(_T("top_side"), (long)m_topSide->GetId());
963
clause->AddAttributeValue(_T("right_side"), (long)m_rightSide->GetId());
965
clause->AddAttributeValue(_T("bottom_side"), (long)m_bottomSide->GetId());
967
clause->AddAttributeValue(_T("handle_side"), (long)m_handleSide);
968
clause->AddAttributeValueString(_T("left_colour"), m_leftSideColour);
969
clause->AddAttributeValueString(_T("top_colour"), m_topSideColour);
970
clause->AddAttributeValueString(_T("left_style"), m_leftSideStyle);
971
clause->AddAttributeValueString(_T("top_style"), m_topSideStyle);
974
void wxDivisionShape::ReadAttributes(wxExpr *clause)
976
wxCompositeShape::ReadAttributes(clause);
978
clause->GetAttributeValue(_T("handle_side"), m_handleSide);
979
clause->GetAttributeValue(_T("left_colour"), m_leftSideColour);
980
clause->GetAttributeValue(_T("top_colour"), m_topSideColour);
981
clause->GetAttributeValue(_T("left_style"), m_leftSideStyle);
982
clause->GetAttributeValue(_T("top_style"), m_topSideStyle);
987
void wxDivisionShape::OnRightClick(double x, double y, int keys, int attachment)
994
else if (keys & KEY_SHIFT)
996
if (m_leftSide || m_topSide || m_rightSide || m_bottomSide)
1001
GetParent()->Draw(dc);
1014
m_parent->HitTest(x, y, &attachment, &dist);
1015
m_parent->GetEventHandler()->OnRightClick(x, y, keys, attachment);
1022
// Divide wxHORIZONTALly or wxVERTICALly
1023
bool wxDivisionShape::Divide(int direction)
1025
// Calculate existing top-left, bottom-right
1026
double x1 = (double)(GetX() - (GetWidth() / 2.0));
1027
double y1 = (double)(GetY() - (GetHeight() / 2.0));
1028
wxCompositeShape *compositeParent = (wxCompositeShape *)GetParent();
1029
double oldWidth = GetWidth();
1030
double oldHeight = GetHeight();
1034
//wxClientDC dc(GetCanvas());
1035
//GetCanvas()->PrepareDC(dc);
1037
if (direction == wxVERTICAL)
1039
// Dividing vertically means notionally putting a horizontal line through it.
1040
// Break existing piece into two.
1041
double newXPos1 = GetX();
1042
double newYPos1 = (double)(y1 + (GetHeight() / 4.0));
1043
double newXPos2 = GetX();
1044
double newYPos2 = (double)(y1 + (3.0 * GetHeight() / 4.0));
1045
wxDivisionShape *newDivision = compositeParent->OnCreateDivision();
1046
newDivision->Show(TRUE);
1050
// Anything adjoining the bottom of this division now adjoins the
1051
// bottom of the new division.
1052
wxNode *node = compositeParent->GetDivisions().GetFirst();
1055
wxDivisionShape *obj = (wxDivisionShape *)node->GetData();
1056
if (obj->GetTopSide() == this)
1057
obj->SetTopSide(newDivision);
1058
node = node->GetNext();
1060
newDivision->SetTopSide(this);
1061
newDivision->SetBottomSide(m_bottomSide);
1062
newDivision->SetLeftSide(m_leftSide);
1063
newDivision->SetRightSide(m_rightSide);
1064
m_bottomSide = newDivision;
1066
compositeParent->GetDivisions().Append(newDivision);
1068
// CHANGE: Need to insert this division at start of divisions in the object
1069
// list, because e.g.:
1071
// 2) Add contained object
1073
// Division is now receiving mouse events _before_ the contained object,
1074
// because it was added last (on top of all others)
1076
// Add after the image that visualizes the container
1077
compositeParent->AddChild(newDivision, compositeParent->FindContainerImage());
1079
m_handleSide = DIVISION_SIDE_BOTTOM;
1080
newDivision->SetHandleSide(DIVISION_SIDE_TOP);
1082
SetSize(oldWidth, (double)(oldHeight / 2.0));
1083
Move(newXPos1, newYPos1);
1085
newDivision->SetSize(oldWidth, (double)(oldHeight / 2.0));
1086
newDivision->Move(newXPos2, newYPos2);
1090
// Dividing horizontally means notionally putting a vertical line through it.
1091
// Break existing piece into two.
1092
double newXPos1 = (double)(x1 + (GetWidth() / 4.0));
1093
double newYPos1 = GetY();
1094
double newXPos2 = (double)(x1 + (3.0 * GetWidth() / 4.0));
1095
double newYPos2 = GetY();
1096
wxDivisionShape *newDivision = compositeParent->OnCreateDivision();
1097
newDivision->Show(TRUE);
1101
// Anything adjoining the left of this division now adjoins the
1102
// left of the new division.
1103
wxNode *node = compositeParent->GetDivisions().GetFirst();
1106
wxDivisionShape *obj = (wxDivisionShape *)node->GetData();
1107
if (obj->GetLeftSide() == this)
1108
obj->SetLeftSide(newDivision);
1109
node = node->GetNext();
1111
newDivision->SetTopSide(m_topSide);
1112
newDivision->SetBottomSide(m_bottomSide);
1113
newDivision->SetLeftSide(this);
1114
newDivision->SetRightSide(m_rightSide);
1115
m_rightSide = newDivision;
1117
compositeParent->GetDivisions().Append(newDivision);
1118
compositeParent->AddChild(newDivision, compositeParent->FindContainerImage());
1120
m_handleSide = DIVISION_SIDE_RIGHT;
1121
newDivision->SetHandleSide(DIVISION_SIDE_LEFT);
1123
SetSize((double)(oldWidth / 2.0), oldHeight);
1124
Move(newXPos1, newYPos1);
1126
newDivision->SetSize((double)(oldWidth / 2.0), oldHeight);
1127
newDivision->Move(newXPos2, newYPos2);
1129
if (compositeParent->Selected())
1131
compositeParent->DeleteControlPoints();
1132
compositeParent->MakeControlPoints();
1133
compositeParent->MakeMandatoryControlPoints();
1135
// compositeParent->Draw(dc);
1138
GetCanvas()->Refresh();
1142
// Make one control point for every visible line
1143
void wxDivisionShape::MakeControlPoints()
1145
MakeMandatoryControlPoints();
1148
void wxDivisionShape::MakeMandatoryControlPoints()
1152
GetBoundingBoxMax(&maxX, &maxY);
1153
double x = 0.0 , y = 0.0;
1158
x = (double)(-maxX/2.0);
1160
wxDivisionControlPoint *control = new wxDivisionControlPoint(m_canvas, this, CONTROL_POINT_SIZE, x, y,
1161
CONTROL_POINT_HORIZONTAL);
1162
m_canvas->AddShape(control);
1163
m_controlPoints.Append(control);
1168
y = (double)(-maxY/2.0);
1169
wxDivisionControlPoint *control = new wxDivisionControlPoint(m_canvas, this, CONTROL_POINT_SIZE, x, y,
1170
CONTROL_POINT_VERTICAL);
1171
m_canvas->AddShape(control);
1172
m_controlPoints.Append(control);
1175
switch (m_handleSide)
1177
case DIVISION_SIDE_LEFT:
1179
x = (double)(-maxX / 2.0);
1181
direction = CONTROL_POINT_HORIZONTAL;
1184
case DIVISION_SIDE_TOP:
1187
y = (double)(-maxY / 2.0);
1188
direction = CONTROL_POINT_VERTICAL;
1191
case DIVISION_SIDE_RIGHT:
1193
x = (double)(maxX / 2.0);
1195
direction = CONTROL_POINT_HORIZONTAL;
1198
case DIVISION_SIDE_BOTTOM:
1201
y = (double)(maxY / 2.0);
1202
direction = CONTROL_POINT_VERTICAL;
1208
if (m_handleSide != DIVISION_SIDE_NONE)
1210
wxDivisionControlPoint *control = new wxDivisionControlPoint(m_canvas, this, CONTROL_POINT_SIZE, x, y,
1212
m_canvas->AddShape(control);
1213
m_controlPoints.Append(control);
1217
void wxDivisionShape::ResetControlPoints()
1219
ResetMandatoryControlPoints();
1222
void wxDivisionShape::ResetMandatoryControlPoints()
1224
if (m_controlPoints.GetCount() < 1)
1229
GetBoundingBoxMax(&maxX, &maxY);
1231
wxNode *node = m_controlPoints.GetFirst();
1234
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData();
1235
if (control->type == CONTROL_POINT_HORIZONTAL)
1237
control->xoffset = (double)(-maxX/2.0); control->m_yoffset = 0.0;
1239
else if (control->type == CONTROL_POINT_VERTICAL)
1241
control->xoffset = 0.0; control->m_yoffset = (double)(-maxY/2.0);
1243
node = node->GetNext();
1246
wxNode *node = m_controlPoints.GetFirst();
1247
if ((m_handleSide == DIVISION_SIDE_LEFT) && node)
1249
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData();
1250
control->m_xoffset = (double)(-maxX / 2.0);
1251
control->m_yoffset = 0.0;
1254
if ((m_handleSide == DIVISION_SIDE_TOP) && node)
1256
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData();
1257
control->m_xoffset = 0.0;
1258
control->m_yoffset = (double)(-maxY / 2.0);
1261
if ((m_handleSide == DIVISION_SIDE_RIGHT) && node)
1263
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData();
1264
control->m_xoffset = (double)(maxX / 2.0);
1265
control->m_yoffset = 0.0;
1268
if ((m_handleSide == DIVISION_SIDE_BOTTOM) && node)
1270
wxDivisionControlPoint *control = (wxDivisionControlPoint *)node->GetData();
1271
control->m_xoffset = 0.0;
1272
control->m_yoffset = (double)(maxY / 2.0);
1276
// Adjust a side, returning FALSE if it's not physically possible.
1277
bool wxDivisionShape::AdjustLeft(double left, bool test)
1279
double x2 = (double)(GetX() + (GetWidth() / 2.0));
1286
double newW = x2 - left;
1287
double newX = (double)(left + newW / 2.0);
1288
SetSize(newW, GetHeight());
1293
GetCanvas()->Refresh();
1298
bool wxDivisionShape::AdjustTop(double top, bool test)
1300
double y2 = (double)(GetY() + (GetHeight() / 2.0));
1307
double newH = y2 - top;
1308
double newY = (double)(top + newH / 2.0);
1309
SetSize(GetWidth(), newH);
1314
GetCanvas()->Refresh();
1319
bool wxDivisionShape::AdjustRight(double right, bool test)
1321
double x1 = (double)(GetX() - (GetWidth() / 2.0));
1328
double newW = right - x1;
1329
double newX = (double)(x1 + newW / 2.0);
1330
SetSize(newW, GetHeight());
1335
GetCanvas()->Refresh();
1340
bool wxDivisionShape::AdjustBottom(double bottom, bool test)
1342
double y1 = (double)(GetY() - (GetHeight() / 2.0));
1349
double newH = bottom - y1;
1350
double newY = (double)(y1 + newH / 2.0);
1351
SetSize(GetWidth(), newH);
1356
GetCanvas()->Refresh();
1361
wxDivisionControlPoint::wxDivisionControlPoint(wxShapeCanvas *the_canvas, wxShape *object, double size, double the_xoffset, double the_yoffset, int the_type):
1362
wxControlPoint(the_canvas, object, size, the_xoffset, the_yoffset, the_type)
1364
SetEraseObject(FALSE);
1367
wxDivisionControlPoint::~wxDivisionControlPoint()
1371
static double originalX = 0.0;
1372
static double originalY = 0.0;
1373
static double originalW = 0.0;
1374
static double originalH = 0.0;
1376
// Implement resizing of canvas object
1377
void wxDivisionControlPoint::OnDragLeft(bool draw, double x, double y, int keys, int attachment)
1379
wxControlPoint::OnDragLeft(draw, x, y, keys, attachment);
1382
void wxDivisionControlPoint::OnBeginDragLeft(double x, double y, int keys, int attachment)
1384
wxDivisionShape *division = (wxDivisionShape *)m_shape;
1385
originalX = division->GetX();
1386
originalY = division->GetY();
1387
originalW = division->GetWidth();
1388
originalH = division->GetHeight();
1390
wxControlPoint::OnBeginDragLeft(x, y, keys, attachment);
1393
void wxDivisionControlPoint::OnEndDragLeft(double x, double y, int keys, int attachment)
1395
wxControlPoint::OnEndDragLeft(x, y, keys, attachment);
1397
wxDivisionShape *division = (wxDivisionShape *)m_shape;
1398
wxCompositeShape *divisionParent = (wxCompositeShape *)division->GetParent();
1400
// Need to check it's within the bounds of the parent composite.
1401
double x1 = (double)(divisionParent->GetX() - (divisionParent->GetWidth() / 2.0));
1402
double y1 = (double)(divisionParent->GetY() - (divisionParent->GetHeight() / 2.0));
1403
double x2 = (double)(divisionParent->GetX() + (divisionParent->GetWidth() / 2.0));
1404
double y2 = (double)(divisionParent->GetY() + (divisionParent->GetHeight() / 2.0));
1406
// Need to check it has not made the division zero or negative width/height
1407
double dx1 = (double)(division->GetX() - (division->GetWidth() / 2.0));
1408
double dy1 = (double)(division->GetY() - (division->GetHeight() / 2.0));
1409
double dx2 = (double)(division->GetX() + (division->GetWidth() / 2.0));
1410
double dy2 = (double)(division->GetY() + (division->GetHeight() / 2.0));
1412
bool success = TRUE;
1413
switch (division->GetHandleSide())
1415
case DIVISION_SIDE_LEFT:
1417
if ((x <= x1) || (x >= x2) || (x >= dx2))
1419
// Try it out first...
1420
else if (!division->ResizeAdjoining(DIVISION_SIDE_LEFT, x, TRUE))
1423
division->ResizeAdjoining(DIVISION_SIDE_LEFT, x, FALSE);
1427
case DIVISION_SIDE_TOP:
1429
if ((y <= y1) || (y >= y2) || (y >= dy2))
1431
else if (!division->ResizeAdjoining(DIVISION_SIDE_TOP, y, TRUE))
1434
division->ResizeAdjoining(DIVISION_SIDE_TOP, y, FALSE);
1438
case DIVISION_SIDE_RIGHT:
1440
if ((x <= x1) || (x >= x2) || (x <= dx1))
1442
else if (!division->ResizeAdjoining(DIVISION_SIDE_RIGHT, x, TRUE))
1445
division->ResizeAdjoining(DIVISION_SIDE_RIGHT, x, FALSE);
1449
case DIVISION_SIDE_BOTTOM:
1451
if ((y <= y1) || (y >= y2) || (y <= dy1))
1453
else if (!division->ResizeAdjoining(DIVISION_SIDE_BOTTOM, y, TRUE))
1456
division->ResizeAdjoining(DIVISION_SIDE_BOTTOM, y, FALSE);
1463
division->SetSize(originalW, originalH);
1464
division->Move(originalX, originalY);
1468
GetCanvas()->Refresh();
1472
/* Resize adjoining divisions.
1474
Behaviour should be as follows:
1475
If right edge moves, find all objects whose left edge
1476
adjoins this object, and move left edge accordingly.
1477
If left..., move ... right.
1478
If top..., move ... bottom.
1479
If bottom..., move top.
1480
If size goes to zero or end position is other side of start position,
1481
resize to original size and return.
1483
bool wxDivisionShape::ResizeAdjoining(int side, double newPos, bool test)
1485
wxCompositeShape *divisionParent = (wxCompositeShape *)GetParent();
1486
wxNode *node = divisionParent->GetDivisions().GetFirst();
1489
wxDivisionShape *division = (wxDivisionShape *)node->GetData();
1492
case DIVISION_SIDE_LEFT:
1494
if (division->m_rightSide == this)
1496
bool success = division->AdjustRight(newPos, test);
1497
if (!success && test)
1502
case DIVISION_SIDE_TOP:
1504
if (division->m_bottomSide == this)
1506
bool success = division->AdjustBottom(newPos, test);
1507
if (!success && test)
1512
case DIVISION_SIDE_RIGHT:
1514
if (division->m_leftSide == this)
1516
bool success = division->AdjustLeft(newPos, test);
1517
if (!success && test)
1522
case DIVISION_SIDE_BOTTOM:
1524
if (division->m_topSide == this)
1526
bool success = division->AdjustTop(newPos, test);
1527
if (!success && test)
1535
node = node->GetNext();
1542
* Popup menu for editing divisions
1545
class OGLPopupDivisionMenu : public wxMenu
1548
OGLPopupDivisionMenu() : wxMenu()
1550
Append(DIVISION_MENU_SPLIT_HORIZONTALLY, wxT("Split horizontally"));
1551
Append(DIVISION_MENU_SPLIT_VERTICALLY, wxT("Split vertically"));
1553
Append(DIVISION_MENU_EDIT_LEFT_EDGE, wxT("Edit left edge"));
1554
Append(DIVISION_MENU_EDIT_TOP_EDGE, wxT("Edit top edge"));
1557
void OnMenu(wxCommandEvent &event);
1559
DECLARE_EVENT_TABLE()
1562
BEGIN_EVENT_TABLE(OGLPopupDivisionMenu, wxMenu)
1563
EVT_MENU_RANGE(DIVISION_MENU_SPLIT_HORIZONTALLY,
1564
DIVISION_MENU_EDIT_BOTTOM_EDGE,
1565
OGLPopupDivisionMenu::OnMenu)
1569
void OGLPopupDivisionMenu::OnMenu(wxCommandEvent &event)
1571
wxDivisionShape *division = (wxDivisionShape *)GetClientData();
1572
switch (event.GetInt())
1574
case DIVISION_MENU_SPLIT_HORIZONTALLY:
1576
division->Divide(wxHORIZONTAL);
1579
case DIVISION_MENU_SPLIT_VERTICALLY:
1581
division->Divide(wxVERTICAL);
1584
case DIVISION_MENU_EDIT_LEFT_EDGE:
1586
division->EditEdge(DIVISION_SIDE_LEFT);
1589
case DIVISION_MENU_EDIT_TOP_EDGE:
1591
division->EditEdge(DIVISION_SIDE_TOP);
1599
void wxDivisionShape::EditEdge(int WXUNUSED(side))
1601
wxMessageBox(wxT("EditEdge() not implemented"), wxT("OGL"), wxOK);
1604
wxBeginBusyCursor();
1606
wxPen *currentPen = NULL;
1607
char **pColour = NULL;
1608
char **pStyle = NULL;
1609
if (side == DIVISION_SIDE_LEFT)
1611
currentPen = m_leftSidePen;
1612
pColour = &m_leftSideColour;
1613
pStyle = &m_leftSideStyle;
1617
currentPen = m_topSidePen;
1618
pColour = &m_topSideColour;
1619
pStyle = &m_topSideStyle;
1622
GraphicsForm *form = new GraphicsForm("Containers");
1623
int lineWidth = currentPen->GetWidth();
1625
form->Add(wxMakeFormShort("Width", &lineWidth, wxFORM_DEFAULT, NULL, NULL, wxVERTICAL,
1627
form->Add(wxMakeFormString("Colour", pColour, wxFORM_CHOICE,
1628
new wxList(wxMakeConstraintStrings(
1652
NULL), NULL, wxVERTICAL, 150));
1653
form->Add(wxMakeFormString("Style", pStyle, wxFORM_CHOICE,
1654
new wxList(wxMakeConstraintStrings(
1661
NULL), NULL, wxVERTICAL, 100));
1663
wxDialogBox *dialog = new wxDialogBox(m_canvas->GetParent(), "Division properties", 10, 10, 500, 500);
1664
if (GraphicsLabelFont)
1665
dialog->SetLabelFont(GraphicsLabelFont);
1666
if (GraphicsButtonFont)
1667
dialog->SetButtonFont(GraphicsButtonFont);
1669
form->AssociatePanel(dialog);
1670
form->dialog = dialog;
1673
dialog->Centre(wxBOTH);
1678
int lineStyle = wxSOLID;
1681
if (strcmp(*pStyle, "Solid") == 0)
1682
lineStyle = wxSOLID;
1683
else if (strcmp(*pStyle, "Dot") == 0)
1685
else if (strcmp(*pStyle, "Short Dash") == 0)
1686
lineStyle = wxSHORT_DASH;
1687
else if (strcmp(*pStyle, "Long Dash") == 0)
1688
lineStyle = wxLONG_DASH;
1689
else if (strcmp(*pStyle, "Dot Dash") == 0)
1690
lineStyle = wxDOT_DASH;
1693
wxPen *newPen = wxThePenList->FindOrCreatePen(*pColour, lineWidth, lineStyle);
1696
if (side == DIVISION_SIDE_LEFT)
1697
m_leftSidePen = newPen;
1699
m_topSidePen = newPen;
1701
// Need to draw whole image again
1702
wxCompositeShape *compositeParent = (wxCompositeShape *)GetParent();
1703
compositeParent->Draw(dc);
1708
void wxDivisionShape::PopupMenu(double x, double y)
1710
wxMenu *oglPopupDivisionMenu = new OGLPopupDivisionMenu;
1712
oglPopupDivisionMenu->SetClientData((void *)this);
1714
oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, TRUE);
1716
oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_LEFT_EDGE, FALSE);
1718
oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_TOP_EDGE, TRUE);
1720
oglPopupDivisionMenu->Enable(DIVISION_MENU_EDIT_TOP_EDGE, FALSE);
1723
m_canvas->GetViewStart(&x1, &y1);
1726
m_canvas->GetScrollPixelsPerUnit(&unit_x, &unit_y);
1728
wxClientDC dc(GetCanvas());
1729
GetCanvas()->PrepareDC(dc);
1731
int mouse_x = (int)(dc.LogicalToDeviceX((long)(x - x1 * unit_x)));
1732
int mouse_y = (int)(dc.LogicalToDeviceY((long)(y - y1 * unit_y)));
1734
m_canvas->PopupMenu(oglPopupDivisionMenu, mouse_x, mouse_y);
1735
delete oglPopupDivisionMenu;
1738
void wxDivisionShape::SetLeftSideColour(const wxString &colour)
1740
m_leftSideColour = colour;
1743
void wxDivisionShape::SetTopSideColour(const wxString &colour)
1745
m_topSideColour = colour;
1748
void wxDivisionShape::SetLeftSideStyle(const wxString &style)
1750
m_leftSideStyle = style;
1753
void wxDivisionShape::SetTopSideStyle(const wxString &style)
1755
m_topSideStyle = style;