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