From 67df0a783f1a08dac3fbea79d732bda5806fd938 Mon Sep 17 00:00:00 2001 From: Anton Gorenko Date: Mon, 24 May 2010 16:08:26 +0600 Subject: [PATCH] add window-controls implementation (without 'textured-background') --- basis/ui/backend/gtk/gtk.factor | 48 ++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/basis/ui/backend/gtk/gtk.factor b/basis/ui/backend/gtk/gtk.factor index 3b45a47427..b984c46563 100644 --- a/basis/ui/backend/gtk/gtk.factor +++ b/basis/ui/backend/gtk/gtk.factor @@ -2,9 +2,9 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors alien.enums alien.strings arrays ascii assocs classes.struct combinators.short-circuit command-line destructors -io.encodings.utf8 kernel literals locals math namespaces -sequences strings ui ui.backend ui.clipboards ui.event-loop -ui.gadgets ui.gadgets.private ui.gestures ui.private +io.encodings.utf8 kernel literals locals math math.bitwise +namespaces sequences strings ui ui.backend ui.clipboards ui.event-loop +ui.gadgets ui.gadgets.private ui.gadgets.worlds ui.gestures ui.private glib glib.ffi gobject gobject.ffi gtk gtk.ffi gdk gdk.ffi gdk.gl gtk.gl gdk.gl.ffi gtk.gl.ffi ; IN: ui.backend.gtk @@ -235,14 +235,54 @@ M: gtk-ui-backend (with-ui) gdk_gl_config_new_by_mode f t GDK_GL_RGBA_TYPE enum>number gtk_widget_set_gl_capability ; +CONSTANT: window-controls>decor-flags + H{ + { close-button 0 } + { minimize-button $[ GDK_DECOR_MINIMIZE enum>number ] } + { maximize-button $[ GDK_DECOR_MAXIMIZE enum>number ] } + { resize-handles $[ GDK_DECOR_RESIZEH enum>number ] } + { small-title-bar $[ GDK_DECOR_TITLE enum>number ] } + { normal-title-bar $[ GDK_DECOR_TITLE enum>number ] } + { textured-background 0 } + } + +CONSTANT: window-controls>func-flags + H{ + { close-button $[ GDK_FUNC_CLOSE enum>number ] } + { minimize-button $[ GDK_FUNC_MINIMIZE enum>number ] } + { maximize-button $[ GDK_FUNC_MAXIMIZE enum>number ] } + { resize-handles $[ GDK_FUNC_RESIZE enum>number ] } + { small-title-bar 0 } + { normal-title-bar 0 } + { textured-background 0 } + } + +: configure-window-controls ( win controls -- ) + [ + small-title-bar swap member-eq? + GDK_WINDOW_TYPE_HINT_UTILITY GDK_WINDOW_TYPE_HINT_NORMAL ? + gtk_window_set_type_hint + ] [ + [ gtk_widget_get_window ] dip + window-controls>decor-flags symbols>flags + GDK_DECOR_BORDER enum>number bitor gdk_window_set_decorations + ] [ + [ gtk_widget_get_window ] dip + window-controls>func-flags symbols>flags + GDK_FUNC_MOVE enum>number bitor gdk_window_set_functions + ] 2tri ; + M:: gtk-ui-backend (open-window) ( world -- ) GTK_WINDOW_TOPLEVEL gtk_window_new :> win world [ window-loc>> win swap first2 gtk_window_move ] [ dim>> win swap first2 gtk_window_set_default_size ] bi win enable-gl drop ! сделать проверку на доступность OpenGL - + win connect-signals + + win gtk_widget_realize + win world window-controls>> configure-window-controls win world handle<< world win register-window