1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
//////////////////////////////////////////////////////////////////////////
//
// pgAdmin III - PostgreSQL Tools
//
// Copyright (C) 2002 - 2014, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
// explainCanvas.h - Explain Canvas
//
//////////////////////////////////////////////////////////////////////////
#ifndef EXPLAINCANVAS_H
#define EXPLAINCANVAS_H
#if wxUSE_POPUPWIN
#include "wx/popupwin.h"
#define pgTipWindowBase wxPopupTransientWindow
#else
#include "wx/frame.h"
#define pgTipWindowBase wxFrame
#endif
#include <ogl/ogl.h>
#if wxUSE_DEPRECATED
#error wxUSE_DEPRECATED should be 0!
#endif
class ExplainShape;
class ExplainPopup;
class ExplainText;
class ExplainCanvas : public wxShapeCanvas
{
public:
ExplainCanvas(wxWindow *parent);
~ExplainCanvas();
void ShowPopup(ExplainShape *s);
void SetExplainString(const wxString &str);
void Clear();
void SaveAsImage(const wxString &fileName, wxBitmapType imageType);
private:
void OnMouseMotion(wxMouseEvent &ev);
ExplainShape *rootShape;
ExplainPopup *popup;
DECLARE_EVENT_TABLE()
};
class ExplainShape : public wxBitmapShape
{
public:
ExplainShape(const wxImage &bmp, const wxString &description, long tokenNo = -1, long detailNo = -1);
static ExplainShape *Create(long level, ExplainShape *last, const wxString &str);
void SetCondition(const wxString &str)
{
if (condition.Length() == 0) condition = str;
else condition += wxT(" ") + str;
}
long GetLevel()
{
return level;
}
wxRealPoint GetStartPoint();
wxRealPoint GetEndPoint(int kidNo);
int GetKidno()
{
return kidNo;
}
ExplainShape *GetUpper()
{
return upperShape;
}
double GetAverageCost()
{
return (costHigh - costLow) / 2 + costLow;
}
protected:
void OnDraw(wxDC &dc);
void OnLeftClick(double x, double y, int keys = 0, int attachment = 0);
ExplainShape *upperShape;
void SetLabel(const wxString &str, int tokenNo = -1, int detailNo = -1);
long level;
wxString description, detail, condition, label;
wxString cost, actual;
double costLow, costHigh;
long rows, width;
int kidCount, kidNo;
int totalShapes; // horizontal space usage by shape and its kids
int usedShapes;
bool m_rootShape;
friend class ExplainCanvas;
friend class ExplainText;
};
class ExplainLine : public wxLineShape
{
public:
ExplainLine(ExplainShape *from, ExplainShape *to, double weight = 0);
private:
int width;
void OnDraw(wxDC &dc);
};
class ExplainPopup : public pgTipWindowBase
{
public:
ExplainPopup(ExplainCanvas *parent, ExplainShape *shape, ExplainPopup **popup = NULL);
void Close();
~ExplainPopup();
protected:
// event handlers
void OnMouseClick(wxMouseEvent &event);
void OnMouseMove(wxMouseEvent &ev);
#if !wxUSE_POPUPWIN
void OnActivate(wxActivateEvent &event);
void OnKillFocus(wxFocusEvent &event);
#else // wxUSE_POPUPWIN
virtual void OnDismiss();
void OnMouseLost(wxMouseCaptureLostEvent &ev);
#endif // wxUSE_POPUPWIN/!wxUSE_POPUPWIN
ExplainPopup **m_ptr;
wxRect m_rectBound;
ExplainText *m_explainText;
#if !wxUSE_POPUPWIN
long m_creationTime;
#endif // !wxUSE_POPUPWIN
friend class ExplainText;
DECLARE_EVENT_TABLE()
};
#endif
|