2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined(INCLUDED_GTKUTIL_ACCELERATOR_H)
23 #define INCLUDED_GTKUTIL_ACCELERATOR_H
25 #include <gdk/gdktypes.h>
26 #include <gdk/gdkkeysyms.h>
28 #include "generic/callback.h"
32 Accelerator(guint _key)
33 : key(_key), modifiers((GdkModifierType)0)
36 Accelerator(guint _key, GdkModifierType _modifiers)
37 : key(_key), modifiers(_modifiers)
40 bool operator<(const Accelerator& other) const
42 return key < other.key || (!(other.key < key) && modifiers < other.modifiers);
45 GdkModifierType modifiers;
48 inline Accelerator accelerator_null()
50 return Accelerator(0, (GdkModifierType)0);
53 const char* global_keys_find(unsigned int key);
54 unsigned int global_keys_find(const char* name);
56 class TextOutputStream;
57 void accelerator_write(const Accelerator& accelerator, TextOutputStream& ostream);
59 template<typename TextOutputStreamType>
60 TextOutputStreamType& ostream_write(TextOutputStreamType& ostream, const Accelerator& accelerator)
62 accelerator_write(accelerator, ostream);
66 void keydown_accelerators_add(Accelerator accelerator, const Callback& callback);
67 void keydown_accelerators_remove(Accelerator accelerator);
68 void keyup_accelerators_add(Accelerator accelerator, const Callback& callback);
69 void keyup_accelerators_remove(Accelerator accelerator);
71 typedef struct _GtkWidget GtkWidget;
72 typedef struct _GtkWindow GtkWindow;
73 void global_accel_connect_window(GtkWindow* window);
74 void global_accel_disconnect_window(GtkWindow* window);
76 void GlobalPressedKeys_releaseAll();
78 typedef struct _GtkAccelGroup GtkAccelGroup;
79 extern GtkAccelGroup* global_accel;
80 void global_accel_init();
81 void global_accel_destroy();
83 GClosure* global_accel_group_find(Accelerator accelerator);
85 void global_accel_group_connect(const Accelerator& accelerator, const Callback& callback);
86 void global_accel_group_disconnect(const Accelerator& accelerator, const Callback& callback);
93 const Accelerator& m_accelerator;
94 Command(const Callback& callback, const Accelerator& accelerator) : m_callback(callback), m_accelerator(accelerator)
103 BoolExportCallback m_exportCallback;
104 Toggle(const Callback& callback, const Accelerator& accelerator, const BoolExportCallback& exportCallback) : m_command(callback, accelerator), m_exportCallback(exportCallback)
112 const Accelerator& m_accelerator;
115 KeyEvent(const Accelerator& accelerator, const Callback& keyDown, const Callback& keyUp) : m_accelerator(accelerator), m_keyDown(keyDown), m_keyUp(keyUp)
122 struct PressedButtons;
123 typedef struct _GtkWidget GtkWidget;
124 void PressedButtons_connect(PressedButtons& pressedButtons, GtkWidget* widget);
126 extern PressedButtons g_pressedButtons;