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