MySQL Workbench  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
drawbox.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; version 2 of the
7  * License.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17  * 02110-1301 USA
18  */
19 
20 #ifndef _MFORMS_DRAWBOX_H_
21 #define _MFORMS_DRAWBOX_H_
22 
23 #include <mforms/base.h>
24 #include <mforms/view.h>
25 #include <base/geometry.h>
26 
27 #include "cairo/cairo.h"
28 
29 namespace mforms
30 {
31  class DrawBox;
32 
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 #ifndef SWIG
35  struct DrawBoxImplPtrs
36  {
37  bool (*create)(DrawBox *);
38  void (*set_needs_repaint)(DrawBox *);
39  void (*set_needs_repaint_area)(DrawBox *, int, int, int, int);//XXX Windows, Linux
40  void (*add)(DrawBox *, View *, Alignment alignment);
41  void (*remove)(DrawBox *, View *);
42  void (*move)(DrawBox *, View *, int x, int y);
43  };
44 
45  struct MFORMS_EXPORT Accessible
46  {
47  public:
48  enum Role
49  {
50  None,
51  Client,
52  Pane,
53  Link,
54  List,
55  ListItem,
56  PushButton,
57  StaticText,
58  Text,
59  Outline,
60  OutlineButton,
61  OutlineItem
62  };
63 
64  virtual ~Accessible() {};
65 
66  // This each child class should implement it's own way to get the
67  // accessible name and role
68  virtual std::string get_acc_name() = 0;
69  virtual Role get_acc_role() = 0;
70 
71  // The rest of the accessible methods are optional on the child
72  // classes, they must implement them as needed
73  virtual std::string get_acc_description() { return ""; }
74  virtual std::string get_acc_value() { return ""; }
75 
76  virtual int get_acc_child_count() { return 0; }
77  virtual Accessible* get_acc_child(int index) { return NULL; }
78 
79  virtual base::Rect get_acc_bounds() { return base::Rect(); }
80  virtual Accessible* hit_test(int x, int y) { return NULL; }
81 
82  virtual std::string get_acc_default_action() { return ""; }
83  virtual void do_default_action() {};
84  };
85 #endif
86 #endif
87 
88  class MFORMS_EXPORT DrawBox : public View, public Accessible
89  {
90  public:
91  DrawBox();
92 
95  void add(View *view, Alignment alignment);
96 
98  void remove(View *view);
99 
101  void move(View *child, int x, int y);
102 
103  virtual void set_layout_dirty(bool value);
104  void set_padding(int left, int top, int right, int bottom);
105 
106  void set_needs_repaint();
107  void set_needs_repaint_area(int x, int y, int w, int h);
108 #ifndef DOXYGEN_SHOULD_SKIP_THIS
109  virtual void get_layout_size(int* w, int* h);
110 
111 #ifndef SWIG
112  virtual void repaint(cairo_t *cr, int x, int y, int w, int h) {}
113  virtual void cancel_operation() {};
114 
115  virtual std::string get_acc_name() { return get_name(); }
116  virtual base::Rect get_acc_bounds(){ return base::Rect(get_x(), get_y(), get_width(), get_height());}
117  virtual Role get_acc_role() { return mforms::Accessible::None; }
118 #endif
119 #endif
120  protected:
121  DrawBoxImplPtrs *_drawbox_impl;
122  };
123 };
124 
125 #endif
#define MFORMS_EXPORT
Definition: base.h:33
Alignment
Definition: view.h:40
DrawBoxImplPtrs * _drawbox_impl
Definition: drawbox.h:121
MySQL Workbench 6.1 documentation