comparison dynamin/gui/events.d @ 0:aa4efef0f0b1

Initial commit of code.
author Jordan Miner <jminer7@gmail.com>
date Mon, 15 Jun 2009 22:10:48 -0500
parents
children 87265a206638
comparison
equal deleted inserted replaced
-1:000000000000 0:aa4efef0f0b1
1 // Written in the D programming language
2 // www.digitalmars.com/d/
3
4 /*
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is the Dynamin library.
16 *
17 * The Initial Developer of the Original Code is Jordan Miner.
18 * Portions created by the Initial Developer are Copyright (C) 2006-2009
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 * Jordan Miner <jminer7@gmail.com>
23 *
24 */
25
26 module dynamin.gui.events;
27
28 import dynamin.all_core;
29 import dynamin.all_painting;
30 import dynamin.all_gui;
31
32 ///
33 enum MouseButton {
34 None, ///
35 Left, ///
36 Right, ///
37 Middle, ///
38 XButton1, ///
39 XButton2 ///
40 }
41
42 ///
43 class PaintingEventArgs : EventArgs {
44 Graphics g;
45 //NativeGraphics ng;
46 public:
47 ///
48 this(Graphics g) {
49 this.g = g;
50 }
51 ///
52 Graphics graphics() { return g; }
53 }
54
55 ///
56 class MouseEventArgs : StopEventArgs {
57 Point _location;
58 MouseButton _button;
59 public:
60 ///
61 this(real x, real y, MouseButton b) {
62 _location = Point(x, y);
63 _button = b;
64 }
65 ///
66 Point location() { return _location; }
67 ///
68 void location(Point pt) { _location = pt; }
69 ///
70 real x() { return _location.x; }
71 ///
72 real y() { return _location.y; }
73 ///
74 MouseButton button() { return _button; }
75 }
76 ///
77 class MouseTurnedEventArgs : StopEventArgs {
78 int _delta;
79 double _scrollAmount;
80 public:
81 this(int delta, double scrollAmount) {
82 _delta = delta;
83 _scrollAmount = scrollAmount;
84 }
85 /*
86 * This is the amount the mouse wheel was turned.
87 */
88 //int delta() { return _delta; }
89 /**
90 * The amount that a control should scroll in response to this event.
91 * In a text control, this is the number of lines to scroll.
92 * This will be negative if the control should scroll upward and positive
93 * if the control should scroll downward. If the amount to be scrolled
94 * is more than what is visible on screen, only what is on screen
95 * should be scrolled.
96 *
97 * All users of this class should check scrollScreen to see whether to
98 * scroll one screen or to scroll the amount by this.
99 */
100 double scrollAmount() { return _scrollAmount; }
101 /**
102 * On some systems, such as Windows, there is the option of setting
103 * the mouse wheel to scroll a screen at a time, the same as the page up
104 * and page down keys do. If this option is turned on, scrollScreen will
105 * return true and scrollAmount will return ±3. If the option is turned off,
106 * scrollScreen will return false.
107 */
108 bool scrollScreen() {
109 return false;
110 }
111 }
112 ///
113 class KeyEventArgs : StopEventArgs {
114 Key _key;
115 bool _repeat;
116 public:
117 this(Key key, bool repeat) {
118 _key = key;
119 _repeat = repeat;
120 }
121 /**
122 * Returns: the key that was typed.
123 */
124 Key key() { return _key; }
125 /**
126 * Gets whether this key event was generated by the user holding
127 * down the key.
128 * Returns: true if the key was already down before this event, false
129 * if the key was just pressed
130 */
131 bool repeat() { return _repeat; }
132 }
133 ///
134 class KeyTypedEventArgs : StopEventArgs {
135 dchar _ch;
136 bool _repeat;
137 public:
138 this(dchar c, bool repeat) {
139 _ch = c;
140 _repeat = repeat;
141 }
142 /**
143 * Gets whether this key event was generated from the user holding
144 * down the key.
145 * Returns: true if the key was already down before this event, false
146 * if the key was just pressed
147 */
148 bool repeat() { return _repeat; }
149 /**
150 * Gets the character that was typed by the user. Many keys on the
151 * keyboard will not generate a KeyTyped event, as they do not represent
152 * characters. Shift, Insert, Home, F7, and Caps Lock are just some of
153 * the keys that do not represent characters.
154 */
155 dchar character() { return _ch; }
156 }
157