Panda3D
 All Classes Functions Variables Enumerations
mouseWatcherParameter.h
1 // Filename: mouseWatcherParameter.h
2 // Created by: drose (06Jul01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef MOUSEWATCHERPARAMETER_H
16 #define MOUSEWATCHERPARAMETER_H
17 
18 #include "pandabase.h"
19 
20 #include "buttonHandle.h"
21 #include "modifierButtons.h"
22 #include "textEncoder.h"
23 #include "luse.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : MouseWatcherParameter
27 // Description : This is sent along as a parameter to most events
28 // generated for a region to indicate the mouse and
29 // button state for the event.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_TFORM MouseWatcherParameter {
32 public:
33  INLINE MouseWatcherParameter();
34  INLINE MouseWatcherParameter(const MouseWatcherParameter &other);
35  INLINE void operator = (const MouseWatcherParameter &other);
36  INLINE ~MouseWatcherParameter();
37 
38  INLINE void set_button(const ButtonHandle &button);
39  INLINE void set_keyrepeat(bool flag);
40  INLINE void set_keycode(int keycode);
41  INLINE void set_candidate(const wstring &candidate_string,
42  size_t highlight_start,
43  size_t higlight_end,
44  size_t cursor_pos);
45  INLINE void set_modifier_buttons(const ModifierButtons &mods);
46  INLINE void set_mouse(const LPoint2 &mouse);
47  INLINE void set_outside(bool flag);
48 
49 PUBLISHED:
50  INLINE bool has_button() const;
51  INLINE ButtonHandle get_button() const;
52  INLINE bool is_keyrepeat() const;
53 
54  INLINE bool has_keycode() const;
55  INLINE int get_keycode() const;
56 
57  INLINE bool has_candidate() const;
58 
59 public:
60  INLINE const wstring &get_candidate_string() const;
61 
62 PUBLISHED:
63  INLINE string get_candidate_string_encoded() const;
64  INLINE string get_candidate_string_encoded(TextEncoder::Encoding encoding) const;
65  INLINE size_t get_highlight_start() const;
66  INLINE size_t get_highlight_end() const;
67  INLINE size_t get_cursor_pos() const;
68 
69  INLINE const ModifierButtons &get_modifier_buttons() const;
70 
71  INLINE bool has_mouse() const;
72  INLINE const LPoint2 &get_mouse() const;
73 
74  INLINE bool is_outside() const;
75 
76  void output(ostream &out) const;
77 
78 public:
79  ButtonHandle _button;
80  short _keycode;
81  wstring _candidate_string;
82  size_t _highlight_start;
83  size_t _highlight_end;
84  size_t _cursor_pos;
85  ModifierButtons _mods;
86  LPoint2 _mouse;
87 
88  enum Flags {
89  F_has_button = 0x001,
90  F_has_mouse = 0x002,
91  F_is_outside = 0x004,
92  F_has_keycode = 0x008,
93  F_has_candidate = 0x010,
94  F_is_keyrepeat = 0x020,
95  };
96  int _flags;
97 };
98 
99 INLINE ostream &operator << (ostream &out, const MouseWatcherParameter &parm);
100 
101 #include "mouseWatcherParameter.I"
102 
103 #endif
This class monitors the state of a number of individual buttons and tracks whether each button is kno...
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
Definition: buttonHandle.h:28
This is a two-component point in space.
Definition: lpoint2.h:92
This is sent along as a parameter to most events generated for a region to indicate the mouse and but...