Panda3D
 All Classes Functions Variables Enumerations
mouseWatcherParameter.h
00001 // Filename: mouseWatcherParameter.h
00002 // Created by:  drose (06Jul01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef MOUSEWATCHERPARAMETER_H
00016 #define MOUSEWATCHERPARAMETER_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "buttonHandle.h"
00021 #include "modifierButtons.h"
00022 #include "textEncoder.h"
00023 #include "luse.h"
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : MouseWatcherParameter
00027 // Description : This is sent along as a parameter to most events
00028 //               generated for a region to indicate the mouse and
00029 //               button state for the event.
00030 ////////////////////////////////////////////////////////////////////
00031 class EXPCL_PANDA_TFORM MouseWatcherParameter {
00032 public:
00033   INLINE MouseWatcherParameter();
00034   INLINE MouseWatcherParameter(const MouseWatcherParameter &other);
00035   INLINE void operator = (const MouseWatcherParameter &other);
00036   INLINE ~MouseWatcherParameter();
00037 
00038   INLINE void set_button(const ButtonHandle &button);
00039   INLINE void set_keyrepeat(bool flag);
00040   INLINE void set_keycode(int keycode);
00041   INLINE void set_candidate(const wstring &candidate_string,
00042                             size_t highlight_start, 
00043                             size_t higlight_end,
00044                             size_t cursor_pos);
00045   INLINE void set_modifier_buttons(const ModifierButtons &mods);
00046   INLINE void set_mouse(const LPoint2 &mouse);
00047   INLINE void set_outside(bool flag);
00048 
00049 PUBLISHED:
00050   INLINE bool has_button() const;
00051   INLINE ButtonHandle get_button() const;
00052   INLINE bool is_keyrepeat() const;
00053 
00054   INLINE bool has_keycode() const;
00055   INLINE int get_keycode() const;
00056 
00057   INLINE bool has_candidate() const;
00058 
00059 public:
00060   INLINE const wstring &get_candidate_string() const;
00061 
00062 PUBLISHED:
00063   INLINE string get_candidate_string_encoded() const;
00064   INLINE string get_candidate_string_encoded(TextEncoder::Encoding encoding) const;
00065   INLINE size_t get_highlight_start() const;
00066   INLINE size_t get_highlight_end() const;
00067   INLINE size_t get_cursor_pos() const;
00068 
00069   INLINE const ModifierButtons &get_modifier_buttons() const;
00070 
00071   INLINE bool has_mouse() const;
00072   INLINE const LPoint2 &get_mouse() const;
00073 
00074   INLINE bool is_outside() const;
00075 
00076   void output(ostream &out) const;
00077 
00078 public:
00079   ButtonHandle _button;
00080   short _keycode;
00081   wstring _candidate_string;
00082   size_t _highlight_start;
00083   size_t _highlight_end;
00084   size_t _cursor_pos;
00085   ModifierButtons _mods;
00086   LPoint2 _mouse;
00087 
00088   enum Flags {
00089     F_has_button    = 0x001,
00090     F_has_mouse     = 0x002,
00091     F_is_outside    = 0x004,
00092     F_has_keycode   = 0x008,
00093     F_has_candidate = 0x010,
00094     F_is_keyrepeat  = 0x020,
00095   };
00096   int _flags;
00097 };
00098 
00099 INLINE ostream &operator << (ostream &out, const MouseWatcherParameter &parm);
00100 
00101 #include "mouseWatcherParameter.I"
00102 
00103 #endif
 All Classes Functions Variables Enumerations