2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gdk-Events.html
52 * - GdkDisplay* -> Display
53 * - GdkEvent* -> Event
54 * - GdkScreen* -> Screen
55 * - GdkWindow* -> Window
66 import tango
.io
.Stdout
; // use the tango loging?
70 private import gtkc
.gdktypes
;
72 private import gtkc
.gdk
;
75 private import glib
.Str
;
76 private import gdk
.Event
;
77 private import gdk
.Window
;
78 private import gdk
.Display
;
79 private import gdk
.Screen
;
80 private import gobject
.Value
;
87 * This section describes functions dealing with events from the window system.
88 * In GTK+ applications the events are handled automatically in
89 * gtk_main_do_event() and passed on to the appropriate widgets, so these
90 * functions are rarely needed. Though some of the fields in the
91 * Event Structures are useful.
96 /** the main Gtk struct */
97 protected GdkEvent
* gdkEvent
;
100 public GdkEvent
* getEventStruct()
106 /** the main Gtk struct as a void* */
107 protected void* getStruct()
109 return cast(void*)gdkEvent
;
113 * Sets our main struct and passes it to the parent class
115 public this (GdkEvent
* gdkEvent
)
119 if ( gdkEvent
is null )
124 Stdout("struct gdkEvent is null on constructor").newline
;
128 printf("struct gdkEvent is null on constructor");
135 assert(gdkEvent
!is null, "struct gdkEvent is null on constructor");
137 this.gdkEvent
= gdkEvent
;
140 public static bool isDoubleClick(GdkEventButton
* eventButton
, int buttonNumber
=1)
142 return eventButton
.button
==buttonNumber
143 && eventButton
.type
== EventType
.DOUBLE_BUTTON_PRESS
;
146 public static bool isTrippleClick(GdkEventButton
* eventButton
, int buttonNumber
=1)
148 return eventButton
.button
==buttonNumber
149 && eventButton
.type
== EventType
.TRIPPLE_BUTTON_PRESS
;
161 * Checks if any events are ready to be processed for any display.
163 * TRUE if any events are pending.
165 public static int gdkEventsPending()
167 // gboolean gdk_events_pending (void);
168 return gdk_events_pending();
172 * If there is an event waiting in the event queue of some open
173 * display, returns a copy of it. See gdk_display_peek_event().
175 * a copy of the first GdkEvent on some event queue, or NULL if no
176 * events are in any queues. The returned GdkEvent should be freed with
179 public static Event
peek()
181 // GdkEvent* gdk_event_peek (void);
182 return new Event( gdk_event_peek() );
186 * Checks all open displays for a GdkEvent to process,to be processed
187 * on, fetching events from the windowing system if necessary.
188 * See gdk_display_get_event().
190 * the next GdkEvent to be processed, or NULL if no events
191 * are pending. The returned GdkEvent should be freed with gdk_event_free().
193 public static Event
get()
195 // GdkEvent* gdk_event_get (void);
196 return new Event( gdk_event_get() );
200 * Waits for a GraphicsExpose or NoExpose event from the X server.
201 * This is used in the GtkText and GtkCList widgets in GTK+ to make sure any
202 * GraphicsExpose events are handled before the widget is scrolled.
204 * the GdkWindow to wait for the events for.
206 * a GdkEventExpose if a GraphicsExpose was received, or NULL if a
207 * NoExpose event was received.
209 public static Event
getGraphicsExpose(Window window
)
211 // GdkEvent* gdk_event_get_graphics_expose (GdkWindow *window);
212 return new Event( gdk_event_get_graphics_expose((window
is null) ?
null : window
.getWindowStruct()) );
216 * Appends a copy of the given event onto the front of the event
217 * queue for event->any.window's display, or the default event
218 * queue if event->any.window is NULL. See gdk_display_put_event().
224 // void gdk_event_put (GdkEvent *event);
225 gdk_event_put(gdkEvent
);
229 * Creates a new event of the given type. All fields are set to 0.
233 * a newly-allocated GdkEvent. The returned GdkEvent
234 * should be freed with gdk_event_free().
237 public this (GdkEventType type
)
239 // GdkEvent* gdk_event_new (GdkEventType type);
240 this(cast(GdkEvent
*)gdk_event_new(type
) );
244 * Copies a GdkEvent, copying or incrementing the reference count of the
245 * resources associated with it (e.g. GdkWindow's and strings).
249 * a copy of event. The returned GdkEvent should be freed with
254 // GdkEvent* gdk_event_copy (GdkEvent *event);
255 return new Event( gdk_event_copy(gdkEvent
) );
259 * Frees a GdkEvent, freeing or decrementing any resources associated with it.
260 * Note that this function should only be called with events returned from
261 * functions such as gdk_event_peek(), gdk_event_get(),
262 * gdk_event_get_graphics_expose() and gdk_event_copy().
268 // void gdk_event_free (GdkEvent *event);
269 gdk_event_free(gdkEvent
);
273 * Returns the time stamp from event, if there is one; otherwise
274 * returns GDK_CURRENT_TIME. If event is NULL, returns GDK_CURRENT_TIME.
278 * time stamp field from event
280 public uint getTime()
282 // guint32 gdk_event_get_time (GdkEvent *event);
283 return gdk_event_get_time(gdkEvent
);
287 * If the event contains a "state" field, puts that field in state. Otherwise
288 * stores an empty state (0). Returns TRUE if there was a state field
289 * in the event. event may be NULL, in which case it's treated
290 * as if the event had no state field.
294 * return location for state
296 * TRUE if there was a state field in the event
298 public int getState(GdkModifierType
* state
)
300 // gboolean gdk_event_get_state (GdkEvent *event, GdkModifierType *state);
301 return gdk_event_get_state(gdkEvent
, state
);
305 * Extract the axis value for a particular axis use from
306 * an event structure.
310 * the axis use to look for
312 * location to store the value found
314 * TRUE if the specified axis was found, otherwise FALSE
316 public int getAxis(GdkAxisUse axisUse
, double* value
)
318 // gboolean gdk_event_get_axis (GdkEvent *event, GdkAxisUse axis_use, gdouble *value);
319 return gdk_event_get_axis(gdkEvent
, axisUse
, value
);
323 * Extract the event window relative x/y coordinates from an event.
327 * location to put event window x coordinate
329 * location to put event window y coordinate
331 * TRUE if the event delivered event window coordinates
333 public int getCoords(double* xWin
, double* yWin
)
335 // gboolean gdk_event_get_coords (GdkEvent *event, gdouble *x_win, gdouble *y_win);
336 return gdk_event_get_coords(gdkEvent
, xWin
, yWin
);
340 * Extract the root window relative x/y coordinates from an event.
344 * location to put root window x coordinate
346 * location to put root window y coordinate
348 * TRUE if the event delivered root window coordinates
350 public int getRootCoords(double* xRoot
, double* yRoot
)
352 // gboolean gdk_event_get_root_coords (GdkEvent *event, gdouble *x_root, gdouble *y_root);
353 return gdk_event_get_root_coords(gdkEvent
, xRoot
, yRoot
);
357 * Sets the function to call to handle all events from GDK.
358 * Note that GTK+ uses this to install its own event handler, so it is
359 * usually not useful for GTK+ applications. (Although an application
360 * can call this function then call gtk_main_do_event() to pass
363 * the function to call to handle events from GDK.
365 * user data to pass to the function.
367 * the function to call when the handler function is removed, i.e. when
368 * gdk_event_handler_set() is called with another event handler.
370 public static void handlerSet(GdkEventFunc func
, void* data
, GDestroyNotify notify
)
372 // void gdk_event_handler_set (GdkEventFunc func, gpointer data, GDestroyNotify notify);
373 gdk_event_handler_set(func
, data
, notify
);
378 * Sends an X ClientMessage event to a given window (which must be
379 * on the default GdkDisplay.)
380 * This could be used for communicating between different applications,
381 * though the amount of data is limited to 20 bytes.
383 * the GdkEvent to send, which should be a GdkEventClient.
385 * the window to send the X ClientMessage event to.
387 * non-zero on success.
389 public int sendClientMessage(GdkNativeWindow winid
)
391 // gboolean gdk_event_send_client_message (GdkEvent *event, GdkNativeWindow winid);
392 return gdk_event_send_client_message(gdkEvent
, winid
);
396 * On X11, sends an X ClientMessage event to a given window. On
397 * Windows, sends a message registered with the name
398 * GDK_WIN32_CLIENT_MESSAGE.
399 * This could be used for communicating between different
400 * applications, though the amount of data is limited to 20 bytes on
401 * X11, and to just four bytes on Windows.
403 * the GdkDisplay for the window where the message is to be sent.
405 * the GdkEvent to send, which should be a GdkEventClient.
407 * the window to send the client message to.
409 * non-zero on success.
412 public static int sendClientMessageForDisplay(Display display
, Event event
, GdkNativeWindow winid
)
414 // gboolean gdk_event_send_client_message_for_display (GdkDisplay *display, GdkEvent *event, GdkNativeWindow winid);
415 return gdk_event_send_client_message_for_display((display
is null) ?
null : display
.getDisplayStruct(), (event
is null) ?
null : event
.getEventStruct(), winid
);
419 * Sends an X ClientMessage event to all toplevel windows on the default
421 * Toplevel windows are determined by checking for the WM_STATE property, as
422 * described in the Inter-Client Communication Conventions Manual (ICCCM).
423 * If no windows are found with the WM_STATE property set, the message is sent
424 * to all children of the root window.
426 * the GdkEvent to send, which should be a GdkEventClient.
428 public void sendClientmessageToall()
430 // void gdk_event_send_clientmessage_toall (GdkEvent *event);
431 gdk_event_send_clientmessage_toall(gdkEvent
);
435 * Adds a filter to the default display to be called when X ClientMessage events
436 * are received. See gdk_display_add_client_message_filter().
438 * the type of ClientMessage events to receive. This will be
439 * checked against the message_type field of the
440 * XClientMessage event struct.
442 * the function to call to process the event.
444 * user data to pass to func.
446 public static void gdkAddClientMessageFilter(GdkAtom messageType
, GdkFilterFunc func
, void* data
)
448 // void gdk_add_client_message_filter (GdkAtom message_type, GdkFilterFunc func, gpointer data);
449 gdk_add_client_message_filter(messageType
, func
, data
);
453 * Gets whether event debugging output is enabled.
455 * TRUE if event debugging output is enabled.
457 public static int gdkGetShowEvents()
459 // gboolean gdk_get_show_events (void);
460 return gdk_get_show_events();
464 * Sets whether a trace of received events is output.
465 * Note that GTK+ must be compiled with debugging (that is,
466 * configured using the --enable-debug option)
467 * to use this option.
469 * TRUE to output event debugging information.
471 public static void gdkSetShowEvents(int showEvents
)
473 // void gdk_set_show_events (gboolean show_events);
474 gdk_set_show_events(showEvents
);
478 * Sets the screen for event to screen. The event must
479 * have been allocated by GTK+, for instance, by
487 public void setScreen(Screen screen
)
489 // void gdk_event_set_screen (GdkEvent *event, GdkScreen *screen);
490 gdk_event_set_screen(gdkEvent
, (screen
is null) ?
null : screen
.getScreenStruct());
494 * Returns the screen for the event. The screen is
495 * typically the screen for event->any.window, but
496 * for events such as mouse events, it is the screen
497 * where the pointer was when the event occurs -
498 * that is, the screen which has the root window
499 * to which event->motion.x_root and
500 * event->motion.y_root are relative.
504 * the screen for the event
507 public Screen
getScreen()
509 // GdkScreen* gdk_event_get_screen (GdkEvent *event);
510 return new Screen( gdk_event_get_screen(gdkEvent
) );
514 * Obtains a desktop-wide setting, such as the double-click time,
515 * for the default screen. See gdk_screen_get_setting().
517 * the name of the setting.
519 * location to store the value of the setting.
521 * : TRUE if the setting existed and a value was stored
522 * in value, FALSE otherwise.
525 * The structs used for each type of event.
527 public static int gdkSettingGet(char[] name
, Value value
)
529 // gboolean gdk_setting_get (const gchar *name, GValue *value);
530 return gdk_setting_get(Str
.toStringz(name
), (value
is null) ?
null : value
.getValueStruct());