00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef PLOTEVENT_H_
00028 #define PLOTEVENT_H_
00029
00030 #include <graphics/GenericPlotter/PlotOptions.h>
00031
00032 namespace casa {
00033
00034
00035 class Plotter;
00036 class PlotCanvas;
00037 class PlotButton;
00038 class PlotCheckbox;
00039
00040
00041 class PlotEvent {
00042 public:
00043 PlotEvent() { }
00044
00045 virtual ~PlotEvent() { }
00046
00047
00048 virtual void* origin() const = 0;
00049 };
00050
00051
00052
00053 class PlotSelectEvent : public virtual PlotEvent {
00054 public:
00055
00056 PlotSelectEvent(PlotCanvas* canvas, const PlotRegion& region);
00057
00058
00059 ~PlotSelectEvent();
00060
00061
00062 void* origin() const { return canvas(); }
00063
00064
00065 PlotCanvas* canvas() const;
00066
00067
00068 PlotRegion region() const;
00069
00070 protected:
00071 PlotCanvas* m_canvas;
00072 PlotRegion m_region;
00073 };
00074
00075
00076
00077
00078 class PlotMouseEvent : public virtual PlotEvent {
00079 public:
00080
00081 enum Type {
00082 CLICK,
00083 PRESS,
00084 RELEASE,
00085 DRAG,
00086 MOVE
00087 };
00088
00089
00090 enum Button {
00091 SINGLE,
00092 DOUBLE,
00093 CONTEXT,
00094 MIDDLE
00095 };
00096
00097
00098
00099 PlotMouseEvent(PlotCanvas* canvas, Type type, Button button,
00100 const PlotCoordinate& coord);
00101
00102
00103 virtual ~PlotMouseEvent();
00104
00105
00106 void* origin() const { return canvas(); }
00107
00108
00109 PlotCanvas* canvas() const;
00110
00111
00112 Type type() const;
00113
00114
00115 Button button() const;
00116
00117
00118 PlotCoordinate where() const;
00119
00120 protected:
00121 PlotCanvas* m_canvas;
00122 Type m_type;
00123 Button m_button;
00124 PlotCoordinate m_coord;
00125 };
00126
00127
00128
00129 class PlotClickEvent : public PlotMouseEvent {
00130 public:
00131 PlotClickEvent(PlotCanvas* canvas, Button button,
00132 const PlotCoordinate& coord) :
00133 PlotMouseEvent(canvas, CLICK, button, coord) { }
00134
00135 ~PlotClickEvent() { }
00136 };
00137
00138
00139 class PlotMousePressEvent : public PlotMouseEvent {
00140 public:
00141 PlotMousePressEvent(PlotCanvas* canvas, Button button,
00142 const PlotCoordinate& coord) :
00143 PlotMouseEvent(canvas, PRESS, button, coord) { }
00144
00145 ~PlotMousePressEvent() { }
00146 };
00147
00148
00149 class PlotMouseReleaseEvent : public PlotMouseEvent {
00150 public:
00151 PlotMouseReleaseEvent(PlotCanvas* canvas, Button button,
00152 const PlotCoordinate& coord) :
00153 PlotMouseEvent(canvas, RELEASE, button, coord) { }
00154
00155 ~PlotMouseReleaseEvent() { }
00156 };
00157
00158
00159 class PlotMouseDragEvent : public PlotMouseEvent {
00160 public:
00161 PlotMouseDragEvent(PlotCanvas* canvas, Button button,
00162 const PlotCoordinate& coord) :
00163 PlotMouseEvent(canvas, DRAG, button, coord) { }
00164
00165 ~PlotMouseDragEvent() { }
00166 };
00167
00168
00169 class PlotMouseMoveEvent : public PlotMouseEvent {
00170 public:
00171 PlotMouseMoveEvent(PlotCanvas* canvas, Button button,
00172 const PlotCoordinate& coord) :
00173 PlotMouseEvent(canvas, MOVE, button, coord) { }
00174
00175 ~PlotMouseMoveEvent() { }
00176 };
00177
00178
00179
00180
00181
00182
00183 class PlotWheelEvent : public virtual PlotEvent {
00184 public:
00185
00186
00187 PlotWheelEvent(PlotCanvas* canvas, int delta, const PlotCoordinate& c);
00188
00189
00190 ~PlotWheelEvent();
00191
00192
00193 void* origin() const { return canvas(); }
00194
00195
00196 PlotCanvas* canvas() const;
00197
00198
00199 int delta() const;
00200
00201
00202 PlotCoordinate where() const;
00203
00204 protected:
00205 PlotCanvas* m_canvas;
00206 int m_delta;
00207 PlotCoordinate m_coord;
00208 };
00209
00210
00211
00212
00213
00214
00215
00216 class PlotKeyEvent : public virtual PlotEvent {
00217 public:
00218
00219 enum Modifier {
00220 CONTROL, SHIFT, ALT, F
00221 };
00222
00223
00224
00225 PlotKeyEvent(PlotCanvas* canvas, char key, const vector<Modifier>& mods);
00226
00227
00228 ~PlotKeyEvent();
00229
00230
00231 void* origin() const { return canvas(); }
00232
00233
00234 PlotCanvas* canvas() const;
00235
00236
00237 char key() const;
00238
00239
00240 vector<Modifier> modifiers() const;
00241
00242
00243 String toString() const;
00244
00245
00246
00247
00248 static String modifier(Modifier f) {
00249 switch(f) {
00250 case CONTROL: return "Ctrl";
00251 case ALT: return "Alt";
00252 case SHIFT: return "Shift";
00253 case F: return "F";
00254
00255 default: return "?";
00256 }
00257 }
00258 static Modifier modifier(String f) {
00259 f.downcase();
00260
00261 if(f == "ctrl" || f == "control") return CONTROL;
00262 if(f == "shift") return SHIFT;
00263 if(f == "alt") return ALT;
00264 if(f == "f" || f == "function") return F;
00265
00266 return F;
00267 }
00268
00269
00270 protected:
00271 PlotCanvas* m_canvas;
00272 char m_key;
00273 vector<Modifier> m_mods;
00274 };
00275
00276
00277
00278 class PlotResizeEvent : public virtual PlotEvent {
00279 public:
00280
00281 PlotResizeEvent(PlotCanvas* canvas, int oldWidth, int oldHeight,
00282 int newWidth, int newHeight);
00283
00284
00285 PlotResizeEvent(Plotter* plotter, int oldWidth, int oldHeight,
00286 int newWidth, int newHeight);
00287
00288
00289 ~PlotResizeEvent();
00290
00291
00292 void* origin() const {
00293 if(canvas() != NULL) return canvas();
00294 else return plotter();
00295 }
00296
00297
00298 PlotCanvas* canvas() const;
00299
00300
00301 Plotter* plotter() const;
00302
00303
00304 std::pair<int, int> oldSize() const;
00305
00306
00307 std::pair<int, int> newSize() const;
00308
00309 protected:
00310 Plotter* m_plotter;
00311 PlotCanvas* m_canvas;
00312 std::pair<int, int> m_old;
00313 std::pair<int, int> m_new;
00314 };
00315
00316
00317
00318 class PlotButtonEvent : public virtual PlotEvent {
00319 public:
00320
00321 PlotButtonEvent(PlotButton* button);
00322
00323
00324 ~PlotButtonEvent();
00325
00326
00327 void* origin() const { return button(); }
00328
00329
00330 PlotButton* button() const;
00331
00332 protected:
00333 PlotButton* m_button;
00334 };
00335
00336
00337 class PlotCheckboxEvent : public virtual PlotEvent {
00338 public:
00339
00340 PlotCheckboxEvent(PlotCheckbox* checkbox);
00341
00342
00343 ~PlotCheckboxEvent();
00344
00345
00346 void* origin() const { return checkbox(); }
00347
00348
00349 PlotCheckbox* checkbox() const;
00350
00351 protected:
00352 PlotCheckbox* m_checkbox;
00353 };
00354
00355 }
00356
00357 #endif