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"
33 Accelerator(guint _key)
34 : key(_key), modifiers((GdkModifierType)0)
37 Accelerator(guint _key, GdkModifierType _modifiers)
38 : key(_key), modifiers(_modifiers)
41 bool operator<(const Accelerator& other) const
43 return key < other.key || (!(other.key < key) && modifiers < other.modifiers);
46 GdkModifierType modifiers;
49 inline Accelerator accelerator_null()
51 return Accelerator(0, (GdkModifierType)0);
55 void keydown_accelerators_add(Accelerator accelerator, const Callback& callback);
56 void keydown_accelerators_remove(Accelerator accelerator);
57 void keyup_accelerators_add(Accelerator accelerator, const Callback& callback);
58 void keyup_accelerators_remove(Accelerator accelerator);
60 typedef struct _GtkWidget GtkWidget;
61 typedef struct _GtkWindow GtkWindow;
62 void global_accel_connect_window(GtkWindow* window);
63 void global_accel_disconnect_window(GtkWindow* window);
65 void GlobalPressedKeys_releaseAll();
67 typedef struct _GtkAccelGroup GtkAccelGroup;
68 extern GtkAccelGroup* global_accel;
69 void global_accel_init();
70 void global_accel_destroy();
72 GClosure* global_accel_group_find(Accelerator accelerator);
74 void command_connect_accelerator(const Accelerator& accelerator, const Callback& callback);
75 void command_disconnect_accelerator(const Accelerator& accelerator, const Callback& callback);
82 const Accelerator& m_accelerator;
83 Command(const Callback& callback, const Accelerator& accelerator) : m_callback(callback), m_accelerator(accelerator)
92 BoolExportCallback m_exportCallback;
93 Toggle(const Callback& callback, const Accelerator& accelerator, const BoolExportCallback& exportCallback) : m_command(callback, accelerator), m_exportCallback(exportCallback)
101 const Accelerator& m_accelerator;
104 KeyEvent(const Accelerator& accelerator, const Callback& keyDown, const Callback& keyUp) : m_accelerator(accelerator), m_keyDown(keyDown), m_keyUp(keyUp)
111 struct PressedButtons;
112 typedef struct _GtkWidget GtkWidget;
113 void PressedButtons_connect(PressedButtons& pressedButtons, GtkWidget* widget);
115 extern PressedButtons g_pressedButtons;