├── AUTHORS ├── CMakeLists.txt ├── Doxyfile ├── INSTALL ├── LICENSES └── LGPL-2.0-or-later.txt ├── README ├── TODO ├── cmake_uninstall.cmake.in ├── config.h.cmake ├── demo ├── CMakeLists.txt ├── oxygenbuttondemowidget.cpp ├── oxygenbuttondemowidget.h ├── oxygendemodialog.cpp ├── oxygendemodialog.h ├── oxygendemowidget.cpp ├── oxygendemowidget.h ├── oxygenframedemowidget.cpp ├── oxygenframedemowidget.h ├── oxygengtkdeco_main.cpp ├── oxygengtkdemo_main.cpp ├── oxygeninfowidget.cpp ├── oxygeninfowidget.h ├── oxygeninputdemowidget.cpp ├── oxygeninputdemowidget.h ├── oxygenlistdemowidget.cpp ├── oxygenlistdemowidget.h ├── oxygensignal.cpp ├── oxygensignal.h ├── oxygensignalhandler.cpp ├── oxygensignalhandler.h ├── oxygensliderdemowidget.cpp ├── oxygensliderdemowidget.h ├── oxygentabdemowidget.cpp ├── oxygentabdemowidget.h ├── oxygentimer.cpp ├── oxygentimer.h ├── oxygenversion.cpp └── oxygenversion.h ├── rc ├── CMakeLists.txt ├── argb-apps.conf ├── gtkrc ├── icons4 ├── kdeglobals └── oxygenrc ├── special-icons ├── CMakeLists.txt ├── standardbutton-closetab-16.png ├── standardbutton-closetab-down-16.png └── standardbutton-closetab-hover-16.png └── src ├── CMakeLists.txt ├── animations ├── oxygenanimationengine.h ├── oxygenanimations.cpp ├── oxygenanimations.h ├── oxygenarrowstatedata.cpp ├── oxygenarrowstatedata.h ├── oxygenarrowstateengine.h ├── oxygenbackgroundhintengine.cpp ├── oxygenbackgroundhintengine.h ├── oxygenbaseengine.cpp ├── oxygenbaseengine.h ├── oxygencomboboxdata.cpp ├── oxygencomboboxdata.h ├── oxygencomboboxengine.h ├── oxygencomboboxentrydata.cpp ├── oxygencomboboxentrydata.h ├── oxygencomboboxentryengine.h ├── oxygencomboengine.h ├── oxygendatamap.h ├── oxygendialogengine.cpp ├── oxygendialogengine.h ├── oxygenflatwidgetengine.cpp ├── oxygenflatwidgetengine.h ├── oxygenfollowmousedata.cpp ├── oxygenfollowmousedata.h ├── oxygengenericengine.h ├── oxygengroupboxengine.h ├── oxygengroupboxlabeldata.h ├── oxygengroupboxlabelengine.h ├── oxygenhook.cpp ├── oxygenhook.h ├── oxygenhoverdata.cpp ├── oxygenhoverdata.h ├── oxygenhoverengine.h ├── oxygeninnershadowdata.cpp ├── oxygeninnershadowdata.h ├── oxygeninnershadowengine.h ├── oxygenmainwindowdata.cpp ├── oxygenmainwindowdata.h ├── oxygenmainwindowengine.h ├── oxygenmenubarstatedata.cpp ├── oxygenmenubarstatedata.h ├── oxygenmenubarstateengine.h ├── oxygenmenuitemdata.cpp ├── oxygenmenuitemdata.h ├── oxygenmenuitemengine.cpp ├── oxygenmenuitemengine.h ├── oxygenmenustatedata.cpp ├── oxygenmenustatedata.h ├── oxygenmenustateengine.h ├── oxygenpaneddata.cpp ├── oxygenpaneddata.h ├── oxygenpanedengine.h ├── oxygenscrollbardata.cpp ├── oxygenscrollbardata.h ├── oxygenscrollbarengine.h ├── oxygenscrollbarstatedata.cpp ├── oxygenscrollbarstatedata.h ├── oxygenscrollbarstateengine.h ├── oxygenscrolledwindowdata.cpp ├── oxygenscrolledwindowdata.h ├── oxygenscrolledwindowengine.h ├── oxygensignal.cpp ├── oxygensignal.h ├── oxygentabwidgetdata.cpp ├── oxygentabwidgetdata.h ├── oxygentabwidgetengine.h ├── oxygentabwidgetstatedata.cpp ├── oxygentabwidgetstatedata.h ├── oxygentabwidgetstateengine.h ├── oxygentimeline.cpp ├── oxygentimeline.h ├── oxygentimelineserver.cpp ├── oxygentimelineserver.h ├── oxygentimer.cpp ├── oxygentimer.h ├── oxygentoolbarstatedata.cpp ├── oxygentoolbarstatedata.h ├── oxygentoolbarstateengine.h ├── oxygentreeviewdata.cpp ├── oxygentreeviewdata.h ├── oxygentreeviewengine.cpp ├── oxygentreeviewengine.h ├── oxygentreeviewstatedata.cpp ├── oxygentreeviewstatedata.h ├── oxygentreeviewstateengine.h ├── oxygenwidgetsizedata.cpp ├── oxygenwidgetsizedata.h ├── oxygenwidgetsizeengine.h ├── oxygenwidgetstatedata.cpp ├── oxygenwidgetstatedata.h ├── oxygenwidgetstateengine.cpp └── oxygenwidgetstateengine.h ├── debug ├── oxygenwidgetexplorer.cpp └── oxygenwidgetexplorer.h ├── oxygen.h ├── oxygenanimationdata.h ├── oxygenanimationmodes.h ├── oxygenapplicationname.cpp ├── oxygenapplicationname.h ├── oxygenargbhelper.cpp ├── oxygenargbhelper.h ├── oxygencache.h ├── oxygencachekey.h ├── oxygencairocontext.cpp ├── oxygencairocontext.h ├── oxygencairopattern.h ├── oxygencairosurface.h ├── oxygencairosurfacecache.h ├── oxygencairoutils.cpp ├── oxygencairoutils.h ├── oxygencoloreffect.cpp ├── oxygencoloreffect.h ├── oxygencolorutils.cpp ├── oxygencolorutils.h ├── oxygendefines.h ├── oxygenflags.h ├── oxygenfontinfo.cpp ├── oxygenfontinfo.h ├── oxygengeometry.h ├── oxygengtkcellinfo.cpp ├── oxygengtkcellinfo.h ├── oxygengtkdetails.h ├── oxygengtkgap.h ├── oxygengtkicons.cpp ├── oxygengtkicons.h ├── oxygengtkrc.cpp ├── oxygengtkrc.h ├── oxygengtktypenames.cpp ├── oxygengtktypenames.h ├── oxygengtkutils.cpp ├── oxygengtkutils.h ├── oxygenloghandler.cpp ├── oxygenloghandler.h ├── oxygenmetrics.h ├── oxygenobjectcounter.cpp ├── oxygenobjectcounter.h ├── oxygenobjectcountermap.cpp ├── oxygenobjectcountermap.h ├── oxygenoption.cpp ├── oxygenoption.h ├── oxygenoptionmap.cpp ├── oxygenoptionmap.h ├── oxygenpalette.cpp ├── oxygenpalette.h ├── oxygenpathlist.cpp ├── oxygenpathlist.h ├── oxygenpropertynames.cpp ├── oxygenpropertynames.h ├── oxygenqtsettings.cpp ├── oxygenqtsettings.h ├── oxygenrcstyle.cpp ├── oxygenrcstyle.h ├── oxygenrgba.cpp ├── oxygenrgba.h ├── oxygenshadowconfiguration.cpp ├── oxygenshadowconfiguration.h ├── oxygenshadowhelper.cpp ├── oxygenshadowhelper.h ├── oxygenstyle.cpp ├── oxygenstyle.h ├── oxygenstylehelper.cpp ├── oxygenstylehelper.h ├── oxygenstyleoptions.cpp ├── oxygenstyleoptions.h ├── oxygenstylewrapper.cpp ├── oxygenstylewrapper.h ├── oxygentaboptions.cpp ├── oxygentaboptions.h ├── oxygentheme.cpp ├── oxygentheme.h ├── oxygentileset.cpp ├── oxygentileset.h ├── oxygentilesetcache.h ├── oxygenwindecobutton.cpp ├── oxygenwindecobutton.h ├── oxygenwindecooptions.cpp ├── oxygenwindecooptions.h ├── oxygenwindowmanager.cpp ├── oxygenwindowmanager.h ├── oxygenwindowshadow.cpp ├── oxygenwindowshadow.h ├── oxygenxulapplicationnames.h └── oxygenxulinfo.h /AUTHORS: -------------------------------------------------------------------------------- 1 | Hugo Pereira Da Costa 2 | Ruslan Kabatsayev 3 | Cédric Bellegarde 4 | 5 | Based on the NULL gtk-engine: 6 | Robert Staudinger 7 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Basic instructions for compiling: 2 | 3 | cd oxygen-gtk 4 | mkdir build 5 | cd build 6 | cmake ../ 7 | make -j2 8 | sudo make install 9 | 10 | Notes: 11 | 12 | 1/ using cmake alone (with no argument) should usually work (that is: select the right path for installing the theme) 13 | If one wants to customize this path, on can manually set the CMAKE_INSTALL_PREFIX flag when running CMake. 14 | The default is equivalent to: 15 | 16 | cmake -DCMAKE_INSTALL_PREFIX=`pkg-config --variable=prefix gtk+-2.0` ../ 17 | 18 | 2/ when using the default installation prefix, the theme engine should also automatically get installed in 19 | the correct location. However, if a custom CMAKE_INSTALL_PREFIX location is set, an extra flag is needed at 20 | the CMake stage, to compile oxygen-gtk on a 64 bits machine (for instance): 21 | 22 | cmake -DCMAKE_INSTALL_PREFIX=your_path -DLIB_SUFFIX=64 ../ 23 | 24 | For other types of architectures (except, notably, i386) it might also be necessary to set the proper value for LIB_SUFFIX. 25 | It is left to the user to figure which value must be used. 26 | 27 | 3/ make -jX uses X parallel jobs so that compilation would speed up on SMP machines with X cores/CPUs/threads 28 | 29 | 4/ There are some build settings available in /CMakeLists.txt: 30 | 31 | * OXYGEN_DEBUG: 32 | set this to 1 to enable a large amount of debug information to be printed to terminal 33 | 34 | * OXYGEN_ICON_HACK: 35 | set this to 0 to disable oxygen-gtk from forcing KDE icons for GTK apps (regardless of DE) 36 | 37 | * OXYGEN_FORCE_KDE_ICONS_AND_FONTS: 38 | set this to 0 to disable forcing KDE icons and fonts (and use the ones set in GTK) - makes sense only when 39 | KDE is not running. Doesn't change anything when KDE is running. 40 | 41 | * ENABLE_COMBOBOX_LIST_RESIZE: 42 | set this to 0 to disable combobox list resizing (see README for more detail) 43 | 44 | * ENABLE_INNER_SHADOWS_HACK 45 | set this to 0 to disable rendering of inner shadows using off-screen pixmap of composite widgets 46 | Note: this flag is automatically set to zero if gtk version is too old because of upstream bugs. 47 | 48 | * ENABLE_GROUPBOX_HACK 49 | set this to 0 to disable rendering of groupbox consistently with Qt. 50 | This special rendering might triggers some unwanted size-changes events in some dialog the first time they are 51 | made visible. 52 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | This is the oxygen-gtk TODO list, maintained and updated by the devs. 2 | You can add anything you can think of here. Possibly specifying the branch, a possible release target, and a priority. 3 | You can also add your name on which of the item you are either already working on, or interested in working on. 4 | 5 | Reminder: fixing existing bugs on bugs.kde.org should always have the highest priority :) 6 | 7 | Try find a way to avoid flicker on combobox resize (not sure whether this actually is possible or not). 8 | 9 | - add hooks at widget realization for registration to the relevant engines, rather than having it scattered in stylewrapper 10 | TRIED, but it actually does not unclutter the code much, and creates other issues. So post-poned. 11 | 12 | - better support for using oxygen-gtk in a non-kde environment. 13 | 14 | GTK3 branch: 15 | 16 | Arrows: 17 | scrollbars: ok 18 | menus: ok. 19 | treeviews: ok 20 | TreeView selection: OK. 21 | Spin buttons: OK 22 | 23 | Menu Expander: no selection. OK. 24 | 25 | Menus: ok, but: 26 | - issues with scrollbar background 27 | - tearoff menus are totally broken. Part of it might be gtk3 issue. 28 | 29 | Combobox entry: completly fucked up 30 | Seems like gtk3 bug. Also broken with Raleigh. 31 | TODO: file bug report. 32 | 33 | Notebooks: 34 | OK, but vertical positionning of text in tabs is broken. 35 | Might also be gtk3 bug, but needs investigation. 36 | 37 | Icons: customize hover effect, and implement custom disable effect. 38 | 39 | ProgressBars 40 | Slider trough 41 | Splitter handles 42 | Toolbar grips 43 | 44 | Gtk3-Demo -> offscreen pixmap -> effects 45 | crash. 46 | 47 | Inner shadows: 48 | Implement separate check if a particular GtkScrolledWindow has to be registered to ScrolledWindowEngine to allow for checking before registration (in innerShadowHook as well as in draw_shadow()) 49 | Also use composited child hack to round combobox list (and remove old XShape hack for this) 50 | 51 | Apply XShape to GtkEntry and GtkComboboxEntry to make it look better on non-oxygen background (e.g. in GtkTextView) 52 | -------------------------------------------------------------------------------- /cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(COMMAND cmake_policy) 2 | if(POLICY CMP0007) 3 | cmake_policy(SET CMP0007 OLD) 4 | endif(POLICY CMP0007) 5 | endif(COMMAND cmake_policy) 6 | 7 | if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 8 | message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 9 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 10 | 11 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 12 | string(REGEX REPLACE "\n" ";" files "${files}") 13 | list(REVERSE files) 14 | foreach (file ${files}) 15 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 16 | if (EXISTS "$ENV{DESTDIR}${file}") 17 | execute_process( 18 | COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" 19 | OUTPUT_VARIABLE rm_out 20 | RESULT_VARIABLE rm_retval 21 | ) 22 | if(NOT ${rm_retval} EQUAL 0) 23 | message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 24 | endif (NOT ${rm_retval} EQUAL 0) 25 | else (EXISTS "$ENV{DESTDIR}${file}") 26 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 27 | endif (EXISTS "$ENV{DESTDIR}${file}") 28 | endforeach(file) 29 | -------------------------------------------------------------------------------- /config.h.cmake: -------------------------------------------------------------------------------- 1 | #ifndef __CONFIG_H__ 2 | #define __CONFIG_H__ 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 8 | * 9 | * SPDX-License-Identifier: LGPL-2.0-or-later 10 | */ 11 | 12 | #define GTK_THEME_DIR "@GTK_THEME_DIR@/gtk-2.0" 13 | #ifndef OXYGEN_DEBUG 14 | #define OXYGEN_DEBUG @OXYGEN_DEBUG@ 15 | #endif 16 | 17 | #ifndef OXYGEN_DEBUG_INNERSHADOWS 18 | #define OXYGEN_DEBUG_INNERSHADOWS @OXYGEN_DEBUG_INNERSHADOWS@ 19 | #endif 20 | 21 | #define OXYGEN_ICON_HACK @OXYGEN_ICON_HACK@ 22 | #define OXYGEN_FORCE_KDE_ICONS_AND_FONTS @OXYGEN_FORCE_KDE_ICONS_AND_FONTS@ 23 | #define HAVE_DBUS @HAVE_DBUS@ 24 | #define HAVE_DBUS_GLIB @HAVE_DBUS_GLIB@ 25 | #define ENABLE_COMBOBOX_LIST_RESIZE @ENABLE_COMBOBOX_LIST_RESIZE@ 26 | 27 | #define ENABLE_INNER_SHADOWS_HACK @ENABLE_INNER_SHADOWS_HACK@ 28 | #define ENABLE_GROUPBOX_HACK @ENABLE_GROUPBOX_HACK@ 29 | #define DISABLE_SIGNAL_HOOKS @DISABLE_SIGNAL_HOOKS@ 30 | 31 | #define OXYGEN_VERSION "@OXYGEN_VERSION@" 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # For config.h to be available 2 | include_directories( ${CMAKE_BINARY_DIR} ) 3 | 4 | ########### next target ############### 5 | set( oxygen_gtk_demo_SOURCES 6 | oxygenbuttondemowidget.cpp 7 | oxygendemodialog.cpp 8 | oxygendemowidget.cpp 9 | oxygenframedemowidget.cpp 10 | oxygeninfowidget.cpp 11 | oxygeninputdemowidget.cpp 12 | oxygenlistdemowidget.cpp 13 | oxygensignal.cpp 14 | oxygensignalhandler.cpp 15 | oxygensliderdemowidget.cpp 16 | oxygentimer.cpp 17 | oxygentabdemowidget.cpp 18 | oxygenversion.cpp 19 | oxygengtkdemo_main.cpp 20 | ) 21 | 22 | IF( WIN32 ) 23 | add_executable( oxygen-gtk-demo WIN32 ${oxygen_gtk_demo_SOURCES} ) 24 | ELSE( WIN32 ) 25 | add_executable( oxygen-gtk-demo ${oxygen_gtk_demo_SOURCES} ) 26 | ENDIF( WIN32 ) 27 | 28 | target_link_libraries( oxygen-gtk-demo ${GTK_LIBRARIES} ${CAIRO_LIBRARIES} ${X11_X11_LIB} ) 29 | install( TARGETS oxygen-gtk-demo DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) 30 | 31 | ########### next target ############### 32 | if( BUILD_DECO_TEST ) 33 | set( deco_test_SOURCES oxygenversion.cpp oxygengtkdeco_main.cpp ) 34 | add_executable( oxygen-gtk-deco ${deco_test_SOURCES} ) 35 | target_link_libraries( oxygen-gtk-deco ${GTK_LIBRARIES} ${CAIRO_LIBRARIES} ${X11_X11_LIB} ${CMAKE_DL_LIBS} ) 36 | install( TARGETS oxygen-gtk-deco DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) 37 | endif( BUILD_DECO_TEST ) 38 | -------------------------------------------------------------------------------- /demo/oxygenbuttondemowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenbuttondemowidget_h 2 | #define oxygenbuttondemowidget_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygendemowidget.h" 15 | #include "oxygensignal.h" 16 | 17 | #include 18 | 19 | namespace Oxygen 20 | { 21 | 22 | class ButtonDemoWidget: public DemoWidget 23 | { 24 | 25 | public: 26 | 27 | //! constructor 28 | ButtonDemoWidget( void ); 29 | 30 | //! destructor 31 | virtual ~ButtonDemoWidget( void ); 32 | 33 | protected: 34 | 35 | //! toolbar styla changed 36 | static void toolBarStyleChanged( GtkComboBox*, gpointer ); 37 | 38 | //! icon size changed 39 | static void iconSizeChanged( GtkComboBox*, gpointer ); 40 | 41 | private: 42 | 43 | //! toolbar 44 | GtkWidget* _toolbar; 45 | 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /demo/oxygendemodialog.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygendemodialog_h 2 | #define oxygendemodialog_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygensignalhandler.h" 15 | #include "oxygensliderdemowidget.h" 16 | 17 | #include 18 | #include 19 | 20 | namespace Oxygen 21 | { 22 | 23 | // forward declaration 24 | class DemoWidget; 25 | 26 | // main demo dialog 27 | class DemoDialog: public SignalHandler 28 | { 29 | 30 | public: 31 | 32 | //! constructor 33 | DemoDialog( void ); 34 | 35 | //! destructor 36 | virtual ~DemoDialog( void ); 37 | 38 | //! main widget 39 | virtual GtkWidget* mainWidget( void ) 40 | { return _mainWidget; } 41 | 42 | protected: 43 | 44 | //! add page 45 | void addPage( DemoWidget* ); 46 | 47 | //!@name callbacks 48 | //@{ 49 | 50 | static void selectionChanged( GtkIconView*, gpointer ); 51 | static void toggleEnableState( GtkToggleButton*, gpointer ); 52 | static void toggleWidgetDirection( GtkToggleButton*, gpointer ); 53 | static gboolean keyPress( GtkWidget*, GdkEventKey*, gpointer ); 54 | //@} 55 | 56 | private: 57 | 58 | //! main widget 59 | GtkWidget* _mainWidget; 60 | 61 | //! tab widget 62 | GtkWidget* _notebook; 63 | 64 | //! model 65 | GtkListStore* _model; 66 | 67 | //! map page index and page widget 68 | typedef std::map PageMap; 69 | PageMap _pages; 70 | SliderDemoWidget* _sliderDemoWidget; 71 | 72 | //! enable state button 73 | GtkWidget* _stateButton; 74 | 75 | }; 76 | 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /demo/oxygendemowidget.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * this file is part of the oxygen gtk engine 4 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 5 | * 6 | * based on the Null Theme Engine for Gtk+. 7 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 8 | * 9 | * SPDX-License-Identifier: LGPL-2.0-or-later 10 | */ 11 | 12 | #include "oxygendemowidget.h" 13 | 14 | namespace Oxygen 15 | { 16 | 17 | //_______________________________________________________ 18 | void DemoWidget::realize( void ) 19 | { 20 | assert( !_mainWidget ); 21 | assert( _widget ); 22 | 23 | // create main widget (vbox) 24 | _mainWidget = gtk_vbox_new( false, 0 ); 25 | gtk_box_set_spacing( GTK_BOX( _mainWidget ), 10 ); 26 | gtk_widget_show( _mainWidget ); 27 | 28 | // horizontal box 29 | GtkWidget* hbox( gtk_hbox_new( false, 0 ) ); 30 | gtk_box_pack_start( GTK_BOX( _mainWidget ), hbox, false, true, 0 ); 31 | gtk_widget_show( hbox ); 32 | 33 | // label 34 | std::string comments( _comments.empty() ? _name:_comments ); 35 | GtkWidget* label( gtk_label_new( comments.c_str() ) ); 36 | 37 | PangoAttrList* attributes( pango_attr_list_new() ); 38 | pango_attr_list_insert( attributes, pango_attr_weight_new( PANGO_WEIGHT_BOLD ) ); 39 | gtk_label_set_attributes( GTK_LABEL( label ), attributes ); 40 | pango_attr_list_unref( attributes ); 41 | 42 | gtk_box_pack_start( GTK_BOX( hbox ), label, false, true, 0 ); 43 | 44 | gtk_widget_show( label ); 45 | 46 | // icon 47 | if( !_iconName.empty() ) 48 | { 49 | GtkIconTheme* theme( gtk_icon_theme_get_default() ); 50 | GdkPixbuf* icon( gtk_icon_theme_load_icon( theme, _iconName.c_str(), 22, (GtkIconLookupFlags) 0, 0L ) ); 51 | GtkWidget* image( gtk_image_new_from_pixbuf( icon ) ); 52 | gtk_box_pack_end( GTK_BOX( hbox ), image, false, false, 0 ); 53 | gtk_widget_show( image ); 54 | 55 | } 56 | 57 | // main content 58 | gtk_box_pack_start( GTK_BOX( _mainWidget ), _widget, true, true, 0 ); 59 | gtk_widget_show( _widget ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /demo/oxygendemowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygendemowidget_h 2 | #define oxygendemowidget_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygensignalhandler.h" 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | namespace Oxygen 21 | { 22 | 23 | class DemoWidget: public SignalHandler 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | DemoWidget( void ): 30 | _mainWidget( 0L ), 31 | _widget(0L), 32 | _enabled( true ) 33 | {} 34 | 35 | //! destructor 36 | virtual ~DemoWidget( void ) 37 | {} 38 | 39 | //! main widget 40 | virtual GtkWidget* mainWidget( void ) 41 | { return _mainWidget; } 42 | 43 | //! enable state 44 | virtual void setEnabled( bool value ) 45 | { 46 | _enabled = value; 47 | if( _widget ) 48 | { gtk_widget_set_sensitive( _widget, _enabled ); } 49 | } 50 | 51 | //! name 52 | const std::string& name( void ) const 53 | { return _name; } 54 | 55 | //! icon name 56 | const std::string& iconName( void ) const 57 | { return _iconName; } 58 | 59 | protected: 60 | 61 | //! name 62 | void setName( const std::string name ) 63 | { _name = name; } 64 | 65 | //! comments 66 | void setComments( const std::string comments ) 67 | { _comments = comments; } 68 | 69 | //! icon name 70 | void setIconName( const std::string iconName ) 71 | { _iconName = iconName; } 72 | 73 | //! assign main widget 74 | virtual void setWidget( GtkWidget *widget ) 75 | { _widget = widget; } 76 | 77 | //! realize widget 78 | void realize( void ); 79 | 80 | private: 81 | 82 | //! copy constructor 83 | DemoWidget( const DemoWidget& ) 84 | { assert( false ); } 85 | 86 | //! assignment operator 87 | DemoWidget& operator = (const DemoWidget& ) 88 | { 89 | assert( false ); 90 | return *this; 91 | } 92 | 93 | //! page name 94 | std::string _name; 95 | 96 | //! page comments 97 | std::string _comments; 98 | 99 | //! icon name 100 | std::string _iconName; 101 | 102 | //! main widget 103 | GtkWidget* _mainWidget; 104 | 105 | //! contents widget 106 | GtkWidget* _widget; 107 | 108 | //! enable state 109 | bool _enabled; 110 | 111 | }; 112 | 113 | } 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /demo/oxygenframedemowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenframedemowidget_h 2 | #define oxygenframedemowidget_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygendemowidget.h" 15 | #include "oxygensignal.h" 16 | 17 | #include 18 | #include 19 | 20 | namespace Oxygen 21 | { 22 | 23 | class FrameDemoWidget: public DemoWidget 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | FrameDemoWidget( void ); 30 | 31 | //! destructor 32 | virtual ~FrameDemoWidget( void ); 33 | 34 | protected: 35 | 36 | //! orientation changed 37 | static void orientationChanged( GtkComboBox*, gpointer ); 38 | 39 | //! shadow style changed 40 | static void shadowChanged( GtkToggleButton*, gpointer ); 41 | 42 | private: 43 | 44 | //! frames box 45 | GtkWidget* _box; 46 | 47 | //! frame 48 | GtkWidget* _frame; 49 | 50 | //! map widget to frame shadow style 51 | typedef std::map WidgetMap; 52 | WidgetMap _widgets; 53 | 54 | }; 55 | 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /demo/oxygengtkdemo_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | based on the Null Theme Engine for Gtk+. 6 | SPDX-FileCopyrightText: 2008 Robert Staudinger 7 | 8 | SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygenversion.h" 12 | #include "oxygendemodialog.h" 13 | 14 | //___________________________________________________________________ 15 | int main( int argc, char** argv ) 16 | { 17 | 18 | // initialize gtk 19 | gtk_init(&argc, &argv); 20 | 21 | // command line arguments 22 | gboolean version( FALSE ); 23 | GOptionEntry entries[] = 24 | { 25 | { "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show the application's version", 0L }, 26 | { 0L } 27 | }; 28 | 29 | GError *error = 0L; 30 | GOptionContext* context( g_option_context_new( "- Gtk+ widgets preview for oxygen" ) ); 31 | g_option_context_add_main_entries(context, entries, 0L ); 32 | g_option_context_add_group (context, gtk_get_option_group( TRUE ) ); 33 | g_option_context_parse( context, &argc, &argv, &error ); 34 | g_option_context_free( context ); 35 | 36 | if( version ) 37 | { 38 | /* 39 | HACK: need to create (and destroy immediatly) a dummy window 40 | in order to make sure that the widget style is initialized properly 41 | */ 42 | GtkWidget* window = gtk_window_new( GTK_WINDOW_TOPLEVEL ); 43 | gtk_widget_destroy( window ); 44 | 45 | Oxygen::Version::print(); 46 | return 0; 47 | } 48 | 49 | // dialog 50 | Oxygen::DemoDialog demoDialog; 51 | 52 | // connect demo dialog destruction to quit 53 | g_signal_connect( G_OBJECT( demoDialog.mainWidget() ), "destroy", G_CALLBACK(gtk_main_quit), 0L); 54 | gtk_widget_show( demoDialog.mainWidget() ); 55 | 56 | // run main loop 57 | gtk_main(); 58 | 59 | return 0; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /demo/oxygeninfowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygeninfowidget_h 2 | #define oxygeninfowidget_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygendemowidget.h" 15 | #include "oxygensignal.h" 16 | 17 | #include 18 | #include 19 | 20 | namespace Oxygen 21 | { 22 | 23 | class InfoWidget: public DemoWidget 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | InfoWidget( void ); 30 | 31 | //! destructor 32 | virtual ~InfoWidget( void ); 33 | 34 | protected: 35 | 36 | // bold label 37 | GtkWidget* boldLabel( void ) const; 38 | 39 | //! add author 40 | void addAuthor( GtkWidget*, int, const std::string&, const std::string& ) const; 41 | 42 | }; 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /demo/oxygeninputdemowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygeninputdemowidget_h 2 | #define oxygeninputdemowidget_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygendemowidget.h" 15 | #include "oxygensignal.h" 16 | 17 | #include 18 | #include 19 | 20 | namespace Oxygen 21 | { 22 | 23 | class InputDemoWidget: public DemoWidget 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | InputDemoWidget( void ); 30 | 31 | //! destructor 32 | virtual ~InputDemoWidget( void ); 33 | 34 | protected: 35 | 36 | //! wrap mode changed 37 | static void flatModeChanged( GtkToggleButton*, gpointer ); 38 | 39 | //! wrap mode changed 40 | static void wrapModeChanged( GtkToggleButton*, gpointer ); 41 | 42 | private: 43 | 44 | //! list of gtk entries 45 | typedef std::vector WidgetList; 46 | WidgetList _entries; 47 | 48 | //! text editor 49 | GtkWidget* _textView; 50 | 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /demo/oxygenlistdemowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenlistdemowidget_h 2 | #define oxygenlistdemowidget_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygendemowidget.h" 15 | 16 | namespace Oxygen 17 | { 18 | 19 | class ListDemoWidget: public DemoWidget 20 | { 21 | 22 | public: 23 | 24 | //! constructor 25 | ListDemoWidget( void ); 26 | 27 | //! destructor 28 | virtual ~ListDemoWidget( void ) 29 | {} 30 | 31 | }; 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /demo/oxygensignal.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * this file is part of the oxygen gtk engine 4 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 5 | * 6 | * SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygensignal.h" 10 | 11 | namespace Oxygen 12 | { 13 | 14 | //____________________________________________________________________ 15 | void Signal::connect( GObject* object, const std::string& signal, GCallback callback, gpointer data ) 16 | { 17 | // make sure that signal is not already connected 18 | assert( _object == 0L && _id == 0 ); 19 | 20 | // store attributes and create connection 21 | _object = object; 22 | _id = g_signal_connect( object, signal.c_str(), callback, data ); 23 | } 24 | 25 | //____________________________________________________________________ 26 | void Signal::disconnect( void ) 27 | { 28 | 29 | // disconnect signal 30 | if( _object && _id > 0 ) g_signal_handler_disconnect( _object, _id ); 31 | 32 | // reset members 33 | _object = 0L; 34 | _id = 0; 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /demo/oxygensignal.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygensignal_h 2 | #define oxygensignal_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | //! handles gtk signal connections 18 | class Signal 19 | { 20 | public: 21 | 22 | //! constructor 23 | Signal( void ): 24 | _id(0), 25 | _object(0L) 26 | {} 27 | 28 | //! destructor 29 | virtual ~Signal( void ) 30 | {} 31 | 32 | //! connect 33 | void connect( GObject*, const std::string&, GCallback, gpointer ); 34 | 35 | //! disconnect 36 | void disconnect( void ); 37 | 38 | //! check if signal belongs to given object 39 | bool belongsTo( GObject* object ) const 40 | { return object == _object; } 41 | 42 | private: 43 | 44 | //! signal id 45 | guint _id; 46 | 47 | //! connected object 48 | GObject* _object; 49 | 50 | }; 51 | 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /demo/oxygensignalhandler.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * this file is part of the oxygen gtk engine 4 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 5 | * 6 | * SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygensignalhandler.h" 10 | 11 | namespace Oxygen 12 | { 13 | 14 | //________________________________________________________ 15 | SignalHandler::~SignalHandler( void ) 16 | { 17 | 18 | // disconnect all signals 19 | for( std::vector::iterator iter = _signals.begin(); iter != _signals.end(); ++iter ) 20 | { iter->disconnect(); } 21 | 22 | } 23 | 24 | //________________________________________________________ 25 | void SignalHandler::connect( GObject* object, const std::string& signal, GCallback callback, gpointer data ) 26 | { 27 | // check if object is already connected 28 | if( _objects.find( object ) == _objects.end() ) 29 | { 30 | 31 | // insert object 32 | _objects.insert( object ); 33 | 34 | // insert destroy signal 35 | Signal destroyId; 36 | destroyId.connect( object, "destroy", (GCallback) destroyNotifyEvent, this ); 37 | _signals.push_back( destroyId ); 38 | 39 | } 40 | 41 | // insert signal 42 | Signal signalId; 43 | signalId.connect( object, signal, callback, data ); 44 | _signals.push_back( signalId ); 45 | 46 | } 47 | 48 | //________________________________________________________ 49 | gboolean SignalHandler::destroyNotifyEvent( GtkWidget* widget, gpointer pointer ) 50 | { 51 | SignalHandler& data( *static_cast( pointer ) ); 52 | for( std::vector::iterator iter = data._signals.begin(); iter != data._signals.end(); ++iter ) 53 | { if( iter->belongsTo( G_OBJECT( widget ) ) ) iter->disconnect(); } 54 | 55 | // remove from objects 56 | data._objects.erase( G_OBJECT( widget ) ); 57 | return FALSE; 58 | 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /demo/oxygensignalhandler.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygensignalhandler_h 2 | #define oxygensignalhandler_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygensignal.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | 20 | class SignalHandler 21 | { 22 | 23 | public: 24 | 25 | //! constructor 26 | SignalHandler( void ) 27 | {} 28 | 29 | //! destructor 30 | virtual ~SignalHandler( void ); 31 | 32 | //! connect 33 | void connect( GObject*, const std::string&, GCallback, gpointer ); 34 | 35 | protected: 36 | 37 | //! destruction callback 38 | static gboolean destroyNotifyEvent( GtkWidget*, gpointer ); 39 | 40 | private: 41 | 42 | //! registered widgets 43 | std::set _objects; 44 | 45 | //! registered signals 46 | std::vector _signals; 47 | 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /demo/oxygensliderdemowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygensliderdemowidget_h 2 | #define oxygensliderdemowidget_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygendemowidget.h" 15 | #include "oxygensignal.h" 16 | #include "oxygentimer.h" 17 | 18 | #include 19 | 20 | namespace Oxygen 21 | { 22 | 23 | class SliderDemoWidget: public DemoWidget 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | SliderDemoWidget( void ); 30 | 31 | //! destructor 32 | virtual ~SliderDemoWidget( void ); 33 | 34 | //! pulse progress bar 35 | void startPulse( void ) 36 | { if( !_timer.isRunning() ) _timer.start( 50, (GSourceFunc)pulseProgressBar, this ); } 37 | 38 | //! pulse progress bar 39 | void stopPulse( void ) 40 | { if( _timer.isRunning() ) _timer.stop(); } 41 | 42 | protected: 43 | 44 | //! pulse progress bar 45 | static gboolean pulseProgressBar( gpointer ); 46 | 47 | //! callback 48 | static void valueChanged( GtkRange*, gpointer ); 49 | 50 | private: 51 | 52 | //! widget container 53 | class Sliders 54 | { 55 | public: 56 | 57 | //! constructor 58 | Sliders( void ): 59 | _scale( 0 ), 60 | _progressBar( 0 ), 61 | _scrollBar( 0 ), 62 | _progressEntry( 0 ) 63 | {} 64 | 65 | //! change value 66 | void setValue( const double& value ) const; 67 | 68 | GtkWidget* _scale; 69 | GtkWidget* _progressBar; 70 | GtkWidget* _scrollBar; 71 | GtkWidget* _progressEntry; 72 | }; 73 | 74 | //! horizontal sliders 75 | Sliders _horizontalSliders; 76 | 77 | //! vertical sliders 78 | Sliders _verticalSliders; 79 | 80 | //! pulse progressbar timer 81 | Timer _timer; 82 | 83 | //! pulse progress bar 84 | GtkWidget* _pulseProgressBar; 85 | }; 86 | 87 | } 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /demo/oxygentabdemowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentabdemowidget_h 2 | #define oxygentabdemowidget_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * based on the Null Theme Engine for Gtk+. 9 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 10 | * 11 | * SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygendemowidget.h" 15 | #include "oxygensignal.h" 16 | 17 | #include 18 | 19 | namespace Oxygen 20 | { 21 | 22 | class TabDemoWidget: public DemoWidget 23 | { 24 | 25 | public: 26 | 27 | //! constructor 28 | TabDemoWidget( void ); 29 | 30 | //! destructor 31 | virtual ~TabDemoWidget( void ); 32 | 33 | protected: 34 | 35 | //! add page to notebook 36 | void addPage( const std::string&, GtkWidget* ) const; 37 | 38 | //! orientation changed 39 | static void orientationChanged( GtkComboBox*, gpointer ); 40 | 41 | private: 42 | 43 | //! tab widget 44 | GtkWidget *_notebook; 45 | 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /demo/oxygentimer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygentimer.h" 9 | 10 | #include 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //____________________________________________________ 17 | void Timer::start( int delay, GSourceFunc func, gpointer data ) 18 | { 19 | 20 | // make sure timer is not already running 21 | g_return_if_fail( _timerId == 0 ); 22 | 23 | _func = func; 24 | _data = data; 25 | _timerId = gdk_threads_add_timeout( delay, (GSourceFunc)timeOut, this ); 26 | 27 | } 28 | 29 | //____________________________________________________ 30 | gboolean Timer::timeOut( gpointer data ) 31 | { 32 | 33 | // cast to timer, and execute relevant function 34 | Timer& timer( *static_cast( data ) ); 35 | gboolean result = (timer._func)( timer._data ); 36 | 37 | // make sure timerId is properly reset if the embedded function returns false 38 | if( !result ) timer.reset(); 39 | return result; 40 | 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /demo/oxygentimer.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentimer_h 2 | #define oxygentimer_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | 12 | namespace Oxygen 13 | { 14 | //! handles gtk timeouts 15 | /*! make sure the timer is properly reset at destruction */ 16 | class Timer 17 | { 18 | 19 | public: 20 | 21 | //! constructor 22 | Timer( void ): 23 | _timerId( 0 ), 24 | _func( 0L ), 25 | _data( 0L ) 26 | {} 27 | 28 | //! copy constructor 29 | /*! actually does not copy anything, and prints a warning if the other timer is running */ 30 | Timer( const Timer& other ): 31 | _timerId( 0 ), 32 | _func( 0L ), 33 | _data( 0L ) 34 | { 35 | if( other.isRunning() ) 36 | { g_warning( "Oxygen::Timer::Timer - Copy constructor on running timer called." ); } 37 | 38 | } 39 | 40 | //! destructor 41 | virtual ~Timer( void ) 42 | { if( _timerId ) g_source_remove( _timerId ); } 43 | 44 | //! start 45 | void start( int, GSourceFunc, gpointer ); 46 | 47 | //! stop 48 | void stop( void ) 49 | { 50 | if( _timerId ) g_source_remove( _timerId ); 51 | reset(); 52 | } 53 | 54 | //! true if running 55 | bool isRunning( void ) const 56 | { return _timerId != 0; } 57 | 58 | protected: 59 | 60 | //! reset 61 | void reset( void ) 62 | { 63 | _timerId = 0; 64 | _data = 0; 65 | _func = 0; 66 | } 67 | 68 | //! delayed update 69 | static gboolean timeOut( gpointer ); 70 | 71 | private: 72 | 73 | // assignment operator is private 74 | Timer& operator = (const Timer& ) 75 | { return *this; } 76 | 77 | //! timer id 78 | int _timerId; 79 | 80 | //! source function 81 | GSourceFunc _func; 82 | 83 | //! data 84 | gpointer _data; 85 | 86 | }; 87 | } 88 | 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /demo/oxygenversion.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 5 | 6 | SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygenversion.h" 10 | #include "../src/oxygendefines.h" 11 | #include "config.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace Oxygen 19 | { 20 | 21 | //____________________________________________ 22 | std::string Version::gtkVersion( void ) 23 | { 24 | std::ostringstream buffer; 25 | buffer << gtk_major_version<< "." << gtk_minor_version << "." << gtk_micro_version; 26 | return buffer.str(); 27 | } 28 | 29 | //____________________________________________ 30 | std::string Version::libVersion( void ) 31 | { 32 | // load type for oxygen version container 33 | GType type( g_type_from_name( OXYGEN_VERSION_TYPE_NAME ) ); 34 | if( !type ) return std::string(); 35 | 36 | // load quark 37 | GQuark quark( g_quark_try_string( OXYGEN_VERSION_QUARK_NAME ) ); 38 | if( !quark ) return std::string(); 39 | 40 | // retrieve data from type 41 | gpointer data( g_type_get_qdata( type, quark ) ); 42 | return data ? std::string( static_cast( data ) ):std::string(); 43 | 44 | } 45 | 46 | //____________________________________________ 47 | void Version::print( void ) 48 | { 49 | 50 | std::cout << "gtk: " << gtkVersion() << std::endl; 51 | 52 | const std::string libraryVersion( libVersion() ); 53 | if( !libraryVersion.empty() ) 54 | { std::cout << "oxygen-gtk: " << libraryVersion << std::endl; } 55 | 56 | std::cout << "oxygen-gtk-demo: " << OXYGEN_VERSION << std::endl; 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /demo/oxygenversion.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenversion_h 2 | #define oxygenversion_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 8 | * 9 | * SPDX-License-Identifier: LGPL-2.0-or-later 10 | */ 11 | 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | 17 | class Version 18 | { 19 | public: 20 | 21 | //! gtk version 22 | static std::string gtkVersion( void ); 23 | 24 | //! lib version 25 | static std::string libVersion( void ); 26 | 27 | //! print options 28 | static void print( void ); 29 | 30 | }; 31 | 32 | } 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /rc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | install( 3 | FILES gtkrc icons4 kdeglobals oxygenrc argb-apps.conf 4 | DESTINATION "${GTK_THEME_DIR}/gtk-2.0" 5 | ) 6 | -------------------------------------------------------------------------------- /rc/argb-apps.conf: -------------------------------------------------------------------------------- 1 | ################################################################# 2 | # this file is part of the oxygen gtk engine 3 | # SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | # SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 5 | # SPDX-License-Identifier: LGPL-2.0-or-later 6 | ################################################################# 7 | 8 | ################################################################# 9 | # syntax: 10 | # enable/disable argb colormap for applications 11 | # syntax is the following 12 | # enable:app1:app2:app3 will enable argb for app1, app2, etC. 13 | # disable:app1:app2:app3 will disable argb for app1, app2, etc. 14 | # 15 | # rules: 16 | # 1/ if an application is not found in the file, argb support will be _enabled_ 17 | # 2/ if an application is found in both an "enable:" and a "disable:" lines, 18 | # the last line containing the application is used to decide whether argb support 19 | # is enabled or disabled. 20 | # 3/ lines that begin neither with enable or disable are ignored. 21 | # 22 | # additional keywords: 23 | # disable:all can be used to disable all applications except the ones appearing in "enable:" lines 24 | # enable:all can be used to enable all applications no matter what, therefore ignoring all "disable:" 25 | # lines, consistently with rull 2/ above 26 | # 27 | ########################################################### 28 | 29 | # enable all applications, by default 30 | # note that this line is not necessary since applications not found 31 | # in this file have argb support enabled anyway 32 | enable:all 33 | 34 | ############################################################ 35 | # The list of disabled applications is now empty, because the way argb is handled should now be safe for all applications 36 | # if you have non-empty user argb-apps.conf file, it is recommanded to try empty it. 37 | disable:xfrun4 38 | -------------------------------------------------------------------------------- /rc/kdeglobals: -------------------------------------------------------------------------------- 1 | [ColorEffects:Disabled] 2 | Color=56,56,56 3 | ColorAmount=0 4 | ColorEffect=0 5 | ContrastAmount=0.65 6 | ContrastEffect=1 7 | IntensityAmount=0.1 8 | IntensityEffect=2 9 | 10 | [ColorEffects:Inactive] 11 | ChangeSelectionColor=true 12 | Color=112,111,110 13 | ColorAmount=-0.9 14 | ColorEffect=1 15 | ContrastAmount=0.25 16 | ContrastEffect=2 17 | Enable=false 18 | IntensityAmount=0 19 | IntensityEffect=0 20 | 21 | [Colors:Button] 22 | BackgroundAlternate=224,223,222 23 | BackgroundNormal=223,220,217 24 | DecorationFocus=58,167,221 25 | DecorationHover=110,214,255 26 | ForegroundActive=255,128,224 27 | ForegroundInactive=137,136,135 28 | ForegroundLink=0,87,174 29 | ForegroundNegative=191,3,3 30 | ForegroundNeutral=176,128,0 31 | ForegroundNormal=34,31,30 32 | ForegroundPositive=0,110,40 33 | ForegroundVisited=100,74,155 34 | 35 | [Colors:Selection] 36 | BackgroundAlternate=62,138,204 37 | BackgroundNormal=67,172,232 38 | DecorationFocus=58,167,221 39 | DecorationHover=110,214,255 40 | ForegroundActive=255,128,224 41 | ForegroundInactive=165,193,228 42 | ForegroundLink=0,49,110 43 | ForegroundNegative=156,14,14 44 | ForegroundNeutral=255,221,0 45 | ForegroundNormal=255,255,255 46 | ForegroundPositive=128,255,128 47 | ForegroundVisited=69,40,134 48 | 49 | [Colors:Tooltip] 50 | BackgroundAlternate=196,224,255 51 | BackgroundNormal=24,21,19 52 | DecorationFocus=58,167,221 53 | DecorationHover=110,214,255 54 | ForegroundActive=255,128,224 55 | ForegroundInactive=137,136,135 56 | ForegroundLink=0,87,174 57 | ForegroundNegative=191,3,3 58 | ForegroundNeutral=176,128,0 59 | ForegroundNormal=231,253,255 60 | ForegroundPositive=0,110,40 61 | ForegroundVisited=100,74,155 62 | 63 | [Colors:View] 64 | BackgroundAlternate=248,247,246 65 | BackgroundNormal=255,255,255 66 | DecorationFocus=58,167,221 67 | DecorationHover=110,214,255 68 | ForegroundActive=255,128,224 69 | ForegroundInactive=137,136,135 70 | ForegroundLink=0,87,174 71 | ForegroundNegative=191,3,3 72 | ForegroundNeutral=176,128,0 73 | ForegroundNormal=31,28,27 74 | ForegroundPositive=0,110,40 75 | ForegroundVisited=100,74,155 76 | 77 | [Colors:Window] 78 | BackgroundAlternate=218,217,216 79 | BackgroundNormal=214,210,208 80 | DecorationFocus=58,167,221 81 | DecorationHover=110,214,255 82 | ForegroundActive=255,128,224 83 | ForegroundInactive=137,136,135 84 | ForegroundLink=0,87,174 85 | ForegroundNegative=191,3,3 86 | ForegroundNeutral=176,128,0 87 | ForegroundNormal=34,31,30 88 | ForegroundPositive=0,110,40 89 | ForegroundVisited=100,74,155 90 | 91 | [General] 92 | Name=Oxygen 93 | 94 | [KDE] 95 | contrast=8 96 | StartDragDist=4 97 | StartDragTime=500 98 | 99 | [WM] 100 | activeBackground=48,174,232 101 | activeForeground=255,255,255 102 | inactiveBackground=224,223,222 103 | inactiveForeground=75,71,67 104 | 105 | [Toolbar style] 106 | ToolButtonStyle=TextBesideIcon 107 | ToolButtonStyleOtherToolbars=TextBesideIcon 108 | -------------------------------------------------------------------------------- /rc/oxygenrc: -------------------------------------------------------------------------------- 1 | [ActiveShadow] 2 | InnerColor=112,239,255 3 | OuterColor=84,167,240 4 | Size=40 5 | UseOuterColor=true 6 | VerticalOffset=0.1 7 | 8 | [InactiveShadow] 9 | InnerColor=0,0,0 10 | OuterColor=0,0,0 11 | Size=40 12 | UseOuterColor=false 13 | VerticalOffset=0.2 14 | 15 | [Style] 16 | CacheEnabled=true 17 | MaxCacheSize=512 18 | AnimationSteps=10 19 | ShowMnemonics=true 20 | ToolTipTransparent=true 21 | ToolTipDrawStyledFrames=true 22 | ToolBarDrawItemSeparator=true 23 | ViewDrawTriangularExpander=true 24 | ViewTriangularExpanderSize=TE_SMALL 25 | ViewDrawFocusIndicator=true 26 | ViewDrawTreeBranchLines=true 27 | ScrollBarWidth=15 28 | ScrollBarAddLineButtons=2 29 | ScrollBarSubLineButtons=1 30 | CheckBoxStyle=CS_CHECK 31 | ScrollBarBevel=true 32 | ProgressBarAnimated=true 33 | MenuHighlightMode=MM_DARK 34 | TabStyle=TS_SINGLE 35 | 36 | WindowDragEnabled=true 37 | WindowDragMode=WD_FULL 38 | WindowDragWhiteList= 39 | WindowDragBlackList= 40 | UseWMMoveResize=true 41 | 42 | WidgetExplorerEnabled=false 43 | DrawWidgetRects=false 44 | 45 | AnimationsEnabled=true 46 | GenericAnimationsEnabled=true 47 | ToolBarAnimationType=TB_FADE 48 | MenuBarAnimationsEnabled=true 49 | MenuBarAnimationType=MB_FADE 50 | MenuAnimationsEnabled=true 51 | MenuAnimationType=ME_FADE 52 | ProgressBarAnimationsEnabled=true 53 | GenericAnimationsDuration=150 54 | ToolBarAnimationsDuration=50 55 | MenuBarAnimationsDuration=150 56 | MenuBarFollowMouseAnimationsDuration=80 57 | MenuAnimationsDuration=150 58 | MenuFollowMouseAnimationsDuration=40 59 | ProgressBarAnimationsDuration=250 60 | ProgressBarBusyStepDuration=50 61 | StackedWidgetTransitionsEnabled=false 62 | LabelTransitionsEnabled=true 63 | ComboBoxTransitionsEnabled=true 64 | LineEditTransitionsEnabled=true 65 | StackedWidgetTransitionsDuration=150 66 | LabelTransitionsDuration=75 67 | ComboBoxTransitionsDuration=75 68 | LineEditTransitionsDuration=150 69 | -------------------------------------------------------------------------------- /special-icons/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | install( 3 | FILES standardbutton-closetab-16.png standardbutton-closetab-down-16.png standardbutton-closetab-hover-16.png 4 | DESTINATION "${GTK_THEME_DIR}/gtk-2.0/special-icons" 5 | ) 6 | -------------------------------------------------------------------------------- /special-icons/standardbutton-closetab-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KDE/oxygen-gtk/3b0558f811d3dbf56de79939bfc1f6fee743fd41/special-icons/standardbutton-closetab-16.png -------------------------------------------------------------------------------- /special-icons/standardbutton-closetab-down-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KDE/oxygen-gtk/3b0558f811d3dbf56de79939bfc1f6fee743fd41/special-icons/standardbutton-closetab-down-16.png -------------------------------------------------------------------------------- /special-icons/standardbutton-closetab-hover-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KDE/oxygen-gtk/3b0558f811d3dbf56de79939bfc1f6fee743fd41/special-icons/standardbutton-closetab-hover-16.png -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories( ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} ) 2 | include_directories( animations debug ) 3 | 4 | # Sources 5 | # please keep this list alphabetically sorted for clarity 6 | set( oxygen_gtk_SOURCES 7 | animations/oxygenanimations.cpp 8 | animations/oxygenarrowstatedata.cpp 9 | animations/oxygenbackgroundhintengine.cpp 10 | animations/oxygenbaseengine.cpp 11 | animations/oxygencomboboxdata.cpp 12 | animations/oxygencomboboxentrydata.cpp 13 | animations/oxygendialogengine.cpp 14 | animations/oxygenflatwidgetengine.cpp 15 | animations/oxygenfollowmousedata.cpp 16 | animations/oxygenhook.cpp 17 | animations/oxygenhoverdata.cpp 18 | animations/oxygeninnershadowdata.cpp 19 | animations/oxygenmainwindowdata.cpp 20 | animations/oxygenmenubarstatedata.cpp 21 | animations/oxygenmenustatedata.cpp 22 | animations/oxygenmenuitemengine.cpp 23 | animations/oxygenmenuitemdata.cpp 24 | animations/oxygenpaneddata.cpp 25 | animations/oxygensignal.cpp 26 | animations/oxygenscrollbardata.cpp 27 | animations/oxygenscrollbarstatedata.cpp 28 | animations/oxygenscrolledwindowdata.cpp 29 | animations/oxygentabwidgetdata.cpp 30 | animations/oxygentabwidgetstatedata.cpp 31 | animations/oxygentimeline.cpp 32 | animations/oxygentimelineserver.cpp 33 | animations/oxygentimer.cpp 34 | animations/oxygentoolbarstatedata.cpp 35 | animations/oxygentreeviewdata.cpp 36 | animations/oxygentreeviewengine.cpp 37 | animations/oxygentreeviewstatedata.cpp 38 | animations/oxygenwidgetsizedata.cpp 39 | animations/oxygenwidgetstatedata.cpp 40 | animations/oxygenwidgetstateengine.cpp 41 | debug/oxygenwidgetexplorer.cpp 42 | oxygenapplicationname.cpp 43 | oxygenargbhelper.cpp 44 | oxygencairocontext.cpp 45 | oxygencairoutils.cpp 46 | oxygencoloreffect.cpp 47 | oxygencolorutils.cpp 48 | oxygenfontinfo.cpp 49 | oxygengtkcellinfo.cpp 50 | oxygengtkicons.cpp 51 | oxygengtkrc.cpp 52 | oxygengtktypenames.cpp 53 | oxygengtkutils.cpp 54 | oxygenloghandler.cpp 55 | oxygenobjectcounter.cpp 56 | oxygenobjectcountermap.cpp 57 | oxygenoption.cpp 58 | oxygenoptionmap.cpp 59 | oxygenpalette.cpp 60 | oxygenpathlist.cpp 61 | oxygenpropertynames.cpp 62 | oxygenqtsettings.cpp 63 | oxygenrcstyle.cpp 64 | oxygenrgba.cpp 65 | oxygenshadowconfiguration.cpp 66 | oxygenshadowhelper.cpp 67 | oxygenstyle.cpp 68 | oxygenstylehelper.cpp 69 | oxygenstyleoptions.cpp 70 | oxygenstylewrapper.cpp 71 | oxygentaboptions.cpp 72 | oxygentheme.cpp 73 | oxygentileset.cpp 74 | oxygenwindecobutton.cpp 75 | oxygenwindecooptions.cpp 76 | oxygenwindowmanager.cpp 77 | oxygenwindowshadow.cpp 78 | ) 79 | 80 | add_library( oxygen-gtk SHARED ${oxygen_gtk_SOURCES} ) 81 | 82 | # Add debug cflags 83 | set( CMAKE_CXX_FLAGS " -Wall -g ${CMAKE_CXX_FLAGS}" ) 84 | set( CMAKE_C_FLAGS " -Wall -g ${CMAKE_C_FLAGS}" ) 85 | 86 | target_link_libraries( oxygen-gtk ${GTK_LIBRARIES} ${CAIRO_LIBRARIES} ${X11_X11_LIB} ) 87 | 88 | install( TARGETS oxygen-gtk DESTINATION ${INSTALL_PATH_GTK_ENGINES} ) 89 | -------------------------------------------------------------------------------- /src/animations/oxygenanimationengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenanimationengine_h 2 | #define oxygenanimationengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "../oxygenapplicationname.h" 11 | 12 | namespace Oxygen 13 | { 14 | 15 | class AnimationEngine 16 | { 17 | 18 | public: 19 | 20 | //! constructor 21 | explicit AnimationEngine( void ): 22 | _duration( 150 ) 23 | {} 24 | 25 | //! destructor 26 | virtual ~AnimationEngine( void ) 27 | {} 28 | 29 | //! application name 30 | virtual void setApplicationName( const ApplicationName& applicationName ) 31 | { _applicationName = applicationName; } 32 | 33 | //! duration 34 | const int& duration( void ) const 35 | { return _duration; } 36 | 37 | //! duration 38 | /*! returns true if changed */ 39 | bool setDuration( int value ) 40 | { 41 | if( _duration == value ) return false; 42 | _duration = value; 43 | return true; 44 | } 45 | 46 | protected: 47 | 48 | //! returs true if widget is black listed (based notably on application name) 49 | bool widgetIsBlackListed( GtkWidget* widget ) const 50 | { 51 | 52 | // for now, only Mozilla applications need blacklisting 53 | return _applicationName.isXul( widget ); 54 | 55 | } 56 | 57 | private: 58 | 59 | //! application name 60 | ApplicationName _applicationName; 61 | 62 | //! animation duration 63 | int _duration; 64 | 65 | }; 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/animations/oxygenarrowstatedata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenarrowstatedata.h" 9 | #include "../config.h" 10 | 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //_____________________________________________ 17 | void ArrowStateData::connect( GtkWidget* widget ) 18 | { 19 | 20 | #if OXYGEN_DEBUG 21 | std::cerr << "Oxygen::ArrowStateData::connect - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; 22 | #endif 23 | 24 | _target = widget; 25 | _upArrowData._timeLine.connect( (GSourceFunc)delayedUpdate, this ); 26 | _downArrowData._timeLine.connect( (GSourceFunc)delayedUpdate, this ); 27 | } 28 | 29 | //_____________________________________________ 30 | void ArrowStateData::disconnect( GtkWidget* widget ) 31 | { 32 | #if OXYGEN_DEBUG 33 | std::cerr << "Oxygen::ArrowStateData::disconnect - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; 34 | #endif 35 | 36 | _upArrowData._timeLine.disconnect(); 37 | _upArrowData._state = false; 38 | 39 | _downArrowData._timeLine.disconnect(); 40 | _downArrowData._state = false; 41 | 42 | _target = 0L; 43 | 44 | } 45 | 46 | //_____________________________________________ 47 | bool ArrowStateData::Data::updateState( bool state ) 48 | { 49 | if( state == _state ) return false; 50 | 51 | #if OXYGEN_DEBUG 52 | std::cerr 53 | << "Oxygen::ArrowStateData::Data::updateState - " 54 | << " state: " << state 55 | << std::endl; 56 | #endif 57 | 58 | _state = state; 59 | 60 | // change direction 61 | _timeLine.setDirection( state ? TimeLine::Forward:TimeLine::Backward ); 62 | 63 | // restart timeLine if needed 64 | if( _timeLine.isConnected() && !_timeLine.isRunning() ) _timeLine.start(); 65 | 66 | return true; 67 | } 68 | 69 | //_____________________________________________ 70 | gboolean ArrowStateData::delayedUpdate( gpointer pointer ) 71 | { 72 | 73 | ArrowStateData& data( *static_cast( pointer ) ); 74 | 75 | if( data._target ) 76 | { gtk_widget_queue_draw( data._target ); } 77 | 78 | return FALSE; 79 | 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/animations/oxygenbaseengine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenbaseengine.h" 9 | #include "oxygenanimations.h" 10 | 11 | namespace Oxygen 12 | { 13 | //______________________________________________________ 14 | bool BaseEngine::registerWidget( GtkWidget* widget ) 15 | { return parent().registerWidget( widget ); } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/animations/oxygenbaseengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenbaseengine_h 2 | #define oxygenbaseengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //! forward declaration 17 | class Animations; 18 | 19 | //! base class for all engines 20 | /*! engines map pointers to GtkWidget to some data, needed for animations */ 21 | class BaseEngine 22 | { 23 | public: 24 | 25 | //! constructor 26 | BaseEngine( Animations* parent ): 27 | _parent( parent ), 28 | _enabled( true ) 29 | {} 30 | 31 | virtual ~BaseEngine() 32 | {} 33 | 34 | //! register widget 35 | virtual bool registerWidget( GtkWidget* widget ); 36 | 37 | //! unregister widget 38 | virtual void unregisterWidget( GtkWidget* ) = 0; 39 | 40 | //! engine list 41 | typedef std::vector< BaseEngine* > List; 42 | 43 | //! enable state 44 | /*! returns true if changed */ 45 | virtual bool setEnabled( bool value ) 46 | { 47 | if( _enabled == value ) return false; 48 | _enabled = value; 49 | return true; 50 | } 51 | 52 | //! enable state 53 | bool enabled( void ) const 54 | { return _enabled; } 55 | 56 | protected: 57 | 58 | //! returns parent 59 | virtual Animations& parent( void ) const 60 | { return *_parent; } 61 | 62 | private: 63 | 64 | //! parent 65 | Animations* _parent; 66 | 67 | //! enable flag 68 | bool _enabled; 69 | 70 | }; 71 | 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /src/animations/oxygencomboengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygencomboengine_h 2 | #define oxygencomboengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygenbaseengine.h" 12 | 13 | #include 14 | #include 15 | 16 | namespace Oxygen 17 | { 18 | //! forward declaration 19 | class Animations; 20 | 21 | //! stores data associated to editable comboes 22 | /*! 23 | ensures that the text and the button of editable comboes 24 | gets hovered and focus flags at the same time 25 | */ 26 | class ComboEngine: public BaseEngine 27 | { 28 | 29 | public: 30 | 31 | //! constructor 32 | ComboEngine( Animations* widget ): 33 | BaseEngine( widget ) 34 | {} 35 | 36 | //! destructor 37 | virtual ~ComboEngine( void ) 38 | {} 39 | 40 | //! register widget 41 | virtual bool registerWidget( GtkWidget* widget ) 42 | { 43 | if( contains( widget ) ) return false; 44 | _data.insert( widget ); 45 | return true; 46 | } 47 | 48 | //! unregister widget 49 | virtual void unregisterWidget( GtkWidget* widget ) 50 | { _data.erase( widget ); } 51 | 52 | //! true if widget is included 53 | virtual bool contains( GtkWidget* widget ) 54 | { return _data.find( widget ) != _data.end(); } 55 | 56 | //@} 57 | 58 | //!@name accessors 59 | //@{ 60 | 61 | //! find combo matching widget 62 | /*! the widget can be any of those in a visible list */ 63 | inline GtkWidget* find( GtkWidget* ) const; 64 | 65 | //@} 66 | 67 | private: 68 | 69 | //! store registered widgets 70 | std::set _data; 71 | 72 | }; 73 | 74 | //_________________________________________________ 75 | GtkWidget* ComboEngine::find( GtkWidget* value ) const 76 | { 77 | GtkWidget* topLevel( gtk_widget_get_toplevel( value ) ); 78 | for( std::set::const_iterator iter = _data.begin(); iter != _data.end(); iter++ ) 79 | { 80 | 81 | if( GTK_IS_COMBO( *iter ) && topLevel == GTK_COMBO( *iter )->popwin ) 82 | { return *iter; } 83 | 84 | } 85 | 86 | return 0L; 87 | 88 | } 89 | 90 | } 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /src/animations/oxygendialogengine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygendialogengine.h" 9 | #include "../oxygengtktypenames.h" 10 | #include "../oxygengtkutils.h" 11 | #include "../config.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | //_________________________________________________________ 18 | bool DialogEngine::registerWidget( GtkWidget* widget ) 19 | { 20 | if( contains( widget ) ) return false; 21 | 22 | GtkDialog* dialog(GTK_DIALOG(widget)); 23 | 24 | GtkResponseType responses[]={ 25 | GTK_RESPONSE_HELP, 26 | (GtkResponseType)1, // FIXME: This id is commonly used, but doesn't seem to be documented anywhere... 27 | GTK_RESPONSE_OK, 28 | GTK_RESPONSE_YES, 29 | GTK_RESPONSE_ACCEPT, 30 | GTK_RESPONSE_APPLY, 31 | GTK_RESPONSE_REJECT, 32 | GTK_RESPONSE_CLOSE, 33 | GTK_RESPONSE_NO, 34 | GTK_RESPONSE_CANCEL 35 | }; 36 | 37 | const int numOfResponseIDs=sizeof(responses)/sizeof(responses[0]); 38 | 39 | #if OXYGEN_DEBUG 40 | std::cerr<<"DialogEngine::registerWidget - Initial response table: "; 41 | for(int i=0; i= numOfResponsesFound, so this will copy response id nearer to start, but never to end 56 | responses[numOfResponsesFound]=responses[i]; 57 | numOfResponsesFound++; 58 | 59 | } 60 | 61 | #if OXYGEN_DEBUG 62 | std::cerr << "DialogEngine::registerWidget - numOfResponsesFound: " << numOfResponsesFound << std::endl; 63 | std::cerr << "List of responses found: { "; 64 | 65 | for(int i=0; i 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "oxygenbaseengine.h" 11 | 12 | #include 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | //! forward declaration 18 | class Animations; 19 | 20 | //! associates widgets with some type of data 21 | class DialogEngine: public BaseEngine 22 | { 23 | 24 | public: 25 | 26 | //! constructor 27 | DialogEngine( Animations* widget ): 28 | BaseEngine( widget ) 29 | {} 30 | 31 | //! destructor 32 | virtual ~DialogEngine( void ) 33 | {} 34 | 35 | //! register widget 36 | virtual bool registerWidget( GtkWidget* ); 37 | 38 | //! unregister widget 39 | virtual void unregisterWidget( GtkWidget* widget ) 40 | { _data.erase( widget ); } 41 | 42 | //! true if widget is included 43 | virtual bool contains( GtkWidget* widget ) 44 | { return _data.find( widget ) != _data.end(); } 45 | 46 | private: 47 | 48 | //! store registered widgets 49 | std::set _data; 50 | 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/animations/oxygenflatwidgetengine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenflatwidgetengine.h" 9 | #include "../oxygengtktypenames.h" 10 | #include "../oxygengtkutils.h" 11 | #include "../config.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | //_________________________________________________________ 18 | bool FlatWidgetEngine::registerFlatWidget( GtkWidget* widget ) 19 | { 20 | if( containsFlat( widget ) ) return false; 21 | _flatData.insert( widget ); 22 | BaseEngine::registerWidget( widget ); 23 | return true; 24 | } 25 | 26 | //_________________________________________________________ 27 | bool FlatWidgetEngine::registerPaintWidget( GtkWidget* widget ) 28 | { 29 | if( containsPaint( widget ) ) return false; 30 | _paintData.insert( widget ); 31 | BaseEngine::registerWidget( widget ); 32 | return true; 33 | } 34 | 35 | //_________________________________________________________ 36 | GtkWidget* FlatWidgetEngine::flatParent( GtkWidget* widget ) 37 | { 38 | 39 | for( GtkWidget* parent = widget; parent; parent = gtk_widget_get_parent( parent ) ) 40 | { 41 | if( containsPaint( parent ) ) return 0x0; 42 | else if( containsFlat( parent ) ) return parent; 43 | } 44 | 45 | return 0L; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/animations/oxygenflatwidgetengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenflatwidgetengine_h 2 | #define oxygenflatwidgetengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "oxygenbaseengine.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace Oxygen 17 | { 18 | //! forward declaration 19 | class Animations; 20 | 21 | //! associates widgets with some type of data 22 | class FlatWidgetEngine: public BaseEngine 23 | { 24 | 25 | public: 26 | 27 | //! constructor 28 | FlatWidgetEngine( Animations* widget ): 29 | BaseEngine( widget ) 30 | {} 31 | 32 | //! destructor 33 | virtual ~FlatWidgetEngine( void ) 34 | {} 35 | 36 | //! register widget 37 | virtual bool registerWidget( GtkWidget* widget ) 38 | { return registerFlatWidget( widget ); } 39 | 40 | //! register widget 41 | virtual bool registerFlatWidget( GtkWidget* ); 42 | 43 | //! register widget 44 | virtual bool registerPaintWidget( GtkWidget* ); 45 | 46 | //! unregister widget 47 | virtual void unregisterWidget( GtkWidget* widget ) 48 | { 49 | _flatData.erase( widget ); 50 | _paintData.erase( widget ); 51 | } 52 | 53 | //! true if one of widgets parent is included 54 | virtual GtkWidget* flatParent( GtkWidget* ); 55 | 56 | protected: 57 | 58 | bool containsFlat( GtkWidget* widget ) const 59 | { return _flatData.find( widget ) != _flatData.end(); } 60 | 61 | bool containsPaint( GtkWidget* widget ) const 62 | { return _paintData.find( widget ) != _paintData.end(); } 63 | 64 | private: 65 | 66 | //! store registered widgets 67 | std::set _flatData; 68 | std::set _paintData; 69 | 70 | }; 71 | 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /src/animations/oxygenfollowmousedata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenfollowmousedata.h" 9 | 10 | namespace Oxygen 11 | { 12 | 13 | //________________________________________________________________________________ 14 | void FollowMouseData::startAnimation( const GdkRectangle& startRect, const GdkRectangle& endRect ) 15 | { 16 | 17 | // copy end rect 18 | _endRect = endRect; 19 | 20 | // check timeLine status 21 | if( _timeLine.isRunning() && 22 | _timeLine.value() < 1.0 && 23 | Gtk::gdk_rectangle_is_valid( &_endRect ) && 24 | Gtk::gdk_rectangle_is_valid( &_animatedRect ) ) 25 | { 26 | 27 | // mark old start rect as part of dirtyRect 28 | _dirtyRect = _startRect; 29 | 30 | // do some math so that the animation finishes at new endRect without discontinuity 31 | const double ratio( _timeLine.value()/(1.0-_timeLine.value() ) ); 32 | _startRect.x += double( _animatedRect.x - _endRect.x )*ratio; 33 | _startRect.y += double( _animatedRect.y - _endRect.y )*ratio; 34 | _startRect.width += double( _animatedRect.width - _endRect.width )*ratio; 35 | _startRect.height += double( _animatedRect.height - _endRect.height )*ratio; 36 | 37 | 38 | } else { 39 | 40 | if( _timeLine.isRunning() ) _timeLine.stop(); 41 | _startRect = startRect; 42 | _timeLine.start(); 43 | 44 | } 45 | 46 | return; 47 | 48 | } 49 | 50 | //________________________________________________________________________________ 51 | void FollowMouseData::updateAnimatedRect( void ) 52 | { 53 | if( _timeLine.isRunning() && 54 | Gtk::gdk_rectangle_is_valid( &_startRect ) && 55 | Gtk::gdk_rectangle_is_valid( &_endRect ) ) 56 | { 57 | 58 | _animatedRect.x = _startRect.x + double( _endRect.x - _startRect.x )*_timeLine.value(); 59 | _animatedRect.y = _startRect.y + double( _endRect.y - _startRect.y )*_timeLine.value(); 60 | _animatedRect.width = _startRect.width + double( _endRect.width - _startRect.width )*_timeLine.value(); 61 | _animatedRect.height = _startRect.height + double( _endRect.height - _startRect.height )*_timeLine.value(); 62 | 63 | } else { 64 | 65 | _animatedRect = Gtk::gdk_rectangle(); 66 | 67 | } 68 | 69 | return; 70 | 71 | } 72 | 73 | //________________________________________________________________________________ 74 | GdkRectangle FollowMouseData::dirtyRect( void ) 75 | { 76 | 77 | GdkRectangle rect( Gtk::gdk_rectangle() ); 78 | Gtk::gdk_rectangle_union( &_startRect, &_animatedRect, &rect ); 79 | 80 | // also union with dirty rect 81 | if( Gtk::gdk_rectangle_is_valid( &_dirtyRect ) ) 82 | { 83 | Gtk::gdk_rectangle_union( &_dirtyRect, &rect, &rect ); 84 | _dirtyRect = Gtk::gdk_rectangle(); 85 | } 86 | 87 | return rect; 88 | 89 | } 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/animations/oxygengenericengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygengenericengine_h 2 | #define oxygengenericengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygenbaseengine.h" 12 | #include "oxygendatamap.h" 13 | 14 | #include 15 | 16 | namespace Oxygen 17 | { 18 | //! forward declaration 19 | class Animations; 20 | 21 | //! associates widgets with some type of data 22 | template< typename T> 23 | class GenericEngine: public BaseEngine 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | GenericEngine( Animations* widget ): 30 | BaseEngine( widget ) 31 | {} 32 | 33 | //! destructor 34 | virtual ~GenericEngine( void ) 35 | {} 36 | 37 | //! register widget 38 | virtual bool registerWidget( GtkWidget* widget ) 39 | { 40 | if( _data.contains( widget ) ) return false; 41 | if( enabled() ) 42 | { 43 | 44 | T& data( _data.registerWidget( widget ) ); 45 | data.connect( widget ); 46 | 47 | } else _data.registerWidget( widget ); 48 | 49 | BaseEngine::registerWidget( widget ); 50 | return true; 51 | 52 | } 53 | 54 | //! unregister widget 55 | virtual void unregisterWidget( GtkWidget* widget ) 56 | { 57 | if( !_data.contains( widget ) ) return; 58 | _data.value( widget ).disconnect( widget ); 59 | _data.erase( widget ); 60 | } 61 | 62 | //! enabled state 63 | /*! returns true if changed */ 64 | inline virtual bool setEnabled( bool value ); 65 | 66 | //! true if widget is included 67 | virtual bool contains( GtkWidget* widget ) 68 | { return _data.contains( widget ); } 69 | 70 | protected: 71 | 72 | //! return refence to data 73 | virtual DataMap& data( void ) 74 | { return _data; } 75 | 76 | //! return refence to data 77 | virtual const DataMap& data( void ) const 78 | { return _data; } 79 | 80 | private: 81 | 82 | //! map widgets to data 83 | DataMap _data; 84 | 85 | }; 86 | 87 | //________________________________________________________________________ 88 | template< typename T> bool GenericEngine::setEnabled( bool value ) 89 | { 90 | if( enabled() == value ) return false; 91 | 92 | BaseEngine::setEnabled( value ); 93 | if( enabled() ) _data.connectAll(); 94 | else _data.disconnectAll(); 95 | 96 | return true; 97 | 98 | } 99 | 100 | } 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /src/animations/oxygengroupboxengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygengroupboxengine_h 2 | #define oxygengroupboxengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "oxygenbaseengine.h" 11 | 12 | #include 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | //! forward declaration 18 | class Animations; 19 | 20 | //! associates widgets with some type of data 21 | class GroupBoxEngine: public BaseEngine 22 | { 23 | 24 | public: 25 | 26 | //! constructor 27 | GroupBoxEngine( Animations* widget ): 28 | BaseEngine( widget ) 29 | {} 30 | 31 | //! destructor 32 | virtual ~GroupBoxEngine( void ) 33 | {} 34 | 35 | //! register widget 36 | virtual bool registerWidget( GtkWidget* widget ) 37 | { return( _data.insert( widget ).second ); } 38 | 39 | //! unregister widget 40 | virtual void unregisterWidget( GtkWidget* widget ) 41 | { _data.erase( widget ); } 42 | 43 | //! true if widget is included 44 | virtual bool contains( GtkWidget* widget ) 45 | { return _data.find( widget ) != _data.end(); } 46 | 47 | private: 48 | 49 | //! store registered widgets 50 | std::set _data; 51 | 52 | }; 53 | 54 | } 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/animations/oxygengroupboxlabeldata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygengroupboxlabeldata_h 2 | #define oxygengroupboxlabeldata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "../oxygengtkutils.h" 11 | 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | // track groupboxlabels 17 | class GroupBoxLabelData 18 | { 19 | 20 | public: 21 | 22 | //! constructor 23 | GroupBoxLabelData( void ): 24 | _resized( false ) 25 | {} 26 | 27 | //! destructor 28 | virtual ~GroupBoxLabelData( void ) 29 | {} 30 | 31 | //! setup connections 32 | void connect( GtkWidget* ) 33 | {} 34 | 35 | //! disconnect 36 | void disconnect( GtkWidget* ) 37 | { _resized = false; } 38 | 39 | //! adjust widget size 40 | void adjustSize( GtkWidget* widget ) 41 | { 42 | if( _resized ) return; 43 | const GdkRectangle allocation( Gtk::gtk_widget_get_allocation( widget ) ); 44 | if( allocation.height > 1 ) 45 | { 46 | 47 | // Save resized state before actually resizing to prevent infinite recursion (bug 305833) 48 | _resized = true; 49 | gtk_widget_set_size_request( widget, allocation.width, allocation.height+14 ); 50 | 51 | } 52 | } 53 | 54 | private: 55 | 56 | bool _resized; 57 | 58 | }; 59 | 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/animations/oxygengroupboxlabelengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygengroupboxlabelengine_h 2 | #define oxygengroupboxlabelengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygengroupboxlabeldata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable scrolled windows 23 | class GroupBoxLabelEngine: public GenericEngine 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | GroupBoxLabelEngine( Animations* widget ): 30 | GenericEngine( widget ) 31 | {} 32 | 33 | //! destructor 34 | virtual ~GroupBoxLabelEngine( void ) 35 | {} 36 | 37 | // adjust widget size 38 | void adjustSize( GtkWidget* widget ) 39 | { return data().value( widget ).adjustSize( widget ); } 40 | 41 | }; 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/animations/oxygenhook.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 5 | 6 | SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygenhook.h" 10 | #include "../config.h" 11 | 12 | #include 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | 18 | #if OXYGEN_DEBUG 19 | static int counter( 0 ); 20 | #endif 21 | 22 | //__________________________________________________________________ 23 | bool Hook::connect( const std::string& signal, GType typeId, GSignalEmissionHook hookFunction, gpointer data ) 24 | { 25 | #if DISABLE_SIGNAL_HOOKS 26 | return false; 27 | #endif 28 | // make sure that signal is not already connected 29 | assert( _signalId == 0 && _hookId == 0 ); 30 | 31 | // check type id 32 | if( !g_type_class_peek( typeId ) ) 33 | { 34 | 35 | #if OXYGEN_DEBUG 36 | std::cerr << "Oxygen::Hook::connect - typeId " << g_type_name(typeId) << " not yet installed" << std::endl; 37 | #endif 38 | 39 | g_type_class_ref( typeId ); 40 | 41 | } 42 | 43 | // store signal id 44 | _signalId = g_signal_lookup( signal.c_str(), typeId ); 45 | if( !_signalId ) 46 | { 47 | 48 | #if OXYGEN_DEBUG 49 | std::cerr << "Oxygen::Hook::connect - signal " << signal << " not installed." << std::endl; 50 | #endif 51 | 52 | return false; 53 | 54 | } 55 | 56 | // store attributes and create connection 57 | _hookId = g_signal_add_emission_hook( 58 | _signalId, 59 | (GQuark)0L, 60 | hookFunction, 61 | data, 0L); 62 | 63 | #if OXYGEN_DEBUG 64 | ++counter; 65 | std::cerr << "Oxygen::Hook::connect - hook: " << _hookId << " counter: " << counter << std::endl; 66 | #endif 67 | 68 | return true; 69 | 70 | } 71 | 72 | //____________________________________________________________________ 73 | void Hook::disconnect( void ) 74 | { 75 | #if DISABLE_SIGNAL_HOOKS 76 | return; 77 | #endif 78 | 79 | // disconnect signal 80 | if( _signalId > 0 && _hookId > 0 ) 81 | { 82 | 83 | #if OXYGEN_DEBUG 84 | --counter; 85 | std::cerr << "Oxygen::Hook::disconnect - hook: " << _hookId << " counter: " << counter << std::endl; 86 | #endif 87 | 88 | g_signal_remove_emission_hook( _signalId, _hookId ); 89 | 90 | } 91 | 92 | _signalId = 0; 93 | _hookId = 0; 94 | 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/animations/oxygenhook.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenhook_h 2 | #define oxygenhook_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | //! handles gtk signal hooks 17 | class Hook 18 | { 19 | public: 20 | 21 | //! constructor 22 | Hook( void ): 23 | _signalId(0), 24 | _hookId(0) 25 | {} 26 | 27 | //! destructor 28 | virtual ~Hook( void ) 29 | {} 30 | 31 | 32 | 33 | //! connect 34 | bool connect( const std::string&, GType, GSignalEmissionHook, gpointer ); 35 | 36 | bool connect( const std::string& signal, GSignalEmissionHook hook, gpointer data ) 37 | { return connect( signal, GTK_TYPE_WIDGET, hook, data ); } 38 | 39 | //! disconnect 40 | void disconnect( void ); 41 | 42 | private: 43 | 44 | //! signal id 45 | guint _signalId; 46 | gulong _hookId; 47 | 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/animations/oxygenhoverdata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenhoverdata_h 2 | #define oxygenhoverdata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygensignal.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | class HoverData 18 | { 19 | 20 | public: 21 | 22 | //! constructor 23 | HoverData( void ): 24 | _hovered( false ), 25 | _updateOnHover( false ) 26 | {} 27 | 28 | //! destructor 29 | virtual ~HoverData( void ) 30 | { disconnect( 0L ); } 31 | 32 | //! setup connections 33 | virtual void connect( GtkWidget* ); 34 | 35 | //! disconnect 36 | virtual void disconnect( GtkWidget* ); 37 | 38 | //! true if hovered 39 | virtual bool hovered( void ) const 40 | { return _hovered; } 41 | 42 | //! true if hover state change should trigger widget repaint 43 | void setUpdateOnHover( bool value ) 44 | { _updateOnHover = value; } 45 | 46 | //! set mouse over state 47 | virtual bool setHovered( GtkWidget* widget, bool value ) 48 | { 49 | if( _hovered == value ) return false; 50 | _hovered = value; 51 | 52 | // schedule repaint 53 | if( _updateOnHover ) 54 | { gtk_widget_queue_draw( widget ); } 55 | 56 | return true; 57 | } 58 | 59 | protected: 60 | 61 | //!@name static callbacks 62 | //@{ 63 | static gboolean enterNotifyEvent( GtkWidget*, GdkEventCrossing*, gpointer ); 64 | static gboolean leaveNotifyEvent( GtkWidget*, GdkEventCrossing*, gpointer ); 65 | //@} 66 | 67 | private: 68 | 69 | //! enter signal id 70 | Signal _enterId; 71 | 72 | //! leave signal id 73 | Signal _leaveId; 74 | 75 | //! true if hovered 76 | bool _hovered; 77 | 78 | //! also update 79 | bool _updateOnHover; 80 | 81 | }; 82 | 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/animations/oxygenhoverengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenhoverengine_h 2 | #define oxygenhoverengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygenhoverdata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable comboboxes 23 | /*! 24 | ensures that the text entry and the button of editable comboboxes 25 | gets hovered and focus flags at the same time 26 | */ 27 | class HoverEngine: public GenericEngine 28 | { 29 | 30 | public: 31 | 32 | //! constructor 33 | HoverEngine( Animations* parent ): 34 | GenericEngine( parent ) 35 | {} 36 | 37 | //! destructor 38 | virtual ~HoverEngine( void ) 39 | {} 40 | 41 | //! register widget 42 | virtual bool registerWidget( GtkWidget* widget ) 43 | { return registerWidget( widget, false ); } 44 | 45 | //! register widget 46 | virtual bool registerWidget( GtkWidget* widget, bool updateOnHover ) 47 | { 48 | if( GenericEngine::registerWidget( widget ) ) 49 | { 50 | data().value(widget).setUpdateOnHover( updateOnHover ); 51 | return true; 52 | } else return false; 53 | 54 | } 55 | 56 | //! true if widget is hovered 57 | bool hovered( GtkWidget* widget ) 58 | { return data().value( widget ).hovered(); } 59 | 60 | //! set hover state 61 | bool setHovered( GtkWidget* widget, bool value ) 62 | { return data().value( widget ).setHovered( widget, value ); } 63 | 64 | }; 65 | 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /src/animations/oxygeninnershadowdata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygeninnershadowdata_h 2 | #define oxygeninnershadowdata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygensignal.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! handle inner shadow drawing using composited GdkWindow API 20 | class InnerShadowData 21 | { 22 | 23 | public: 24 | 25 | //! constructor 26 | InnerShadowData( void ): 27 | _target(0) 28 | {} 29 | 30 | //! destructor 31 | virtual ~InnerShadowData( void ) 32 | { disconnect( _target ); } 33 | 34 | //! setup connections 35 | void connect( GtkWidget* ); 36 | 37 | //! disconnect 38 | void disconnect( GtkWidget* ); 39 | 40 | //! register child 41 | /*! needed to restore composited state on disconnect */ 42 | void registerChild( GtkWidget* ); 43 | 44 | protected: 45 | 46 | //! unregister child 47 | void unregisterChild( GtkWidget* ); 48 | 49 | //!@ callbacks 50 | //@{ 51 | static gboolean childUnrealizeNotifyEvent( GtkWidget*, gpointer ); 52 | static gboolean targetExposeEvent( GtkWidget*, GdkEventExpose*, gpointer ); 53 | //@} 54 | 55 | private: 56 | 57 | //! target widget 58 | GtkWidget* _target; 59 | 60 | //! expose 61 | Signal _exposeId; 62 | 63 | //! child data 64 | class ChildData 65 | { 66 | public: 67 | 68 | //! constructor 69 | ChildData( void ): 70 | _initiallyComposited( false ) 71 | {} 72 | 73 | //! destructor 74 | virtual ~ChildData( void ) 75 | {} 76 | 77 | //! disconnect all signals 78 | void disconnect( GtkWidget* ); 79 | 80 | //! signal 81 | Signal _unrealizeId; 82 | 83 | //! keep track of composited state 84 | bool _initiallyComposited; 85 | }; 86 | 87 | //! map registered children and corresponding data 88 | typedef std::map ChildDataMap; 89 | ChildDataMap _childrenData; 90 | 91 | }; 92 | 93 | } 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /src/animations/oxygeninnershadowengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygeninnershadowengine_h 2 | #define oxygeninnershadowengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | 12 | #include "oxygengenericengine.h" 13 | #include "oxygendatamap.h" 14 | #include "oxygeninnershadowdata.h" 15 | 16 | #include 17 | 18 | namespace Oxygen 19 | { 20 | //! forward declaration 21 | class Animations; 22 | 23 | //! stores data associated to editable scrolled windows 24 | class InnerShadowEngine: public GenericEngine 25 | { 26 | 27 | public: 28 | 29 | //! constructor 30 | InnerShadowEngine( Animations* widget ): 31 | GenericEngine( widget ) 32 | {} 33 | 34 | //! destructor 35 | virtual ~InnerShadowEngine( void ) 36 | {} 37 | 38 | //! register child 39 | void registerChild( GtkWidget* widget, GtkWidget* child ) 40 | { data().value( widget ).registerChild( child ); } 41 | 42 | }; 43 | 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/animations/oxygenmainwindowdata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 5 | 6 | SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygenmainwindowdata.h" 10 | #include "../oxygengtkutils.h" 11 | 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | 17 | //________________________________________________________________________________ 18 | void MainWindowData::connect( GtkWidget* widget ) 19 | { 20 | _target = widget; 21 | _locked = false; 22 | _configureId.connect( G_OBJECT(widget), "configure-event", G_CALLBACK( configureNotifyEvent ), this); 23 | } 24 | 25 | //________________________________________________________________________________ 26 | void MainWindowData::disconnect( GtkWidget* widget ) 27 | { 28 | _target = 0L; 29 | 30 | // reset timeout and locked flag 31 | _timer.stop(); 32 | _locked = false; 33 | 34 | _configureId.disconnect(); 35 | } 36 | 37 | //________________________________________________________________________________ 38 | void MainWindowData::updateSize( int width, int height ) 39 | { 40 | 41 | if( width == _width && height == _height ) return; 42 | _width = width; 43 | _height = height; 44 | 45 | // schedule delayed timeOut 46 | if( !_timer.isRunning() ) 47 | { 48 | 49 | _timer.start( 50, (GSourceFunc)delayedUpdate, this ); 50 | _locked = false; 51 | 52 | } else _locked = true; 53 | 54 | } 55 | 56 | //________________________________________________________________________________ 57 | gboolean MainWindowData::configureNotifyEvent(GtkWidget* widget, GdkEventConfigure* event, gpointer data ) 58 | { 59 | static_cast(data)->updateSize( event->width, event->height ); 60 | return FALSE; 61 | } 62 | 63 | //________________________________________________________________________________ 64 | gboolean MainWindowData::delayedUpdate( gpointer pointer ) 65 | { 66 | 67 | MainWindowData& data( *static_cast(pointer) ); 68 | if( !data._target ) 69 | { 70 | 71 | // if target is invalid, reset timeout and return 72 | data._locked = false; 73 | return FALSE; 74 | 75 | } else if( data._locked ) { 76 | 77 | // if locked, reset the flag and re-run timer 78 | data._locked = false; 79 | return TRUE; 80 | 81 | } else { 82 | 83 | // otherwise, trigger update 84 | gtk_widget_queue_draw( data._target ); 85 | return FALSE; 86 | 87 | } 88 | 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/animations/oxygenmainwindowdata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenmainwindowdata_h 2 | #define oxygenmainwindowdata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygensignal.h" 12 | #include "oxygentimer.h" 13 | 14 | #include 15 | 16 | namespace Oxygen 17 | { 18 | // track main window resize events 19 | class MainWindowData 20 | { 21 | 22 | public: 23 | 24 | //! constructor 25 | MainWindowData( void ): 26 | _target(0L), 27 | _locked(false), 28 | _width(-1), 29 | _height(-1) 30 | {} 31 | 32 | //! destructor 33 | virtual ~MainWindowData( void ) 34 | { disconnect( _target ); } 35 | 36 | //! setup connections 37 | void connect( GtkWidget* ); 38 | 39 | //! disconnect 40 | void disconnect( GtkWidget* ); 41 | 42 | protected: 43 | 44 | //! update size 45 | void updateSize( int width, int height ); 46 | 47 | //!name static callbacks 48 | static gboolean configureNotifyEvent( GtkWidget*, GdkEventConfigure*, gpointer); 49 | 50 | //! delayed update 51 | static gboolean delayedUpdate( gpointer ); 52 | 53 | private: 54 | 55 | //! pointer to associated widget 56 | GtkWidget* _target; 57 | 58 | //! timer 59 | Timer _timer; 60 | 61 | //! true if next update must be delayed 62 | bool _locked; 63 | 64 | //! configure signal id 65 | Signal _configureId; 66 | 67 | //! old width 68 | int _width; 69 | 70 | //! old height 71 | int _height; 72 | 73 | 74 | }; 75 | 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/animations/oxygenmainwindowengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenmainwindowengine_h 2 | #define oxygenmainwindowengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygenmainwindowdata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable mainwindowes 23 | /*! 24 | ensures that the text entry and the button of editable mainwindowes 25 | gets hovered and focus flags at the same time 26 | */ 27 | class MainWindowEngine: public GenericEngine 28 | { 29 | 30 | public: 31 | 32 | //! constructor 33 | MainWindowEngine( Animations* widget ): 34 | GenericEngine( widget ) 35 | {} 36 | 37 | //! destructor 38 | virtual ~MainWindowEngine( void ) 39 | {} 40 | 41 | }; 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/animations/oxygenmenuitemdata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 5 | 6 | SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygenmenuitemdata.h" 10 | #include "../oxygengtkutils.h" 11 | #include "../config.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | 18 | //________________________________________________________________________________ 19 | void MenuItemData::connect( GtkWidget* widget ) 20 | { 21 | _target = widget; 22 | _parentSetId.connect( G_OBJECT(widget), "parent-set", G_CALLBACK( parentSet ), this); 23 | } 24 | 25 | //________________________________________________________________________________ 26 | void MenuItemData::disconnect( GtkWidget* widget ) 27 | { 28 | _target = 0L; 29 | _parentSetId.disconnect(); 30 | } 31 | 32 | //_____________________________________________________ 33 | void MenuItemData::parentSet( GtkWidget* widget, GtkWidget*, gpointer data ) 34 | { 35 | 36 | // check type 37 | if( !GTK_IS_WIDGET( widget ) ) return; 38 | 39 | // retrieve parent window and check 40 | GdkWindow* window( gtk_widget_get_parent_window( widget ) ); 41 | if( !window ) return; 42 | 43 | static_cast(data)->attachStyle( widget, window ); 44 | return; 45 | 46 | } 47 | 48 | //_____________________________________________________ 49 | void MenuItemData::attachStyle( GtkWidget* widget, GdkWindow* window ) const 50 | { 51 | 52 | // retrieve widget style and check 53 | GtkStyle* style( gtk_widget_get_style( widget ) ); 54 | if( !( style && style->depth >= 0 ) ) return; 55 | 56 | // adjust depth 57 | if( style->depth == gdk_drawable_get_depth( window ) ) 58 | { return; } 59 | 60 | #if OXYGEN_DEBUG 61 | std::cerr 62 | << "Oxygen::MenuItemData::attachStyle -" 63 | << " widget: " << widget << " (" <depth 65 | << " window depth: " << gdk_drawable_get_depth( window ) 66 | << std::endl; 67 | #endif 68 | 69 | widget->style = gtk_style_attach( style, window ); 70 | 71 | // if widget is a container, we need to do the same for its children 72 | if( !GTK_IS_CONTAINER( widget ) ) return; 73 | 74 | // get children 75 | GList* children( gtk_container_get_children( GTK_CONTAINER( widget ) ) ); 76 | for( GList *child = g_list_first( children ); child; child = g_list_next( child ) ) 77 | { 78 | if( !GTK_IS_WIDGET( child->data ) ) continue; 79 | attachStyle( GTK_WIDGET( child->data ), window ); 80 | } 81 | 82 | if( children ) g_list_free( children ); 83 | 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/animations/oxygenmenuitemdata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenmenuitemdata_h 2 | #define oxygenmenuitemdata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygensignal.h" 12 | #include "oxygentimer.h" 13 | 14 | #include 15 | 16 | namespace Oxygen 17 | { 18 | // track main window resize events 19 | class MenuItemData 20 | { 21 | 22 | public: 23 | 24 | //! constructor 25 | MenuItemData( void ): 26 | _target(0) 27 | {} 28 | 29 | //! destructor 30 | virtual ~MenuItemData( void ) 31 | { disconnect( _target ); } 32 | 33 | //! setup connections 34 | void connect( GtkWidget* ); 35 | 36 | //! disconnect 37 | void disconnect( GtkWidget* ); 38 | 39 | protected: 40 | 41 | //! attach style of widget to passed window [recursive] 42 | void attachStyle( GtkWidget*, GdkWindow* ) const; 43 | 44 | //! parent set callback 45 | static void parentSet( GtkWidget*, GtkWidget*, gpointer ); 46 | 47 | private: 48 | 49 | //! target 50 | GtkWidget* _target; 51 | 52 | //! reparent signal id 53 | Signal _parentSetId; 54 | 55 | }; 56 | 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/animations/oxygenmenuitemengine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenmenuitemengine.h" 9 | #include 10 | 11 | namespace Oxygen 12 | { 13 | 14 | //_______________________________________________________________ 15 | bool MenuItemEngine::registerMenu( GtkWidget* parent ) 16 | { 17 | 18 | // check widget 19 | if( !GTK_IS_MENU( parent ) ) return false; 20 | 21 | // keep track of added children 22 | bool found( false ); 23 | 24 | // get children 25 | GList* children( gtk_container_get_children( GTK_CONTAINER( parent ) ) ); 26 | for( GList *child = g_list_first( children ); child; child = g_list_next( child ) ) 27 | { 28 | if( !GTK_IS_MENU_ITEM( child->data ) ) continue; 29 | GtkWidget* widget( gtk_bin_get_child( GTK_BIN( child->data ) ) ); 30 | if( registerWidget( widget ) ) found = true; 31 | } 32 | 33 | // free list of children 34 | if( children ) g_list_free( children ); 35 | 36 | return found; 37 | 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/animations/oxygenmenuitemengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenmenuitemengine_h 2 | #define oxygenmenuitemengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygenmenuitemdata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable menuitemes 23 | /*! 24 | ensures that the text entry and the button of editable menuitemes 25 | gets hovered and focus flags at the same time 26 | */ 27 | class MenuItemEngine: public GenericEngine 28 | { 29 | 30 | public: 31 | 32 | //! constructor 33 | MenuItemEngine( Animations* widget ): 34 | GenericEngine( widget ) 35 | {} 36 | 37 | //! destructor 38 | virtual ~MenuItemEngine( void ) 39 | {} 40 | 41 | //! register all menuItems children of a menu 42 | virtual bool registerMenu( GtkWidget* ); 43 | 44 | }; 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/animations/oxygenpaneddata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenpaneddata.h" 9 | 10 | #include 11 | 12 | namespace Oxygen 13 | { 14 | 15 | //_______________________________________________ 16 | void PanedData::connect( GtkWidget* widget ) 17 | { 18 | updateCursor( widget ); 19 | _realizeId.connect( G_OBJECT(widget), "realize", G_CALLBACK( realizeEvent ), this ); 20 | } 21 | 22 | //_______________________________________________ 23 | void PanedData::disconnect( GtkWidget* ) 24 | { _realizeId.disconnect(); } 25 | 26 | //_______________________________________________ 27 | void PanedData::realizeEvent( GtkWidget* widget, gpointer data ) 28 | { static_cast( data )->updateCursor( widget ); } 29 | 30 | //_______________________________________________ 31 | void PanedData::updateCursor( GtkWidget* widget ) 32 | { 33 | 34 | // do nothing if incorrect widget type 35 | if( !GTK_IS_PANED( widget ) ) return; 36 | 37 | // load cursor if needed 38 | if( !_cursorLoaded ) 39 | { 40 | assert( !_cursor ); 41 | 42 | GdkDisplay *display( gtk_widget_get_display( widget ) ); 43 | _cursor = gdk_cursor_new_from_name( display, GTK_IS_VPANED( widget ) ? "col-resize":"row-resize" ); 44 | _cursorLoaded = true; 45 | 46 | } 47 | 48 | // assign to widget 49 | if( _cursor ) 50 | { 51 | 52 | // load handle window 53 | #if GTK_CHECK_VERSION(2, 20, 0) 54 | GdkWindow* window( gtk_paned_get_handle_window( GTK_PANED( widget ) ) ); 55 | #else 56 | GdkWindow* window( GTK_PANED( widget )->handle ); 57 | #endif 58 | 59 | // assign cursor 60 | gdk_window_set_cursor( window, _cursor ); 61 | 62 | } 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/animations/oxygenpaneddata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenpaneddata_h 2 | #define oxygenpaneddata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "oxygensignal.h" 11 | 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | class PanedData 17 | { 18 | 19 | public: 20 | 21 | //! constructor 22 | PanedData( void ): 23 | _cursorLoaded( false ), 24 | _cursor( 0L ) 25 | {} 26 | 27 | //! destructor 28 | virtual ~PanedData( void ) 29 | { 30 | disconnect( 0L ); 31 | if( _cursor ) gdk_cursor_unref( _cursor ); 32 | } 33 | 34 | //! setup connections 35 | void connect( GtkWidget* ); 36 | 37 | //! disconnect 38 | void disconnect( GtkWidget* ); 39 | 40 | protected: 41 | 42 | //! update cursor 43 | virtual void updateCursor( GtkWidget* ); 44 | 45 | //! realization hook 46 | static void realizeEvent( GtkWidget*, gpointer ); 47 | 48 | private: 49 | 50 | //! realization signal 51 | Signal _realizeId; 52 | 53 | //! cursor 54 | bool _cursorLoaded; 55 | GdkCursor* _cursor; 56 | 57 | }; 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/animations/oxygenpanedengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenpanedengine_h 2 | #define oxygenpanedengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygenpaneddata.h" 13 | 14 | #include 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to vertical and horizontal paned 23 | class PanedEngine: public GenericEngine 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | PanedEngine( Animations* widget ): 30 | GenericEngine( widget ) 31 | {} 32 | 33 | //! destructor 34 | virtual ~PanedEngine( void ) 35 | {} 36 | 37 | }; 38 | 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/animations/oxygenscrollbardata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenscrollbardata.h" 9 | #include "../oxygengtkutils.h" 10 | 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //________________________________________________________________________________ 17 | void ScrollBarData::connect( GtkWidget* widget ) 18 | { 19 | _target = widget; 20 | _locked = false; 21 | _valueChangedId.connect( G_OBJECT(widget), "value-changed", G_CALLBACK( valueChanged ), this ); 22 | } 23 | 24 | //________________________________________________________________________________ 25 | void ScrollBarData::disconnect( GtkWidget* ) 26 | { 27 | _target = 0L; 28 | 29 | // reset timeout and locked flag 30 | _timer.stop(); 31 | _locked = false; 32 | 33 | _valueChangedId.disconnect(); 34 | } 35 | 36 | //________________________________________________________________________________ 37 | void ScrollBarData::valueChanged( GtkRange* widget, gpointer pointer ) 38 | { 39 | 40 | ScrollBarData& data( *static_cast( pointer ) ); 41 | if( data._updatesDelayed ) 42 | { 43 | 44 | // schedule delayed timeOut 45 | if( !data._timer.isRunning() ) 46 | { 47 | 48 | data._timer.start( data._delay, (GSourceFunc)delayedUpdate, &data ); 49 | data._locked = false; 50 | 51 | } else data._locked = true; 52 | 53 | 54 | } else if( GtkWidget* parent = Gtk::gtk_parent_scrolled_window( GTK_WIDGET( widget ) ) ) { 55 | 56 | gtk_widget_queue_draw( parent ); 57 | 58 | } 59 | 60 | return; 61 | } 62 | 63 | //________________________________________________________________________________ 64 | gboolean ScrollBarData::delayedUpdate( gpointer pointer ) 65 | { 66 | 67 | ScrollBarData& data( *static_cast(pointer) ); 68 | 69 | if( !data._target ) 70 | { 71 | 72 | // if target is invalid, reset timeout and return 73 | data._locked = false; 74 | return FALSE; 75 | 76 | } else if( data._locked ) { 77 | 78 | // if locked, reset the flag and re-run timer 79 | data._locked = false; 80 | return TRUE; 81 | 82 | } else if( GtkWidget* parent = Gtk::gtk_parent_scrolled_window( GTK_WIDGET( data._target ) ) ) { 83 | 84 | // otherwise, trigger update 85 | gtk_widget_queue_draw( parent ); 86 | return FALSE; 87 | 88 | } 89 | 90 | // if everything fails, unlock and do nothing 91 | data._locked = false; 92 | return FALSE; 93 | 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /src/animations/oxygenscrollbardata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenscrollbardata_h 2 | #define oxygenscrollbardata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "oxygensignal.h" 11 | #include "oxygentimer.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | // track scrollbars 18 | class ScrollBarData 19 | { 20 | 21 | public: 22 | 23 | //! constructor 24 | ScrollBarData( void ): 25 | _target( 0L ), 26 | _updatesDelayed( false ), 27 | _delay( 10 ), 28 | _locked( false ) 29 | {} 30 | 31 | //! destructor 32 | virtual ~ScrollBarData( void ) 33 | { disconnect( _target ); } 34 | 35 | //! setup connections 36 | void connect( GtkWidget* ); 37 | 38 | //! disconnect 39 | void disconnect( GtkWidget* ); 40 | 41 | //! toggle delayed updates 42 | void setUpdatesDelayed( bool value ) 43 | { _updatesDelayed = value; } 44 | 45 | //! set delay 46 | void setDelay( int value ) 47 | { _delay = value; } 48 | 49 | protected: 50 | 51 | static void valueChanged( GtkRange*, gpointer ); 52 | 53 | //! delayed update 54 | static gboolean delayedUpdate( gpointer ); 55 | 56 | private: 57 | 58 | //! pointer to associated widget 59 | GtkWidget* _target; 60 | 61 | //! true if updates are delayed 62 | bool _updatesDelayed; 63 | 64 | //! update delay 65 | int _delay; 66 | 67 | //! timer 68 | Timer _timer; 69 | 70 | //! true if next update must be delayed 71 | bool _locked; 72 | 73 | //! signal 74 | Signal _valueChangedId; 75 | 76 | }; 77 | 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/animations/oxygenscrollbarengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenscrollbarengine_h 2 | #define oxygenscrollbarengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygenscrollbardata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable scrollbares 23 | /*! 24 | ensures that the text entry and the button of editable scrollbares 25 | gets hovered and focus flags at the same time 26 | */ 27 | class ScrollBarEngine: public GenericEngine 28 | { 29 | 30 | public: 31 | 32 | //! constructor 33 | ScrollBarEngine( Animations* widget ): 34 | GenericEngine( widget ) 35 | {} 36 | 37 | //! destructor 38 | virtual ~ScrollBarEngine( void ) 39 | {} 40 | 41 | //! register scrollbar from scrolled window 42 | inline void registerScrolledWindow( GtkWidget* ); 43 | 44 | }; 45 | 46 | //________________________________________________________________ 47 | void ScrollBarEngine::registerScrolledWindow( GtkWidget* widget ) 48 | { 49 | if( !GTK_IS_SCROLLED_WINDOW( widget ) ) return; 50 | GtkScrolledWindow* scrolledWindow( GTK_SCROLLED_WINDOW( widget ) ); 51 | 52 | if( GtkWidget* hScrollBar = gtk_scrolled_window_get_hscrollbar( scrolledWindow ) ) 53 | { registerWidget( hScrollBar ); } 54 | 55 | if( GtkWidget* vScrollBar = gtk_scrolled_window_get_vscrollbar( scrolledWindow ) ) 56 | { registerWidget( vScrollBar ); } 57 | 58 | return; 59 | } 60 | 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/animations/oxygenscrollbarstatedata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenscrollbarstatedata.h" 9 | #include "../config.h" 10 | 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //_____________________________________________ 17 | void ScrollBarStateData::connect( GtkWidget* widget ) 18 | { 19 | 20 | #if OXYGEN_DEBUG 21 | std::cerr << "Oxygen::ScrollBarStateData::connect - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; 22 | #endif 23 | 24 | _target = widget; 25 | _upArrowData._timeLine.connect( (GSourceFunc)delayedUpdate, this ); 26 | _downArrowData._timeLine.connect( (GSourceFunc)delayedUpdate, this ); 27 | } 28 | 29 | //_____________________________________________ 30 | void ScrollBarStateData::disconnect( GtkWidget* widget ) 31 | { 32 | #if OXYGEN_DEBUG 33 | std::cerr << "Oxygen::ScrollBarStateData::disconnect - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; 34 | #endif 35 | 36 | _upArrowData._timeLine.disconnect(); 37 | _upArrowData._rect = Gtk::gdk_rectangle(); 38 | _upArrowData._state = false; 39 | 40 | _downArrowData._timeLine.disconnect(); 41 | _downArrowData._rect = Gtk::gdk_rectangle(); 42 | _downArrowData._state = false; 43 | 44 | _target = 0L; 45 | 46 | } 47 | 48 | //_____________________________________________ 49 | bool ScrollBarStateData::Data::updateState( bool state ) 50 | { 51 | if( state == _state ) return false; 52 | 53 | #if OXYGEN_DEBUG 54 | std::cerr 55 | << "Oxygen::ScrollBarStateData::Data::updateState - " 56 | << " state: " << state 57 | << std::endl; 58 | #endif 59 | 60 | _state = state; 61 | 62 | // change direction 63 | _timeLine.setDirection( state ? TimeLine::Forward:TimeLine::Backward ); 64 | 65 | // restart timeLine if needed 66 | if( _timeLine.isConnected() && !_timeLine.isRunning() ) _timeLine.start(); 67 | 68 | return true; 69 | } 70 | 71 | //_____________________________________________ 72 | gboolean ScrollBarStateData::delayedUpdate( gpointer pointer ) 73 | { 74 | 75 | ScrollBarStateData& data( *static_cast( pointer ) ); 76 | 77 | if( data._target ) 78 | { gtk_widget_queue_draw( data._target ); } 79 | 80 | return FALSE; 81 | 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/animations/oxygenscrolledwindowengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenscrolledwindowengine_h 2 | #define oxygenscrolledwindowengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygenscrolledwindowdata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable scrolled windows 23 | class ScrolledWindowEngine: public GenericEngine 24 | { 25 | 26 | public: 27 | 28 | //! constructor 29 | ScrolledWindowEngine( Animations* widget ): 30 | GenericEngine( widget ) 31 | {} 32 | 33 | //! destructor 34 | virtual ~ScrolledWindowEngine( void ) 35 | {} 36 | 37 | //! true if scrolled window is hovered 38 | bool hovered( GtkWidget* widget ) 39 | { return data().value( widget ).hovered(); } 40 | 41 | //! true if scrolled window is focused 42 | bool focused( GtkWidget* widget ) 43 | { return data().value( widget ).focused(); } 44 | 45 | //! register child 46 | void registerChild( GtkWidget* widget, GtkWidget* child ) 47 | { data().value( widget ).registerChild( child ); } 48 | 49 | 50 | }; 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/animations/oxygensignal.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * this file is part of the oxygen gtk engine 4 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 5 | * 6 | * SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygensignal.h" 10 | #include "../config.h" 11 | 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | 17 | #if OXYGEN_DEBUG 18 | static int counter( 0 ); 19 | #endif 20 | 21 | //____________________________________________________________________ 22 | bool Signal::connect( GObject* object, const std::string& signal, GCallback callback, gpointer data, bool after ) 23 | { 24 | // make sure that signal is not already connected 25 | assert( _object == 0L && _id == 0 ); 26 | 27 | // check object 28 | if( !object ) return false; 29 | 30 | // first try lookup signal 31 | if( !g_signal_lookup( signal.c_str(), G_OBJECT_TYPE(object) ) ) 32 | { 33 | 34 | #if OXYGEN_DEBUG 35 | std::cerr << "Oxygen::Signal::connect - signal " << signal << " not installed on widget " << object << std::endl; 36 | #endif 37 | 38 | return false; 39 | 40 | } 41 | 42 | // store attributes and create connection 43 | _object = object; 44 | if(after) _id = g_signal_connect_after( object, signal.c_str(), callback, data ); 45 | else _id = g_signal_connect( object, signal.c_str(), callback, data ); 46 | 47 | #if OXYGEN_DEBUG 48 | ++counter; 49 | std::cerr << "Oxygen::Signal::connect - _id: " << _id << " counter: " << counter << std::endl; 50 | #endif 51 | 52 | return true; 53 | 54 | } 55 | 56 | //____________________________________________________________________ 57 | void Signal::disconnect( void ) 58 | { 59 | 60 | // disconnect signal 61 | if( _object && _id > 0 ) 62 | { 63 | 64 | #if OXYGEN_DEBUG 65 | --counter; 66 | std::cerr << "Oxygen::Signal::disconnect - _id: " << _id << " counter: " << counter << std::endl; 67 | #endif 68 | 69 | g_signal_handler_disconnect( _object, _id ); 70 | 71 | } 72 | 73 | // reset members 74 | _object = 0L; 75 | _id = 0; 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/animations/oxygensignal.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygensignal_h 2 | #define oxygensignal_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | //! handles gtk signal connections 18 | class Signal 19 | { 20 | public: 21 | 22 | //! constructor 23 | Signal( void ): 24 | _id(0), 25 | _object(0L) 26 | {} 27 | 28 | //! destructor 29 | virtual ~Signal( void ) 30 | {} 31 | 32 | //! true if connected 33 | bool isConnected( void ) const 34 | { return _id > 0 && _object; } 35 | 36 | //! connect 37 | bool connect( GObject*, const std::string&, GCallback, gpointer, bool after=false ); 38 | 39 | //! disconnect 40 | void disconnect( void ); 41 | 42 | private: 43 | 44 | //! signal id 45 | guint _id; 46 | 47 | //! connected object 48 | GObject* _object; 49 | 50 | }; 51 | 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /src/animations/oxygentabwidgetengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentabwidgetengine_h 2 | #define oxygentabwidgetengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygentabwidgetdata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable tabwidgetes 23 | /*! 24 | ensures that the text entry and the button of editable tabwidgetes 25 | gets hovered and focus flags at the same time 26 | */ 27 | class TabWidgetEngine: public GenericEngine 28 | { 29 | 30 | public: 31 | 32 | //! constructor 33 | TabWidgetEngine( Animations* widget ): 34 | GenericEngine( widget ) 35 | {} 36 | 37 | //! destructor 38 | virtual ~TabWidgetEngine( void ) 39 | {} 40 | 41 | //!@name modifiers 42 | //@{ 43 | 44 | //! returns hovered tab, if any 45 | void updateTabRect( GtkWidget* widget, int index, int x, int y, int w, int h ) 46 | { 47 | GdkRectangle local = { x, y, w, h }; 48 | return data().value( widget ).updateTabRect( widget, index, local ); 49 | } 50 | 51 | //! returns hovered tab, if any 52 | void updateTabRect( GtkWidget* widget, int index, const GdkRectangle& r ) 53 | { return data().value( widget ).updateTabRect( widget, index, r ); } 54 | 55 | //! returns hovered tab, if any 56 | void updateHoveredTab( GtkWidget* widget ) 57 | { return data().value( widget ).updateHoveredTab( widget ); } 58 | 59 | //! true when drag is in progress 60 | void setDragInProgress( GtkWidget* widget, bool value ) 61 | { data().value( widget ).setDragInProgress( value ); } 62 | 63 | //! toggle dirty state 64 | void toggleDirty( GtkWidget* widget ) 65 | { data().value( widget ).toggleDirty(); } 66 | 67 | //! true when tabbar is dirty 68 | void setDirty( GtkWidget* widget, bool value ) 69 | { data().value( widget ).setDirty( value ); } 70 | 71 | //@} 72 | 73 | //!@name accessors 74 | //@{ 75 | 76 | //! returns hovered tab, if any 77 | int hoveredTab( GtkWidget* widget ) 78 | { return data().value( widget ).hoveredTab(); } 79 | 80 | //! returns true if provided point is in one tab of the widget 81 | bool isInTab( GtkWidget* widget, int x, int y ) 82 | { return data().value( widget ).isInTab( x, y ); } 83 | 84 | //! true when drag is in progress 85 | bool dragInProgress( GtkWidget* widget ) 86 | { return data().value( widget ).dragInProgress(); } 87 | 88 | //! true when tabbar is dirty 89 | bool isDirty( GtkWidget* widget ) 90 | { return data().value( widget ).isDirty(); } 91 | 92 | //@} 93 | 94 | }; 95 | 96 | } 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /src/animations/oxygentabwidgetstatedata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentabwidgetstatedata_h 2 | #define oxygentabwidgetstatedata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "oxygentimeline.h" 11 | #include "../oxygenanimationdata.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | //! track arrow state changes events, 18 | /*! used to deal with spinbox and Notebook arrows */ 19 | class TabWidgetStateData 20 | { 21 | 22 | public: 23 | 24 | //! constructor 25 | explicit TabWidgetStateData( void ): 26 | _target( 0L ) 27 | {} 28 | 29 | //! destructor 30 | virtual ~TabWidgetStateData( void ) 31 | {} 32 | 33 | //! setup connections 34 | void connect( GtkWidget* ); 35 | 36 | //! disconnect 37 | void disconnect( GtkWidget* ); 38 | 39 | //! update state 40 | bool updateState( int, bool ); 41 | 42 | //! enable state 43 | void setEnabled( bool value ) 44 | { 45 | _current._timeLine.setEnabled( value ); 46 | _previous._timeLine.setEnabled( value ); 47 | } 48 | 49 | //! duration 50 | void setDuration( int value ) 51 | { 52 | _current._timeLine.setDuration( value ); 53 | _previous._timeLine.setDuration( value ); 54 | } 55 | 56 | //! true if tab index is animated 57 | bool isAnimated( int index ) const 58 | { 59 | if( index == _current._index ) return _current._timeLine.isRunning(); 60 | else if( index == _previous._index ) return _previous._timeLine.isRunning(); 61 | else return false; 62 | } 63 | 64 | //! opacity 65 | double opacity( int index ) const 66 | { 67 | if( index == _current._index ) return _current._timeLine.value(); 68 | else if( index == _previous._index ) return _previous._timeLine.value(); 69 | else return OpacityInvalid; 70 | } 71 | 72 | protected: 73 | 74 | //! return dirty rect (for update) 75 | GdkRectangle dirtyRect( void ) const; 76 | 77 | //! delayed update 78 | static gboolean delayedUpdate( gpointer ); 79 | 80 | private: 81 | 82 | //! invalid index 83 | static const int IndexInvalid; 84 | 85 | //! tab data 86 | class Data 87 | { 88 | 89 | public: 90 | 91 | //! constructor 92 | explicit Data( void ): 93 | _index( IndexInvalid ) 94 | {} 95 | 96 | //! timeline 97 | TimeLine _timeLine; 98 | 99 | //! tab index 100 | int _index; 101 | 102 | }; 103 | 104 | //! target 105 | GtkWidget* _target; 106 | 107 | //! current tab data 108 | Data _current; 109 | 110 | //! previous tab data 111 | Data _previous; 112 | 113 | }; 114 | 115 | } 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /src/animations/oxygentimelineserver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygentimelineserver.h" 9 | #include "oxygentimeline.h" 10 | #include "../config.h" 11 | 12 | #include 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | 18 | //! time interval between two updates (use 20 msec for now) 19 | static const int updateInterval = 20; 20 | 21 | //____________________________________________________________________ 22 | TimeLineServer* TimeLineServer::_instance = 0L; 23 | TimeLineServer& TimeLineServer::instance( void ) 24 | { 25 | 26 | if( !_instance ) 27 | { _instance = new TimeLineServer(); } 28 | 29 | return *_instance; 30 | } 31 | 32 | //____________________________________________________________________ 33 | TimeLineServer::TimeLineServer( void ): 34 | _timerId( 0 ) 35 | { 36 | #if OXYGEN_DEBUG 37 | std::cerr << "TimeLineServer::TimeLineServer." << std::endl; 38 | #endif 39 | } 40 | 41 | //____________________________________________________________________ 42 | TimeLineServer::~TimeLineServer( void ) 43 | { 44 | 45 | #if OXYGEN_DEBUG 46 | std::cerr << "TimeLineServer::~TimeLineServer." << std::endl; 47 | #endif 48 | 49 | // clear timer Id and singleton 50 | if( _timerId ) g_source_remove( _timerId ); 51 | _instance = 0L; 52 | 53 | } 54 | 55 | //____________________________________________________________________ 56 | void TimeLineServer::start( void ) 57 | { 58 | 59 | if( !_timerId ) 60 | { _timerId = gdk_threads_add_timeout( updateInterval, (GSourceFunc)update, this ); } 61 | 62 | return; 63 | 64 | } 65 | 66 | //____________________________________________________________________ 67 | void TimeLineServer::stop( void ) 68 | { 69 | 70 | if( _timerId ) 71 | { 72 | g_source_remove( _timerId ); 73 | _timerId = 0; 74 | } 75 | 76 | } 77 | 78 | //____________________________________________________________________ 79 | gboolean TimeLineServer::update( gpointer data ) 80 | { 81 | 82 | bool running( false ); 83 | TimeLineServer& server( *static_cast( data ) ); 84 | 85 | // loop over timelines 86 | for( TimeLineSet::const_iterator iter = server._timeLines.begin(); iter != server._timeLines.end(); ++iter ) 87 | { if( (*iter)->update() ) running = true; } 88 | 89 | // stop timeout 90 | if( !running ) server.stop(); 91 | 92 | // return true if at least one timeline is still running 93 | return gboolean( running ); 94 | 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/animations/oxygentimelineserver.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentimelineserver_h 2 | #define oxygentimelineserver_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include 12 | #include 13 | namespace Oxygen 14 | { 15 | 16 | 17 | //! forward declaration 18 | class TimeLine; 19 | 20 | //! keep track of timelines, triggers update at regular intervals, as long as running 21 | class TimeLineServer 22 | { 23 | 24 | public: 25 | 26 | //! singleton 27 | static TimeLineServer& instance( void ); 28 | 29 | //! destructor 30 | virtual ~TimeLineServer( void ); 31 | 32 | //! register timeline 33 | void registerTimeLine( TimeLine* timeLine ) 34 | { _timeLines.insert( timeLine ); } 35 | 36 | //! unregister timeline 37 | void unregisterTimeLine( TimeLine* timeLine ) 38 | { _timeLines.erase( timeLine ); } 39 | 40 | //! start timeout if needed 41 | void start( void ); 42 | 43 | protected: 44 | 45 | //! stop timeout 46 | void stop( void ); 47 | 48 | //! update registered timers 49 | static gboolean update( gpointer ); 50 | 51 | private: 52 | 53 | //! constructor is private 54 | TimeLineServer( void ); 55 | 56 | //! keeps track of all registered timelines 57 | typedef std::set< TimeLine* > TimeLineSet; 58 | TimeLineSet _timeLines; 59 | 60 | //! timer id 61 | int _timerId; 62 | 63 | //! singleton 64 | static TimeLineServer* _instance; 65 | 66 | 67 | 68 | 69 | }; 70 | 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/animations/oxygentimer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygentimer.h" 9 | #include "../config.h" 10 | 11 | #include 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | 17 | //____________________________________________________ 18 | void Timer::start( int delay, GSourceFunc func, gpointer data ) 19 | { 20 | 21 | // make sure timer is not already running 22 | g_return_if_fail( _timerId == 0 ); 23 | 24 | _func = func; 25 | _data = data; 26 | _timerId = gdk_threads_add_timeout( delay, (GSourceFunc)timeOut, this ); 27 | 28 | } 29 | 30 | //____________________________________________________ 31 | gboolean Timer::timeOut( gpointer data ) 32 | { 33 | 34 | // cast to timer, and execute relevant function 35 | Timer& timer( *static_cast( data ) ); 36 | gboolean result = (timer._func)( timer._data ); 37 | 38 | // make sure timerId is properly reset if the embedded function returns false 39 | if( !result ) timer.reset(); 40 | return result; 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/animations/oxygentimer.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentimer_h 2 | #define oxygentimer_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | 12 | namespace Oxygen 13 | { 14 | //! handles gtk timeouts 15 | /*! make sure the timer is properly reset at destruction */ 16 | class Timer 17 | { 18 | 19 | public: 20 | 21 | //! constructor 22 | Timer( void ): 23 | _timerId( 0 ), 24 | _func( 0L ), 25 | _data( 0L ) 26 | {} 27 | 28 | //! copy constructor 29 | /*! actually does not copy anything, and prints a warning if the other timer is running */ 30 | Timer( const Timer& other ): 31 | _timerId( 0 ), 32 | _func( 0L ), 33 | _data( 0L ) 34 | { 35 | if( other.isRunning() ) 36 | { g_warning( "Oxygen::Timer::Timer - Copy constructor on running timer called." ); } 37 | 38 | } 39 | 40 | //! destructor 41 | virtual ~Timer( void ) 42 | { if( _timerId ) g_source_remove( _timerId ); } 43 | 44 | //! start 45 | void start( int, GSourceFunc, gpointer ); 46 | 47 | //! stop 48 | void stop( void ) 49 | { 50 | if( _timerId ) g_source_remove( _timerId ); 51 | reset(); 52 | } 53 | 54 | //! true if running 55 | bool isRunning( void ) const 56 | { return _timerId != 0; } 57 | 58 | protected: 59 | 60 | //! reset 61 | void reset( void ) 62 | { 63 | _timerId = 0; 64 | _data = 0; 65 | _func = 0; 66 | } 67 | 68 | //! delayed update 69 | static gboolean timeOut( gpointer ); 70 | 71 | private: 72 | 73 | // assignment operator is private 74 | Timer& operator = (const Timer& ) 75 | { return *this; } 76 | 77 | //! timer id 78 | int _timerId; 79 | 80 | //! source function 81 | GSourceFunc _func; 82 | 83 | //! data 84 | gpointer _data; 85 | 86 | }; 87 | } 88 | 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /src/animations/oxygentreeviewengine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 5 | 6 | SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygentreeviewengine.h" 10 | 11 | namespace Oxygen 12 | { 13 | 14 | 15 | //____________________________________________________________________ 16 | TreeViewEngine::TreeViewEngine( Animations* parent ): 17 | GenericEngine( parent ), 18 | _cursorLoaded( false ), 19 | _cursor( 0L ) 20 | {} 21 | 22 | //____________________________________________________________________ 23 | TreeViewEngine::~TreeViewEngine( void ) 24 | { if( _cursor ) gdk_cursor_unref( _cursor ); } 25 | 26 | //____________________________________________________________________ 27 | bool TreeViewEngine::registerWidget( GtkWidget* widget ) 28 | { 29 | if( !GenericEngine::registerWidget( widget ) ) return false; 30 | else if( GTK_IS_TREE_VIEW( widget ) ) 31 | { 32 | 33 | // always disable treelines. 34 | /* tree lines are rendered by the style, in order to be able to draw them with custom color */ 35 | GtkTreeView* treeView( GTK_TREE_VIEW( widget ) ); 36 | gtk_tree_view_set_enable_tree_lines( treeView, false ); 37 | 38 | GtkWidget* parent( gtk_widget_get_parent( widget ) ); 39 | GtkScrolledWindow* scrolledWindow(0); 40 | if( 41 | GTK_IS_SCROLLED_WINDOW( parent ) && 42 | gtk_scrolled_window_get_shadow_type( (scrolledWindow = GTK_SCROLLED_WINDOW( parent ) ) ) != GTK_SHADOW_IN && 43 | !Gtk::gtk_parent_is_shadow_in( parent ) ) 44 | { gtk_scrolled_window_set_shadow_type( scrolledWindow, GTK_SHADOW_IN ); } 45 | 46 | // load cursor if needed 47 | if( !_cursorLoaded ) 48 | { 49 | assert( !_cursor ); 50 | GdkDisplay *display( gtk_widget_get_display( widget ) ); 51 | _cursor = gdk_cursor_new_from_name( display, "row-resize" ); 52 | _cursorLoaded = true; 53 | } 54 | 55 | // pass cursor to data 56 | data().value( widget ).setCursor( _cursor ); 57 | 58 | } 59 | 60 | return true; 61 | 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/animations/oxygentreeviewengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentreeviewengine_h 2 | #define oxygentreeviewengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygentreeviewdata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable comboboxes 23 | /*! 24 | ensures that the text entry and the button of editable comboboxes 25 | gets hovered and focus flags at the same time 26 | */ 27 | class TreeViewEngine: public GenericEngine 28 | { 29 | 30 | public: 31 | 32 | //! constructor 33 | TreeViewEngine( Animations* ); 34 | 35 | //! destructor 36 | virtual ~TreeViewEngine( void ); 37 | 38 | //! register widget 39 | virtual bool registerWidget( GtkWidget* ); 40 | 41 | //! true if widget is hovered 42 | bool hovered( GtkWidget* widget ) 43 | { return data().value( widget ).hovered(); } 44 | 45 | //! true if treeview data is dirty 46 | bool isDirty( GtkWidget* widget ) 47 | { return data().value( widget ).isDirty(); } 48 | 49 | //! update hovered cell for given widget 50 | void updateHoveredCell( GtkWidget* widget ) 51 | { return data().value( widget ).updateHoveredCell(); } 52 | 53 | //! true if given cell is hovered 54 | bool isCellHovered( GtkWidget* widget, const Gtk::CellInfo& info ) 55 | { return data().value( widget ).isCellHovered( info ); } 56 | 57 | bool isCellHovered( GtkWidget* widget, const Gtk::CellInfo& info, bool fullWidth ) 58 | { return data().value( widget ).isCellHovered( info, fullWidth ); } 59 | 60 | private: 61 | 62 | //! cursor 63 | bool _cursorLoaded; 64 | GdkCursor* _cursor; 65 | }; 66 | 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/animations/oxygenwidgetsizedata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 5 | 6 | SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygenwidgetsizedata.h" 10 | #include "../oxygengtkutils.h" 11 | 12 | namespace Oxygen 13 | { 14 | 15 | //___________________________________________________________________________________________________________ 16 | WidgetSizeData::ChangedFlags WidgetSizeData::update() 17 | { 18 | 19 | ChangedFlags changed; 20 | 21 | // get size and check 22 | const GtkAllocation allocation( Gtk::gtk_widget_get_allocation( _target ) ); 23 | const int& width( allocation.width ); 24 | const int& height( allocation.height ); 25 | if( width != _width || height != _height ) 26 | { 27 | _width = width; 28 | _height = height; 29 | changed |= SizeChanged; 30 | } 31 | 32 | const bool alpha( Gtk::gtk_widget_has_rgba( _target ) ); 33 | if( alpha != _alpha ) 34 | { 35 | _alpha = alpha; 36 | changed |= AlphaChanged; 37 | } 38 | 39 | return changed; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/animations/oxygenwidgetsizedata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenwidgetsizedata_h 2 | #define oxygenwidgetsizedata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "../oxygenflags.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | // track main window resize events 18 | class WidgetSizeData 19 | { 20 | 21 | public: 22 | 23 | //! constructor 24 | WidgetSizeData( void ): 25 | _target(NULL), 26 | _width(-1), 27 | _height(-1), 28 | _alpha(false) 29 | {} 30 | 31 | //! destructor 32 | virtual ~WidgetSizeData( void ) 33 | {} 34 | 35 | //! setup connections 36 | void connect( GtkWidget* widget ) 37 | { _target = widget; } 38 | 39 | //! disconnect 40 | void disconnect( GtkWidget* ) 41 | { _target = 0L; } 42 | 43 | //! changed flags 44 | enum ChangedFlag 45 | { 46 | SizeChanged = 1<<0, 47 | AlphaChanged = 1<<1 48 | }; 49 | 50 | OX_DECLARE_FLAGS( ChangedFlags, ChangedFlag ) 51 | 52 | //! update widget size and alpha 53 | /*! return bitmask on what was changed */ 54 | ChangedFlags update(); 55 | 56 | //! width 57 | int width( void ) const 58 | { return _width; } 59 | 60 | //! height 61 | int height( void ) const 62 | { return _height; } 63 | 64 | //! alpha 65 | bool alpha( void ) const 66 | { return _alpha; } 67 | 68 | private: 69 | 70 | //! target widget 71 | GtkWidget* _target; 72 | 73 | //! old width 74 | int _width; 75 | 76 | //! old height 77 | int _height; 78 | 79 | //! whether the widget has alpha channel 80 | bool _alpha; 81 | 82 | }; 83 | 84 | OX_DECLARE_OPERATORS_FOR_FLAGS( WidgetSizeData::ChangedFlags ) 85 | 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /src/animations/oxygenwidgetsizeengine.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenwidgetsizeengine_h 2 | #define oxygenwidgetsizeengine_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | 11 | #include "oxygengenericengine.h" 12 | #include "oxygendatamap.h" 13 | #include "oxygenwidgetsizedata.h" 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | //! forward declaration 20 | class Animations; 21 | 22 | //! stores data associated to editable widgetsizees 23 | /*! 24 | ensures that the text entry and the button of editable widgetsizees 25 | gets hovered and focus flags at the same time 26 | */ 27 | class WidgetSizeEngine: public GenericEngine 28 | { 29 | 30 | public: 31 | 32 | //! constructor 33 | WidgetSizeEngine( Animations* widget ): 34 | GenericEngine( widget ) 35 | {} 36 | 37 | //! destructor 38 | virtual ~WidgetSizeEngine( void ) 39 | {} 40 | 41 | //! update window XShape for given widget 42 | WidgetSizeData::ChangedFlags update( GtkWidget* widget ) 43 | { return data().value( widget ).update(); } 44 | 45 | //! width 46 | int width( GtkWidget* widget ) 47 | { return data().value( widget ).width(); } 48 | 49 | //! height 50 | int height( GtkWidget* widget ) 51 | { return data().value( widget ).height(); } 52 | 53 | //! alpha 54 | bool alpha( GtkWidget* widget ) 55 | { return data().value( widget ).alpha(); } 56 | 57 | }; 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/animations/oxygenwidgetstatedata.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenwidgetstatedata.h" 9 | #include "../config.h" 10 | 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //_____________________________________________ 17 | void WidgetStateData::connect( GtkWidget* widget ) 18 | { 19 | 20 | #if OXYGEN_DEBUG 21 | std::cerr << "Oxygen::WidgetStateData::connect - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; 22 | #endif 23 | 24 | _target = widget; 25 | _timeLine.connect( (GSourceFunc)delayedUpdate, this ); 26 | } 27 | 28 | //_____________________________________________ 29 | void WidgetStateData::disconnect( GtkWidget* widget ) 30 | { 31 | #if OXYGEN_DEBUG 32 | std::cerr << "Oxygen::WidgetStateData::disconnect - " << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" << std::endl; 33 | #endif 34 | 35 | _timeLine.disconnect(); 36 | _target = 0L; 37 | _state = false; 38 | } 39 | 40 | //_____________________________________________ 41 | bool WidgetStateData::updateState( bool state, const GdkRectangle& rect ) 42 | { 43 | 44 | // always update dirty rect 45 | _dirtyRect = rect; 46 | 47 | // check state and update 48 | if( state == _state ) return false; 49 | 50 | #if OXYGEN_DEBUG 51 | std::cerr 52 | << "Oxygen::WidgetStateData::updateState - " 53 | << _target << " (" << ( _target ? std::string( G_OBJECT_TYPE_NAME( _target ) ) : "none" ) << ")" 54 | << " state: " << state 55 | << std::endl; 56 | #endif 57 | 58 | _state = state; 59 | 60 | // change direction 61 | _timeLine.setDirection( state ? TimeLine::Forward:TimeLine::Backward ); 62 | 63 | // restart timeLine if needed 64 | if( _timeLine.isConnected() && !_timeLine.isRunning() ) _timeLine.start(); 65 | 66 | return true; 67 | } 68 | 69 | //_____________________________________________ 70 | gboolean WidgetStateData::delayedUpdate( gpointer pointer ) 71 | { 72 | 73 | WidgetStateData& data( *static_cast( pointer ) ); 74 | 75 | #if OXYGEN_DEBUG 76 | std::cerr 77 | << "Oxygen::WidgetStateData::updateState - " 78 | << data._target << " (" << G_OBJECT_TYPE_NAME( data._target ) << ")" 79 | << " state: " << data._state 80 | << " rect: " << data._dirtyRect 81 | << " opacity: " << data._timeLine.value() 82 | << std::endl; 83 | #endif 84 | 85 | if( data._target && gtk_widget_get_realized(data._target) ) 86 | { Gtk::gtk_widget_queue_draw( data._target, &data._dirtyRect ); } 87 | 88 | return FALSE; 89 | 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/animations/oxygenwidgetstatedata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenwidgetstatedata_h 2 | #define oxygenwidgetstatedata_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "oxygentimeline.h" 11 | #include "../oxygengtkutils.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | //! track widget state changes events 18 | class WidgetStateData 19 | { 20 | 21 | public: 22 | 23 | //! constructor 24 | explicit WidgetStateData( void ): 25 | _target( 0L ), 26 | _dirtyRect( Gtk::gdk_rectangle() ), 27 | _state( false ) 28 | {} 29 | 30 | //! destructor 31 | virtual ~WidgetStateData( void ) 32 | {} 33 | 34 | //! setup connections 35 | void connect( GtkWidget* ); 36 | 37 | //! disconnect 38 | void disconnect( GtkWidget* ); 39 | 40 | //! update state 41 | bool updateState( bool value, const GdkRectangle& ); 42 | 43 | //! update state 44 | bool updateState( bool value ) 45 | { return updateState( value, Gtk::gdk_rectangle() ); } 46 | 47 | //! true if animated 48 | bool isAnimated( void ) const 49 | { return _timeLine.isRunning(); } 50 | 51 | //! opacity 52 | double opacity( void ) const 53 | { return _timeLine.value(); } 54 | 55 | //! enable state 56 | void setEnabled( bool value ) 57 | { _timeLine.setEnabled( value ); } 58 | 59 | //! duration 60 | void setDuration( int value ) 61 | { _timeLine.setDuration( value ); } 62 | 63 | protected: 64 | 65 | //! delayed update 66 | static gboolean delayedUpdate( gpointer ); 67 | 68 | private: 69 | 70 | //! target 71 | GtkWidget* _target; 72 | 73 | //! timeline 74 | TimeLine _timeLine; 75 | 76 | //! dirty rect 77 | GdkRectangle _dirtyRect; 78 | 79 | //! state 80 | bool _state; 81 | 82 | }; 83 | 84 | } 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /src/animations/oxygenwidgetstateengine.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenwidgetstateengine.h" 9 | 10 | namespace Oxygen 11 | { 12 | 13 | //________________________________________________________ 14 | bool WidgetStateEngine::registerWidget( GtkWidget* widget, AnimationModes modes, const StyleOptions& options ) 15 | { 16 | 17 | #if OXYGEN_DEBUG 18 | std::cerr 19 | << "Oxygen::WidgetStateEngine::registerWidget - " 20 | << widget << " (" << G_OBJECT_TYPE_NAME( widget ) << ")" 21 | << " mode: " << modes 22 | << std::endl; 23 | #endif 24 | 25 | bool registered( false ); 26 | if( (modes&AnimationHover) && registerWidget( widget, _hoverData, (options&Hover)&&!(options&Disabled) ) ) registered = true; 27 | if( (modes&AnimationFocus) && registerWidget( widget, _focusData, (options&Focus)&&!(options&Disabled) ) ) registered = true; 28 | 29 | if( registered ) 30 | { BaseEngine::registerWidget( widget ); } 31 | 32 | return registered; 33 | 34 | } 35 | 36 | //________________________________________________________ 37 | bool WidgetStateEngine::registerWidget( GtkWidget* widget, DataMap& dataMap, const bool& state ) const 38 | { 39 | 40 | if( dataMap.contains( widget ) ) return false; 41 | 42 | WidgetStateData& data( dataMap.registerWidget( widget ) ); 43 | data.setEnabled( enabled() ); 44 | data.updateState( state ); 45 | data.setDuration( duration() ); 46 | 47 | /* 48 | blacklist some applications based on name and widget 49 | the widget is effectively registered, but not connected 50 | */ 51 | if( widgetIsBlackListed( widget ) ) return true; 52 | 53 | // connect 54 | if( enabled() ) data.connect( widget ); 55 | 56 | return true; 57 | 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/debug/oxygenwidgetexplorer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | oxygenwidgetexplorer.h 3 | printout widget information on button press, for debugging 4 | ------------------- 5 | 6 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | 8 | Largely inspired from Qtcurve style 9 | SPDX-FileCopyrightText: 2003-2010 Craig Drummond 10 | 11 | SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygenwidgetexplorer.h" 15 | #include "config.h" 16 | 17 | #include 18 | 19 | namespace Oxygen 20 | { 21 | //___________________________________________________________ 22 | WidgetExplorer::WidgetExplorer( void ): 23 | _enabled( false ), 24 | _hooksInitialized( false ) 25 | { 26 | 27 | #if OXYGEN_DEBUG 28 | std::cerr << "Oxygen::WidgetExplorer::WidgetExplorer" << std::endl; 29 | #endif 30 | 31 | } 32 | 33 | 34 | //_________________________________________________ 35 | WidgetExplorer::~WidgetExplorer( void ) 36 | { 37 | 38 | #if OXYGEN_DEBUG 39 | std::cerr << "Oxygen::WidgetExplorer::~WidgetExplorer" << std::endl; 40 | #endif 41 | 42 | _buttonPressHook.disconnect(); 43 | 44 | } 45 | 46 | //_________________________________________________ 47 | void WidgetExplorer::initializeHooks( void ) 48 | { 49 | if( _hooksInitialized ) return; 50 | 51 | _buttonPressHook.connect( "button-press-event", (GSignalEmissionHook)buttonPressHook, this ); 52 | _hooksInitialized = true; 53 | } 54 | 55 | //_________________________________________________ 56 | void WidgetExplorer::setEnabled( bool value ) 57 | { _enabled = value; } 58 | 59 | //_________________________________________________________________ 60 | gboolean WidgetExplorer::buttonPressHook( GSignalInvocationHint*, guint, const GValue* params, gpointer data ) 61 | { 62 | 63 | // cast data to window manager 64 | WidgetExplorer &explorer( *static_cast(data) ); 65 | if( !explorer._enabled ) return TRUE; 66 | 67 | // get widget from params 68 | GtkWidget* widget( GTK_WIDGET( g_value_get_object( params ) ) ); 69 | if( !GTK_IS_WIDGET( widget ) ) return TRUE; 70 | 71 | std::cerr << "Oxygen::WidgetExplorer::buttonPressHook -"; 72 | int row( 0 ); 73 | for( GtkWidget* parent = widget; parent; parent = gtk_widget_get_parent( parent ) ) 74 | { 75 | 76 | if( row ) std::cerr << " parent:"; 77 | std::cerr << " " << parent<< " (" << G_OBJECT_TYPE_NAME( parent ) << ")" << std::endl; 78 | ++row; 79 | } 80 | if( row > 1 ) std::cerr << std::endl; 81 | return TRUE; 82 | 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/debug/oxygenwidgetexplorer.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenwidgetexplorer_h 2 | #define oxygenwidgetexplorer_h 3 | 4 | /* 5 | * oxygenwidgetexplorer.h 6 | * printout widget information on button press, for debugging 7 | * ------------------- 8 | * 9 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 10 | * 11 | * Largely inspired from Qtcurve style 12 | * SPDX-FileCopyrightText: 2003-2010 Craig Drummond 13 | * 14 | * SPDX-License-Identifier: LGPL-2.0-or-later 15 | */ 16 | 17 | #include "oxygenhook.h" 18 | 19 | #include 20 | 21 | // constructor 22 | namespace Oxygen 23 | { 24 | 25 | class WidgetExplorer 26 | { 27 | 28 | public: 29 | 30 | //! constructor 31 | WidgetExplorer( void ); 32 | 33 | //! destructor 34 | virtual ~WidgetExplorer( void ); 35 | 36 | //! initialize hooks 37 | void initializeHooks( void ); 38 | 39 | //! enabled state 40 | void setEnabled( bool value ); 41 | 42 | protected: 43 | 44 | //! style-set hook 45 | static gboolean buttonPressHook( GSignalInvocationHint*, guint, const GValue*, gpointer ); 46 | 47 | private: 48 | 49 | //! enable set 50 | bool _enabled; 51 | 52 | //! true when hooks are initialized 53 | bool _hooksInitialized; 54 | 55 | //! mouse button press event hook 56 | Hook _buttonPressHook; 57 | 58 | }; 59 | 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/oxygen.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygen_h 2 | #define oxygen_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * based on the Null Theme Engine for Gtk+. 8 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 9 | * 10 | * SPDX-License-Identifier: LGPL-2.0-or-later 11 | */ 12 | 13 | #include 14 | 15 | G_BEGIN_DECLS 16 | 17 | #define OXYGEN_LOG_DOMAIN "oxygen-engine" 18 | 19 | G_END_DECLS 20 | 21 | 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/oxygenanimationdata.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenanimationdata_h 2 | #define oxygenanimationdata_h 3 | 4 | /* 5 | * oxygenanimationdata.h 6 | * animation modes 7 | * ------------------- 8 | * 9 | * SPDX-FileCopyrightText: 2012 Hugo Pereira Da Costa 10 | * 11 | * Largely inspired from Qtcurve style 12 | * SPDX-FileCopyrightText: 2003-2010 Craig Drummond 13 | * 14 | * SPDX-License-Identifier: LGPL-2.0-or-later 15 | */ 16 | 17 | #include "oxygenanimationmodes.h" 18 | 19 | namespace Oxygen 20 | { 21 | 22 | //! invalid opacity 23 | static const double OpacityInvalid = -1; 24 | 25 | class AnimationData 26 | { 27 | 28 | public: 29 | 30 | //! constructor 31 | explicit AnimationData( double opacity = OpacityInvalid, AnimationMode mode = AnimationNone ): 32 | _opacity( opacity ), 33 | _mode( mode ) 34 | {} 35 | 36 | double _opacity; 37 | AnimationMode _mode; 38 | 39 | }; 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/oxygenanimationmodes.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenanimationmodes_h 2 | #define oxygenanimationmodes_h 3 | 4 | /* 5 | * oxygenanimationmodes.h 6 | * animation modes 7 | * ------------------- 8 | * 9 | * SPDX-FileCopyrightText: 2012 Hugo Pereira Da Costa 10 | * 11 | * Largely inspired from Qtcurve style 12 | * SPDX-FileCopyrightText: 2003-2010 Craig Drummond 13 | * 14 | * SPDX-License-Identifier: LGPL-2.0-or-later 15 | */ 16 | 17 | #include "oxygenflags.h" 18 | 19 | namespace Oxygen 20 | { 21 | 22 | //! animation type 23 | /*! used for menubars, toolbars and menus */ 24 | enum AnimationType 25 | { 26 | NoAnimation, 27 | Fade, 28 | FollowMouse 29 | }; 30 | 31 | //! animated widget type 32 | /*! 33 | used for engines that keep track of previously(fade-out) and 34 | currently (fade-in) animated objects 35 | */ 36 | enum WidgetType 37 | { 38 | AnimationCurrent, 39 | AnimationPrevious 40 | }; 41 | 42 | //! animation mode 43 | enum AnimationMode 44 | { 45 | AnimationNone = 0, 46 | AnimationHover = 1<<0, 47 | AnimationFocus = 1<<1, 48 | }; 49 | 50 | OX_DECLARE_FLAGS( AnimationModes, AnimationMode ) 51 | OX_DECLARE_OPERATORS_FOR_FLAGS( AnimationModes ) 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/oxygenargbhelper.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenargbhelper_h 2 | #define oxygenargbhelper_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygenhook.h" 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | 18 | //! handles argb support on a per-application, per-widget basis 19 | class ArgbHelper 20 | { 21 | 22 | public: 23 | 24 | //! constructor 25 | explicit ArgbHelper( void ); 26 | 27 | //! destructor 28 | virtual ~ArgbHelper( void ); 29 | 30 | //! initialize hooks 31 | void initializeHooks( void ); 32 | 33 | protected: 34 | 35 | //! argb hook 36 | static gboolean styleSetHook( GSignalInvocationHint*, guint, const GValue*, gpointer ); 37 | 38 | private: 39 | 40 | //! true if hooks are initialized 41 | bool _hooksInitialized; 42 | 43 | //! colormap hook 44 | Hook _styleSetHook; 45 | 46 | }; 47 | 48 | } 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/oxygencairocontext.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygencairocontext.h" 9 | #include 10 | namespace Oxygen 11 | { 12 | 13 | //_________________________________________- 14 | Cairo::Context::Context( GdkWindow* window, GdkRectangle* clipRect): 15 | _cr( 0L ) 16 | { 17 | 18 | if( !GDK_IS_DRAWABLE(window) ) return; 19 | _cr= static_cast( gdk_cairo_create(window) ); 20 | setClipping( clipRect ); 21 | 22 | } 23 | 24 | //_________________________________________- 25 | Cairo::Context::Context( cairo_surface_t* surface, GdkRectangle* clipRect): 26 | _cr( 0L ) 27 | { 28 | 29 | _cr= static_cast( cairo_create(surface) ); 30 | setClipping( clipRect ); 31 | 32 | } 33 | 34 | //_________________________________________________ 35 | void Cairo::Context::free( void ) 36 | { 37 | if( _cr ) { 38 | 39 | cairo_destroy( _cr ); 40 | _cr = 0L; 41 | 42 | } 43 | } 44 | 45 | //_________________________________________________ 46 | void Cairo::Context::setClipping( GdkRectangle* clipRect ) const 47 | { 48 | if( !clipRect ) return; 49 | cairo_rectangle( _cr, clipRect->x, clipRect->y, clipRect->width, clipRect->height ); 50 | cairo_clip( _cr ); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/oxygencairocontext.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygencairocontext_h 2 | #define oxygencairocontext_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | namespace Oxygen 16 | { 17 | namespace Cairo 18 | { 19 | 20 | //! wrapper class around cairo_t structure 21 | class Context 22 | { 23 | public: 24 | 25 | //! constructor 26 | explicit Context( GdkWindow*, GdkRectangle* = 0L ); 27 | 28 | //! constructor 29 | explicit Context( cairo_surface_t*, GdkRectangle* = 0L ); 30 | 31 | //! destructor 32 | virtual ~Context( void ) 33 | { free(); } 34 | 35 | //! free the context 36 | /*! 37 | it should not be necessary to call this method 38 | since it is already handled in destructor 39 | */ 40 | void free( void ); 41 | 42 | //! cast to cairo_t 43 | operator cairo_t* (void) const 44 | { return _cr; } 45 | 46 | //! context accessor 47 | cairo_t* cr( void ) const 48 | { return _cr; } 49 | 50 | //! set clipping 51 | void setClipping( GdkRectangle* ) const; 52 | 53 | private: 54 | 55 | //! empty constructor is private 56 | explicit Context( void ): 57 | _cr( 0L ) 58 | { assert( false ); } 59 | 60 | //! copy constructor is private 61 | Context( const Context& other ): 62 | _cr( 0L ) 63 | { assert( false ); } 64 | 65 | //! equal to operator is private 66 | Context& operator = (const Context& other ) 67 | { 68 | _cr = other._cr; 69 | assert( false ); 70 | return *this; 71 | } 72 | 73 | //! equal to operator is private 74 | Context& operator = (cairo_t* other ) 75 | { 76 | assert( false ); 77 | return *this; 78 | } 79 | 80 | //! cairo contect 81 | cairo_t* _cr; 82 | 83 | }; 84 | 85 | } 86 | } 87 | #endif 88 | -------------------------------------------------------------------------------- /src/oxygencairopattern.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygencairopattern_h 2 | #define oxygencairopattern_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | namespace Cairo 16 | { 17 | 18 | //! wrapper class around cairo_pattern_t structure 19 | class Pattern 20 | { 21 | public: 22 | 23 | //! empty constructor is private 24 | Pattern( void ): 25 | _pattern( 0L ) 26 | {} 27 | 28 | //! constructor 29 | Pattern( cairo_pattern_t* pattern ): 30 | _pattern( pattern ) 31 | {} 32 | 33 | //! destructor 34 | virtual ~Pattern( void ) 35 | { free(); } 36 | 37 | 38 | //! copy constructor is private 39 | Pattern( const Pattern& other ): 40 | _pattern( other._pattern ) 41 | { if( _pattern ) cairo_pattern_reference( _pattern ); } 42 | 43 | //! equal to operator is private 44 | Pattern& operator = (const Pattern& other ) 45 | { 46 | cairo_pattern_t* old( _pattern ); 47 | _pattern = other._pattern; 48 | if( _pattern ) cairo_pattern_reference( _pattern ); 49 | if( old ) cairo_pattern_destroy( old ); 50 | return *this; 51 | } 52 | 53 | //! set pattern 54 | void set( cairo_pattern_t* pattern ) 55 | { 56 | assert( !_pattern ); 57 | _pattern = pattern; 58 | } 59 | 60 | //! free the pattern 61 | /*! 62 | it should not be necessary to call this method 63 | since it is already handled in destructor 64 | */ 65 | void free( void ) 66 | { 67 | if( _pattern ) 68 | { 69 | cairo_pattern_destroy( _pattern ); 70 | _pattern = 0L; 71 | } 72 | } 73 | 74 | //! cast to cairo_pattern_t 75 | operator cairo_pattern_t* (void) const 76 | { return _pattern; } 77 | 78 | private: 79 | 80 | //! pattern 81 | cairo_pattern_t* _pattern; 82 | 83 | 84 | }; 85 | 86 | } 87 | } 88 | #endif 89 | -------------------------------------------------------------------------------- /src/oxygencairosurface.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygencairosurface_h 2 | #define oxygencairosurface_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | namespace Cairo 16 | { 17 | 18 | //! wrapper class around cairo_surface_t structure 19 | class Surface 20 | { 21 | public: 22 | 23 | //! empty constructor is private 24 | Surface( void ): 25 | _surface( 0L ) 26 | {} 27 | 28 | //! constructor 29 | Surface( cairo_surface_t* surface ): 30 | _surface( surface ) 31 | {} 32 | 33 | //! destructor 34 | virtual ~Surface( void ) 35 | { free(); } 36 | 37 | 38 | //! copy constructor is private 39 | Surface( const Surface& other ): 40 | _surface( other._surface ) 41 | { if( _surface ) cairo_surface_reference( _surface ); } 42 | 43 | //! equal to operator is private 44 | Surface& operator = (const Surface& other ) 45 | { 46 | cairo_surface_t* old( _surface ); 47 | _surface = other._surface; 48 | if( _surface ) cairo_surface_reference( _surface ); 49 | if( old ) cairo_surface_destroy( old ); 50 | return *this; 51 | } 52 | 53 | //! returns true if valid 54 | bool isValid( void ) const 55 | { return (bool) _surface; } 56 | 57 | //! set surface 58 | void set( cairo_surface_t* surface ) 59 | { 60 | assert( !_surface ); 61 | _surface = surface; 62 | } 63 | 64 | //! free the surface 65 | /*! 66 | it should not be necessary to call this method 67 | since it is already handled in destructor 68 | */ 69 | void free( void ) 70 | { 71 | if( _surface ) 72 | { 73 | cairo_surface_destroy( _surface ); 74 | _surface = 0L; 75 | } 76 | } 77 | 78 | //! cast to cairo_surface_t 79 | operator cairo_surface_t* (void) const 80 | { return _surface; } 81 | 82 | private: 83 | 84 | //! equal to operator is private 85 | Surface& operator = (cairo_surface_t* other ) 86 | { 87 | assert( false ); 88 | return *this; 89 | } 90 | 91 | //! surface 92 | cairo_surface_t* _surface; 93 | 94 | 95 | }; 96 | 97 | } 98 | } 99 | #endif 100 | -------------------------------------------------------------------------------- /src/oxygencairosurfacecache.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygencairosurfacecache_h 2 | #define oxygencairosurfacecache_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygencache.h" 12 | #include "oxygencairosurface.h" 13 | 14 | #include 15 | 16 | namespace Oxygen 17 | { 18 | 19 | 20 | template< typename T> 21 | class CairoSurfaceCache: public Cache 22 | { 23 | 24 | public: 25 | 26 | //! constructor 27 | CairoSurfaceCache( size_t size = 100 ): 28 | Cache( size ) 29 | {} 30 | 31 | //! destructor 32 | virtual ~CairoSurfaceCache( void ) 33 | {} 34 | 35 | }; 36 | 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/oxygendefines.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygendefines_h 2 | #define oxygendefines_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 8 | * 9 | * SPDX-License-Identifier: LGPL-2.0-or-later 10 | */ 11 | 12 | #define OXYGEN_VERSION_TYPE_NAME "OxygenVersionContainer" 13 | #define OXYGEN_VERSION_QUARK_NAME "VersionString" 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/oxygenfontinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenfontinfo_h 2 | #define oxygenfontinfo_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | class FontInfo 17 | { 18 | 19 | public: 20 | 21 | //! font types 22 | enum FontType 23 | { 24 | Default, 25 | Desktop, 26 | Fixed, 27 | Menu, 28 | Small, 29 | Taskbar, 30 | ToolBar 31 | }; 32 | 33 | typedef std::map Map; 34 | 35 | //! font weight 36 | enum FontWeight 37 | { 38 | Light = 0, 39 | Normal = 38, 40 | DemiBold = 57, 41 | Bold = 69, 42 | Black = 81 43 | }; 44 | 45 | //! empty constructor 46 | FontInfo( void ): 47 | _weight( Normal ), 48 | _italic( false ), 49 | _fixed( false ), 50 | _size( 0 ) 51 | {} 52 | 53 | //! true if font is valid 54 | bool isValid( void ) const 55 | { return _size > 0 && !_family.empty(); } 56 | 57 | //! weight 58 | FontWeight weight( void ) const 59 | { return _weight; } 60 | 61 | //! italic 62 | bool italic( void ) const 63 | { return _italic; } 64 | 65 | //! fixed width 66 | bool fixed( void ) const 67 | { return _fixed; } 68 | 69 | //! size 70 | double size( void ) const 71 | { return _size; } 72 | 73 | //! family 74 | const std::string& family( void ) const 75 | { return _family; } 76 | 77 | //! convert to gtk string 78 | std::string toString( bool addQuotes = true ) const; 79 | 80 | //! utilities 81 | static FontInfo fromKdeOption( std::string ); 82 | 83 | std::string weightString( void ) const; 84 | std::string italicString( void ) const; 85 | 86 | private: 87 | 88 | //! font weight 89 | FontWeight _weight; 90 | 91 | //! true if italic 92 | bool _italic; 93 | 94 | //! true if fixed width 95 | bool _fixed; 96 | 97 | //! font size 98 | double _size; 99 | 100 | //! family 101 | std::string _family; 102 | 103 | }; 104 | 105 | 106 | 107 | } 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /src/oxygengeometry.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygengeometry_h 2 | #define oxygengeometry_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | 12 | namespace Oxygen 13 | { 14 | 15 | class Point 16 | { 17 | public: 18 | 19 | //! constructor 20 | explicit Point( double x, double y): 21 | _x( x ), 22 | _y( y ) 23 | {} 24 | 25 | 26 | //! destructor 27 | virtual ~Point( void ) 28 | {} 29 | 30 | //! accessors 31 | //@{ 32 | double x( void ) const { return _x; } 33 | double y( void ) const { return _y; } 34 | //@} 35 | 36 | //! modifiers 37 | void setX( double x ) { _x = x; } 38 | void setY( double y ) { _y = y; } 39 | 40 | private: 41 | 42 | double _x; 43 | double _y; 44 | 45 | }; 46 | 47 | //! polygons 48 | class Polygon: public std::vector 49 | { 50 | 51 | public: 52 | 53 | Polygon& operator << (const Point& point ) 54 | { 55 | push_back( point ); 56 | return *this; 57 | } 58 | 59 | }; 60 | 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/oxygengtkgap.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygengtkgap_h 2 | #define oxygengtkgap_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include 11 | 12 | namespace Oxygen 13 | { 14 | namespace Gtk 15 | { 16 | 17 | //! stores 'gap' parameters, for convenience 18 | class Gap 19 | { 20 | public: 21 | 22 | //! constructor 23 | explicit Gap( void ): 24 | _x(0), 25 | _w(0), 26 | _h( DefaultGapHeight ), 27 | _position( GTK_POS_TOP ) 28 | {} 29 | 30 | //! constructor 31 | Gap( gint x, gint w, GtkPositionType position ): 32 | _x( x ), 33 | _w( w ), 34 | _h( DefaultGapHeight ), 35 | _position( position ) 36 | {} 37 | 38 | //!@name accessors 39 | //@{ 40 | 41 | const gint& x( void ) const { return _x; } 42 | const gint& width( void ) const { return _w; } 43 | const gint& height( void ) const { return _h; } 44 | const GtkPositionType& position( void ) const { return _position; } 45 | 46 | //@} 47 | 48 | //!@name modifiers 49 | //@{ 50 | 51 | void setX( gint value ) { _x = value; } 52 | void setWidth( gint value) { _w = value; } 53 | void setHeight( gint value ) { _h = value; } 54 | 55 | //@} 56 | 57 | private: 58 | 59 | enum { DefaultGapHeight = 4 }; 60 | 61 | gint _x; 62 | gint _w; 63 | gint _h; 64 | GtkPositionType _position; 65 | 66 | 67 | 68 | }; 69 | 70 | } 71 | 72 | } 73 | #endif 74 | -------------------------------------------------------------------------------- /src/oxygenloghandler.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 5 | 6 | SPDX-License-Identifier: LGPL-2.0-or-later 7 | */ 8 | 9 | #include "oxygenloghandler.h" 10 | 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //_________________________________________________________ 17 | LogHandler::LogHandler( void ) 18 | { 19 | _gtkLogId = g_log_set_handler( "Gtk", G_LOG_LEVEL_WARNING, gtkLogHandler, 0L ); 20 | _glibLogId = g_log_set_handler( "GLib-GObject", G_LOG_LEVEL_CRITICAL, glibLogHandler, 0L ); 21 | } 22 | 23 | //_________________________________________________________ 24 | LogHandler::~LogHandler( void ) 25 | { 26 | 27 | if( _gtkLogId > 0 ) 28 | { 29 | 30 | g_log_remove_handler( "Gtk", _gtkLogId ); 31 | g_log_set_handler( "Gtk", G_LOG_LEVEL_WARNING, g_log_default_handler, 0L ); 32 | 33 | } 34 | 35 | if( _glibLogId > 0 ) 36 | { 37 | 38 | g_log_remove_handler( "GLib-GObject", _glibLogId ); 39 | g_log_set_handler( "GLib-GObject", G_LOG_LEVEL_CRITICAL, g_log_default_handler, 0L ); 40 | 41 | } 42 | 43 | } 44 | 45 | //_________________________________________________________ 46 | void LogHandler::gtkLogHandler( const gchar* domain, GLogLevelFlags flags, const gchar* message, gpointer data ) 47 | { 48 | 49 | if( std::string( message ).find( "attempt to underallocate" ) != std::string::npos ) return; 50 | g_log_default_handler( domain, flags, message, data ); 51 | 52 | } 53 | 54 | //_________________________________________________________ 55 | void LogHandler::glibLogHandler( const gchar* domain, GLogLevelFlags flags, const gchar* message, gpointer data ) 56 | { 57 | 58 | if( std::string( message ).find( "g_object_ref" ) != std::string::npos ) return; 59 | g_log_default_handler( domain, flags, message, data ); 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/oxygenloghandler.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenloghandler_h 2 | #define oxygenloghandler_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | class LogHandler 16 | { 17 | 18 | public: 19 | 20 | //! constructor 21 | LogHandler( void ); 22 | 23 | //! destructor 24 | virtual ~LogHandler( void ); 25 | 26 | protected: 27 | 28 | //!@name error handlers 29 | //@{ 30 | static void gtkLogHandler( const gchar*, GLogLevelFlags, const gchar*, gpointer ); 31 | static void glibLogHandler( const gchar*, GLogLevelFlags, const gchar*, gpointer ); 32 | //@} 33 | 34 | private: 35 | 36 | //! gtk log id 37 | guint _gtkLogId; 38 | 39 | 40 | //! glib log id 41 | guint _glibLogId; 42 | 43 | }; 44 | 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/oxygenmetrics.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenmetrics_h 2 | #define oxygenmetrics_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 8 | * 9 | * SPDX-License-Identifier: LGPL-2.0-or-later 10 | */ 11 | 12 | namespace Oxygen 13 | { 14 | 15 | //! metrics 16 | /*! these are copied from the old KStyle WidgetProperties */ 17 | enum Metrics 18 | { 19 | 20 | /* 21 | checkbox. Do not change, unless 22 | changing the actual cached pixmap size 23 | */ 24 | CheckBox_Size = 21, 25 | 26 | // slider groove height 27 | Slider_GrooveWidth = 7, 28 | 29 | // menu vertical offset 30 | Menu_VerticalOffset = 1, 31 | 32 | /* 33 | entries size margins. Do not change, unless 34 | changing the corresponding oxygen-entry-margins style 35 | in gtkrc 36 | */ 37 | Entry_SideMargin = 3 38 | 39 | }; 40 | } 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/oxygenobjectcounter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2012 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenobjectcounter.h" 9 | #include "oxygenobjectcountermap.h" 10 | 11 | namespace Oxygen 12 | { 13 | //____________________________________________________________ 14 | ObjectCounter::ObjectCounter( const std::string& name ): 15 | count_( 0 ) 16 | { 17 | count_ = ObjectCounterMap::get().counter( name ); 18 | ObjectCounterMap::get().increment( *count_ ); 19 | return; 20 | } 21 | 22 | //____________________________________________________________ 23 | ObjectCounter::ObjectCounter( const ObjectCounter& counter ): 24 | count_( counter.count_ ) 25 | { 26 | ObjectCounterMap::get().increment( *count_ ); 27 | return; 28 | } 29 | 30 | //____________________________________________________________ 31 | ObjectCounter::~ObjectCounter( void ) 32 | { if( count_ ) ObjectCounterMap::get().decrement( *count_ ); } 33 | 34 | //____________________________________________________________ 35 | int ObjectCounter::count( void ) const 36 | { return (count_) ? *count_:0; } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/oxygenobjectcounter.h: -------------------------------------------------------------------------------- 1 | #ifndef Counter_h 2 | #define Counter_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2012 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | 15 | 16 | namespace Oxygen 17 | { 18 | 19 | class ObjectCounter 20 | { 21 | 22 | public: 23 | 24 | //! counter name and counts pair 25 | typedef std::pair Pair; 26 | 27 | //! constructor 28 | ObjectCounter( const std::string& name ); 29 | 30 | //! constructor 31 | ObjectCounter( const ObjectCounter& counter ); 32 | 33 | //! destructor 34 | virtual ~ObjectCounter( void ); 35 | 36 | //! retrieves counter count 37 | int count( void ) const; 38 | 39 | private: 40 | 41 | //! pointer to integer counter 42 | int* count_; 43 | 44 | }; 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/oxygenobjectcountermap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2012 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenobjectcountermap.h" 9 | 10 | namespace Oxygen 11 | { 12 | 13 | //___________________________________________________ 14 | ObjectCounterMap& ObjectCounterMap::get( void ) 15 | { 16 | static ObjectCounterMap singleton; 17 | return singleton; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/oxygenobjectcountermap.h: -------------------------------------------------------------------------------- 1 | #ifndef ObjectCounterMap_h 2 | #define ObjectCounterMap_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2012 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | //! thread-safe Object counter storage map 15 | namespace Oxygen 16 | { 17 | class ObjectCounterMap: public std::map 18 | { 19 | 20 | public: 21 | 22 | //! singleton 23 | static ObjectCounterMap& get( void ); 24 | 25 | //! get counter for a given name 26 | /*! 27 | if the name is found, returns adress of the existing counter 28 | creates new counter otherwise and returns adress 29 | */ 30 | int* counter( const std::string& name ) 31 | { 32 | iterator iter = find( name ); 33 | if( iter == end() ) return &(insert( std::make_pair( name, 0 ) ).first->second); 34 | else return &(iter->second); 35 | } 36 | 37 | //! increment 38 | void increment( int& counter ) 39 | { counter++; } 40 | 41 | //! increment 42 | void decrement( int& counter ) 43 | { counter--; } 44 | 45 | private: 46 | 47 | //! constructor 48 | ObjectCounterMap( void ) 49 | {} 50 | 51 | }; 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/oxygenoption.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | SPDX-FileCopyrightText: 2012 Ruslan Kabatsayev 5 | 6 | inspired notably from kdelibs/kdeui/color/kcolorutils.h 7 | SPDX-FileCopyrightText: 2007 Matthew Woehlke 8 | SPDX-FileCopyrightText: 2007 Thomas Zander 9 | SPDX-FileCopyrightText: 2007 Zack Rusin 10 | 11 | SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | 14 | #include "oxygenoption.h" 15 | 16 | namespace Oxygen 17 | { 18 | //_______________________________________________________________________ 19 | template<> std::string Option::toVariant( std::string defaultValue ) const 20 | { 21 | 22 | std::string out; 23 | std::istringstream stream( _value ); 24 | return ( std::getline(stream, out) ) ? out:defaultValue; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/oxygenoptionmap.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenoptionmap_h 2 | #define oxygenoptionmap_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * inspired notably from kdelibs/kdeui/color/kcolorutils.h 8 | * SPDX-FileCopyrightText: 2007 Matthew Woehlke 9 | * SPDX-FileCopyrightText: 2007 Thomas Zander 10 | * SPDX-FileCopyrightText: 2007 Zack Rusin 11 | * 12 | * SPDX-License-Identifier: LGPL-2.0-or-later 13 | */ 14 | 15 | #include "oxygenoption.h" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace Oxygen 22 | { 23 | // all options from kde globals 24 | class OptionMap: public std::map 25 | { 26 | public: 27 | 28 | //! constructor 29 | OptionMap( void ) 30 | {} 31 | 32 | //! constructor from filename 33 | OptionMap( const std::string& ); 34 | 35 | //! destructor 36 | virtual ~OptionMap( void ) 37 | {} 38 | 39 | //! equal to operator 40 | bool operator == ( const OptionMap& ) const; 41 | 42 | //! differ from operator 43 | bool operator != (const OptionMap& other ) const 44 | { return !(*this == other ); } 45 | 46 | //! merge with other map 47 | /*! when options are duplicated between two maps, the second overwrite the first */ 48 | OptionMap& merge( const OptionMap& ); 49 | 50 | //! true if option is in map 51 | bool hasOption( const std::string& section, const std::string& tag ) const; 52 | 53 | //! find option in map 54 | Option getOption( const std::string& section, const std::string& tag ) const; 55 | 56 | //! find option in map 57 | std::string getValue( const std::string& section, const std::string& tag, const std::string& defaultValue = "" ) const 58 | { 59 | Option option( getOption( section, tag ) ); 60 | return option == tag ? option.value():defaultValue; 61 | } 62 | 63 | //! streamer 64 | friend std::ostream& operator << (std::ostream& out, const OptionMap& options ) 65 | { 66 | for( OptionMap::const_iterator iter = options.begin(); iter != options.end(); ++iter ) 67 | { 68 | out << iter->first << std::endl; 69 | out << iter->second << std::endl; 70 | } 71 | return out; 72 | } 73 | 74 | }; 75 | 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /src/oxygenpathlist.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenpathlist.h" 9 | 10 | #include 11 | 12 | namespace Oxygen 13 | { 14 | 15 | //_________________________________________________________ 16 | void PathList::split( const std::string& path, const std::string& separator ) 17 | { 18 | 19 | clear(); 20 | std::string local( path ); 21 | if( local.empty() ) return; 22 | if( local[local.size()-1] == '\n' ) local = local.substr( 0, local.size()-1 ); 23 | 24 | size_t position( std::string::npos ); 25 | while( ( position = local.find( separator ) ) != std::string::npos ) 26 | { 27 | push_back( local.substr(0, position ) ); 28 | local = local.substr( position + separator.length() ); 29 | } 30 | 31 | if( !local.empty() ) push_back( local ); 32 | return; 33 | 34 | } 35 | 36 | //_________________________________________________________ 37 | std::string PathList::join( const std::string& separator ) const 38 | { 39 | std::ostringstream out; 40 | for( const_iterator iter = begin(); iter != end(); ++iter ) 41 | { 42 | if( iter != begin() ) out << separator; 43 | out << *iter; 44 | } 45 | 46 | return out.str(); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/oxygenpathlist.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenpathlist_h 2 | #define oxygenpathlist_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * inspired notably from kdelibs/kdeui/color/kcolorutils.h 8 | * SPDX-FileCopyrightText: 2007 Matthew Woehlke 9 | * SPDX-FileCopyrightText: 2007 Thomas Zander 10 | * SPDX-FileCopyrightText: 2007 Zack Rusin 11 | * 12 | * SPDX-License-Identifier: LGPL-2.0-or-later 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace Oxygen 21 | { 22 | 23 | typedef std::set PathSet; 24 | 25 | //! utility class to handle path list 26 | //! path list 27 | class PathList: public std::vector 28 | { 29 | 30 | public: 31 | 32 | //! empty constructor 33 | explicit PathList( void ) 34 | {} 35 | 36 | //! splitting constructor 37 | explicit PathList( const std::string& path, const std::string& separator = ":" ) 38 | { split( path, separator ); } 39 | 40 | //! split string using provided separator and store 41 | void split( const std::string&, const std::string& = ":" ); 42 | 43 | //! concatenate using provided separator 44 | std::string join( const std::string& = ":" ) const; 45 | 46 | friend std::ostream& operator << ( std::ostream& out, const PathList& pathList ) 47 | { 48 | for( PathList::const_iterator iter = pathList.begin(); iter != pathList.end(); iter++ ) 49 | { out << " " << *iter << std::endl; } 50 | 51 | return out; 52 | } 53 | 54 | }; 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/oxygenpropertynames.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | oxygenpropertynames.cpp 3 | hard-coded property names to disable some of oxygen features 4 | ------------------- 5 | 6 | SPDX-FileCopyrightText: 2012 Hugo Pereira Da Costa 7 | 8 | Largely inspired from Qtcurve style 9 | SPDX-FileCopyrightText: 2003-2010 Craig Drummond 10 | 11 | SPDX-License-Identifier: LGPL-2.0-or-later 12 | */ 13 | #include "oxygenpropertynames.h" 14 | 15 | namespace Oxygen 16 | { 17 | 18 | const char* const PropertyNames::noAnimations = "_kde_no_animations"; 19 | const char* const PropertyNames::noWindowGrab = "_kde_no_window_grab"; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/oxygenpropertynames.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenpropertynames_h 2 | #define oxygenpropertynames_h 3 | 4 | /* 5 | * oxygenpropertynames.h 6 | * hard-coded property names to disable some of oxygen features 7 | * ------------------- 8 | * 9 | * SPDX-FileCopyrightText: 2012 Hugo Pereira Da Costa 10 | * 11 | * Largely inspired from Qtcurve style 12 | * SPDX-FileCopyrightText: 2003-2010 Craig Drummond 13 | * 14 | * SPDX-License-Identifier: LGPL-2.0-or-later 15 | */ 16 | 17 | namespace Oxygen 18 | { 19 | 20 | struct PropertyNames 21 | { 22 | 23 | static const char* const noAnimations; 24 | static const char* const noWindowGrab; 25 | 26 | }; 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/oxygenrcstyle.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenrcstyle_h 2 | #define oxygenrcstyle_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * based on the Null Theme Engine for Gtk+. 8 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 9 | * 10 | * SPDX-License-Identifier: LGPL-2.0-or-later 11 | */ 12 | 13 | #include 14 | 15 | // Oxygen RcStyle struct 16 | struct OxygenRcStyle 17 | { GtkRcStyle parent; }; 18 | 19 | // oxygen RcStyleClass struct 20 | struct OxygenRcStyleClass 21 | { GtkRcStyleClass parent; }; 22 | 23 | namespace Oxygen 24 | { 25 | class RCStyle 26 | { 27 | 28 | public: 29 | 30 | //! type registration 31 | static void registerType( GTypeModule* ); 32 | 33 | //! registered type 34 | static GType type( void ); 35 | 36 | protected: 37 | 38 | //! class initialization method 39 | static void classInit( OxygenRcStyleClass* ); 40 | 41 | //! style creation 42 | static GtkStyle* createStyle( GtkRcStyle* ); 43 | 44 | //! parse RC options 45 | static guint parse( GtkRcStyle*, GtkSettings*, GScanner* ); 46 | 47 | //! merge styles 48 | static void merge( GtkRcStyle*, GtkRcStyle* ); 49 | 50 | private: 51 | 52 | //! parent class 53 | static GtkRcStyleClass* _parentClass; 54 | 55 | //! registered type indo 56 | static GTypeInfo _typeInfo; 57 | 58 | //! registered type 59 | static GType _type; 60 | 61 | }; 62 | } 63 | 64 | 65 | #endif /* OXYGEN_RC_STYLE_H */ 66 | -------------------------------------------------------------------------------- /src/oxygenshadowconfiguration.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenshadowconfiguration_h 2 | #define oxygenshadowconfiguration_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * inspired notably from kdelibs/kdeui/color/kcolorutils.h 8 | * SPDX-FileCopyrightText: 2007 Matthew Woehlke 9 | * SPDX-FileCopyrightText: 2007 Thomas Zander 10 | * SPDX-FileCopyrightText: 2007 Zack Rusin 11 | * 12 | * SPDX-License-Identifier: LGPL-2.0-or-later 13 | */ 14 | 15 | #include "oxygenoptionmap.h" 16 | #include "oxygenpalette.h" 17 | 18 | namespace Oxygen 19 | { 20 | //! shadow configuration (not including colors since they reside in _palette) 21 | class ShadowConfiguration 22 | { 23 | public: 24 | 25 | //! default constructor 26 | ShadowConfiguration( Palette::Group ); 27 | 28 | //! destructor 29 | virtual ~ShadowConfiguration() 30 | {} 31 | 32 | Palette::Group colorGroup() const 33 | { return _colorGroup; } 34 | 35 | //! enability 36 | bool isEnabled() const 37 | { return _enabled; } 38 | 39 | //! shadow size 40 | double shadowSize() const 41 | { return _shadowSize; } 42 | 43 | //! horizontal offset 44 | double horizontalOffset() const 45 | { return _horizontalOffset; } 46 | 47 | //! vertical offset 48 | double verticalOffset() const 49 | { return _verticalOffset; } 50 | 51 | //! inner color 52 | ColorUtils::Rgba innerColor() const 53 | { return _innerColor; } 54 | 55 | //! outer color 56 | ColorUtils::Rgba outerColor() const 57 | { return _outerColor; } 58 | 59 | //! initialize from options 60 | void initialize( const OptionMap& ); 61 | 62 | private: 63 | 64 | //! color group 65 | Palette::Group _colorGroup; 66 | 67 | //! enability 68 | bool _enabled; 69 | 70 | //! shadow size 71 | double _shadowSize; 72 | 73 | //! horizontal offset 74 | double _horizontalOffset; 75 | 76 | //! vertical offset 77 | double _verticalOffset; 78 | 79 | //! inner color 80 | ColorUtils::Rgba _innerColor; 81 | 82 | //! outer color 83 | ColorUtils::Rgba _outerColor; 84 | 85 | //! use outer color 86 | bool _useOuterColor; 87 | 88 | //! streamer (for debugging) 89 | friend std::ostream& operator << (std::ostream&, const ShadowConfiguration& ); 90 | 91 | }; 92 | } 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /src/oxygenstyleoptions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygenstyleoptions.h" 9 | 10 | #include 11 | #include 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //______________________________________________________________ 17 | std::ostream& operator << (std::ostream& out, const StyleOptions& options ) 18 | { 19 | std::vector flags; 20 | if( options & Blend ) flags.push_back( "Blend" ); 21 | if( options & Sunken ) flags.push_back( "Sunken" ); 22 | if( options & Flat ) flags.push_back( "Flat" ); 23 | if( options & Focus ) flags.push_back( "Focus" ); 24 | if( options & Hover ) flags.push_back( "Hover" ); 25 | if( options & NoFill ) flags.push_back( "NoFill" ); 26 | if( options & Vertical ) flags.push_back( "Vertical" ); 27 | if( options & Alpha ) flags.push_back( "Alpha" ); 28 | if( options & Round ) flags.push_back( "Round" ); 29 | if( options & Contrast ) flags.push_back( "Contrast" ); 30 | if( options & Selected ) flags.push_back( "Selected" ); 31 | if( options & Disabled ) flags.push_back( "Disabled" ); 32 | if( options & Menu ) flags.push_back( "Menu" ); 33 | 34 | if( flags.empty() ) out << "None"; 35 | else { 36 | 37 | for( std::vector::const_iterator iter = flags.begin(); iter != flags.end(); ++iter ) 38 | { 39 | if( iter == flags.begin() ) out << *iter; 40 | else out << "|" << *iter; 41 | } 42 | 43 | } 44 | 45 | return out; 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/oxygenstyleoptions.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenstyleoptions_h 2 | #define oxygenstyleoptions_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygenflags.h" 12 | #include "oxygengtkutils.h" 13 | #include "oxygenpalette.h" 14 | 15 | #include 16 | #include 17 | 18 | namespace Oxygen 19 | { 20 | 21 | //! internal option flags to pass arguments around 22 | enum StyleOption 23 | { 24 | Blend = 1<<0, 25 | Sunken = 1<<1, 26 | Active = 1<<2, 27 | Flat = 1<<3, 28 | Focus = 1<<4, 29 | Hover = 1<<5, 30 | NoFill = 1<<6, 31 | Vertical = 1<<7, 32 | Alpha = 1<<8, 33 | Round = 1<<9, 34 | Contrast = 1<<10, 35 | Selected = 1<<11, 36 | Disabled = 1<<12, 37 | Menu = 1<<13, 38 | DrawAlphaChannel = 1<<14 39 | }; 40 | 41 | class StyleOptions: public Flags 42 | { 43 | 44 | public: 45 | 46 | //! constructor 47 | StyleOptions( void ) 48 | {} 49 | 50 | //! constructor 51 | StyleOptions(StyleOption f): 52 | Flags( f ) 53 | {} 54 | 55 | //! constructor 56 | StyleOptions( Flags f): 57 | Flags( f ) 58 | {} 59 | 60 | //! constructor from widget 61 | StyleOptions( GtkWidget* widget, GtkStateType state, GtkShadowType shadow = GTK_SHADOW_NONE ) 62 | { 63 | if( state == GTK_STATE_INSENSITIVE ) (*this) |= Disabled; 64 | else if( state == GTK_STATE_PRELIGHT ) (*this) |= Hover; 65 | else if( state == GTK_STATE_SELECTED ) (*this) |= Selected; 66 | else if( state == GTK_STATE_ACTIVE ) (*this) |= Active; 67 | 68 | if( shadow == GTK_SHADOW_IN ) (*this) |= Sunken; 69 | if( widget && gtk_widget_has_focus(widget) ) (*this)|=Focus; 70 | } 71 | 72 | //! destructor 73 | virtual ~StyleOptions( void ) 74 | {} 75 | 76 | 77 | //! color set 78 | /*! it is used to pass custom colors to painting routines */ 79 | Palette::ColorSet _customColors; 80 | 81 | //! streamer 82 | friend std::ostream& operator << (std::ostream& out, const StyleOptions& options ); 83 | 84 | }; 85 | 86 | } 87 | 88 | OX_DECLARE_OPERATORS_FOR_FLAGS( Oxygen::StyleOptions ) 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /src/oxygenstylewrapper.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenstylewrapper_h 2 | #define oxygenstylewrapper_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * based on the Null Theme Engine for Gtk+. 8 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 9 | * 10 | * SPDX-License-Identifier: LGPL-2.0-or-later 11 | */ 12 | 13 | #include 14 | #include "oxygenxulinfo.h" 15 | 16 | // oxygen style struct 17 | struct OxygenStyle 18 | { GtkStyle parent; }; 19 | 20 | // oxygen style class struct 21 | struct OxygenStyleClass 22 | { GtkStyleClass parent; }; 23 | 24 | namespace Oxygen 25 | { 26 | class StyleWrapper 27 | { 28 | 29 | public: 30 | 31 | //! type registration 32 | static void registerType( GTypeModule* ); 33 | 34 | //! version type registration 35 | /*! 36 | it is used to let an external program retrieve 37 | the oxygen-gtk version that it uses, if any 38 | */ 39 | static void registerVersionType( void ); 40 | 41 | //! registered type 42 | static GType type( void ); 43 | 44 | //! parent class 45 | inline static GtkStyleClass* parentClass( void ) 46 | { return _parentClass; } 47 | 48 | //! xul info 49 | inline static XulInfo& xulInfo( void ) 50 | { return _xulInfo; } 51 | 52 | protected: 53 | 54 | //! instance initialization 55 | static void instanceInit( OxygenStyle* ); 56 | 57 | //! class initialization 58 | static void classInit( OxygenStyleClass* ); 59 | 60 | private: 61 | 62 | //! parent class 63 | static GtkStyleClass* _parentClass; 64 | 65 | //! registered type indo 66 | static GTypeInfo _typeInfo; 67 | 68 | //! registered type 69 | static GType _type; 70 | 71 | //! xul info, needed to properly render focus in checkboxes and radio buttons 72 | static XulInfo _xulInfo; 73 | 74 | }; 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/oxygentaboptions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | this file is part of the oxygen gtk engine 3 | SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 4 | 5 | SPDX-License-Identifier: LGPL-2.0-or-later 6 | */ 7 | 8 | #include "oxygentaboptions.h" 9 | #include "oxygenstyleoptions.h" 10 | #include "oxygengtkutils.h" 11 | 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | 17 | //______________________________________________________________________ 18 | TabOptions::TabOptions( GtkWidget* widget, GtkStateType state, GtkPositionType position, int x, int y, int w, int h ) 19 | { 20 | 21 | // strange: all tabs but the current one are painted with the active flag 22 | if( state != GTK_STATE_ACTIVE ) (*this) |= CurrentTab; 23 | 24 | // get allocated size 25 | const GtkAllocation allocation( Gtk::gtk_widget_get_allocation( widget ) ); 26 | int borderWidth( GTK_IS_CONTAINER( widget ) ? gtk_container_get_border_width( GTK_CONTAINER( widget ) ):0 ); 27 | 28 | 29 | // this simple comparison seems robust enough and much simpler 30 | // than any other implementation 31 | switch( position ) 32 | { 33 | default: 34 | case GTK_POS_TOP: 35 | case GTK_POS_BOTTOM: 36 | if( x == allocation.x + borderWidth ) (*this) |= FirstTabAligned; 37 | if( x+w == allocation.x + allocation.width - borderWidth ) (*this) |= LastTabAligned; 38 | break; 39 | 40 | case GTK_POS_LEFT: 41 | case GTK_POS_RIGHT: 42 | if( y == allocation.y + borderWidth ) (*this) |= FirstTabAligned; 43 | if( y+h == allocation.y + allocation.height - borderWidth ) (*this) |= LastTabAligned; 44 | break; 45 | } 46 | 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/oxygentaboptions.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentaboptions_h 2 | #define oxygentaboptions_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | #include "oxygenflags.h" 11 | 12 | #include 13 | 14 | namespace Oxygen 15 | { 16 | 17 | //! internal option flags to pass arguments around 18 | enum TabOption 19 | { 20 | FirstTab = 1<<0, 21 | LastTab = 1<<1, 22 | CurrentTab = 1<<2, 23 | 24 | /* 25 | these flags are used to decide how to connect 26 | tabs to the main frame 27 | */ 28 | FirstTabAligned = 1<<3, 29 | LastTabAligned = 1<<4, 30 | LeftOfSelected = 1<<5, 31 | RightOfSelected = 1<<6, 32 | 33 | //! true if tab is being dragged 34 | Dragged = 1<<7, 35 | 36 | //! true if tabs are drawn for Xul application 37 | Xul = 1<<8 38 | 39 | }; 40 | 41 | class TabOptions: public Flags 42 | { 43 | 44 | public: 45 | 46 | //! constructor 47 | TabOptions( void ) 48 | {} 49 | 50 | //! constructor 51 | TabOptions( GtkWidget*, GtkStateType, GtkPositionType, int x, int y, int w, int h ); 52 | 53 | //! destructor 54 | virtual ~TabOptions( void ) 55 | {} 56 | 57 | }; 58 | 59 | } 60 | 61 | OX_DECLARE_OPERATORS_FOR_FLAGS( Oxygen::TabOptions ) 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/oxygentheme.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentheme_h 2 | #define oxygentheme_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 8 | * 9 | * based on the Null Theme Engine for Gtk+. 10 | * SPDX-FileCopyrightText: 2008 Robert Staudinger 11 | * 12 | * SPDX-License-Identifier: LGPL-2.0-or-later 13 | */ 14 | 15 | #include 16 | 17 | //!@name external 'c' methods, expected by gtk 18 | //@{ 19 | extern "C" G_MODULE_EXPORT void theme_init( GTypeModule* ); 20 | extern "C" G_MODULE_EXPORT void theme_exit( void ); 21 | extern "C" G_MODULE_EXPORT GtkRcStyle* theme_create_rc_style( void ); 22 | extern "C" G_MODULE_EXPORT const gchar* g_module_check_init( GModule* ); 23 | 24 | // exports for WM theming 25 | extern "C" G_MODULE_EXPORT void drawWindowDecoration(cairo_t*, unsigned long,gint,gint,gint,gint,const gchar**,gint,gint); 26 | extern "C" G_MODULE_EXPORT void drawWindecoButton(cairo_t*, unsigned long,unsigned long, unsigned long,gint,gint,gint,gint); 27 | extern "C" G_MODULE_EXPORT void drawWindecoShapeMask(cairo_t*, unsigned long,gint,gint,gint,gint); 28 | extern "C" G_MODULE_EXPORT void drawWindowShadow(cairo_t*, unsigned long options, gint x, gint y, gint w, gint h); 29 | extern "C" G_MODULE_EXPORT gint getWindecoMetric(unsigned long); 30 | extern "C" G_MODULE_EXPORT gint getWindecoButtonSize(unsigned long); 31 | extern "C" G_MODULE_EXPORT unsigned long getWindecoABIVersion(void); 32 | //@} 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/oxygentilesetcache.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygentilesetcache_h 2 | #define oxygentilesetcache_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygencache.h" 12 | 13 | namespace Oxygen 14 | { 15 | 16 | // forward declaration 17 | class TileSet; 18 | 19 | template< typename T> 20 | class TileSetCache: public Cache 21 | { 22 | 23 | public: 24 | 25 | //! constructor 26 | TileSetCache( size_t size = 100 ): 27 | Cache( size ) 28 | {} 29 | 30 | //! destructor 31 | virtual ~TileSetCache( void ) 32 | {} 33 | 34 | }; 35 | 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/oxygenwindecobutton.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenwindecobutton_h 2 | #define oxygenwindecobutton_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygencairocontext.h" 12 | namespace Oxygen 13 | { 14 | 15 | // forward declarations 16 | class QtSettings; 17 | class StyleHelper; 18 | 19 | namespace WinDeco 20 | { 21 | 22 | //! button status 23 | enum ButtonStatus { 24 | Normal, 25 | Disabled, // this shouldn't be specified by WMs unless button is really insensitive 26 | Hovered, 27 | Pressed, 28 | ButtonStatusCount 29 | }; 30 | 31 | //! buttons 32 | enum ButtonType { 33 | ButtonHelp=0, 34 | ButtonMax, 35 | ButtonMin, 36 | ButtonClose, 37 | ButtonMenu, 38 | ButtonStick, 39 | ButtonAbove, 40 | ButtonBelow, 41 | ButtonShade, 42 | ButtonUnmax, 43 | ButtonUnstick, 44 | ButtonUnshade, 45 | ButtonUndoAbove, 46 | ButtonUndoBelow, 47 | ButtonTypeCount 48 | }; 49 | 50 | //! window decoration button 51 | class Button 52 | { 53 | 54 | public: 55 | 56 | //! constructor 57 | Button( const QtSettings& settings, StyleHelper& helper, const ButtonType& type ): 58 | _settings( settings ), 59 | _helper( helper ), 60 | _type( type ), 61 | _state( Normal ) 62 | {} 63 | 64 | //! destructor 65 | virtual ~Button( void ) 66 | {} 67 | 68 | //! state 69 | void setState( const ButtonStatus& state ) 70 | { _state = state; } 71 | 72 | //! render 73 | void render( cairo_t*, gint x, gint y, gint w, gint h ) const; 74 | 75 | protected: 76 | 77 | //! icon 78 | void drawIcon( cairo_t*, gint w, gint h ) const; 79 | 80 | //! settings 81 | const QtSettings& settings( void ) const 82 | { return _settings; } 83 | 84 | //! helper 85 | StyleHelper& helper( void ) const 86 | { return _helper; } 87 | 88 | private: 89 | 90 | //! settings 91 | const QtSettings& _settings; 92 | 93 | //! helper 94 | StyleHelper& _helper; 95 | 96 | //! type 97 | ButtonType _type; 98 | 99 | //! status 100 | ButtonStatus _state; 101 | 102 | }; 103 | 104 | 105 | } 106 | 107 | } 108 | 109 | #endif 110 | -------------------------------------------------------------------------------- /src/oxygenwindecooptions.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenwindecooptions_h 2 | #define oxygenwindecooptions_h 3 | 4 | /* 5 | * this file is part of the oxygen gtk engine 6 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 7 | * 8 | * SPDX-License-Identifier: LGPL-2.0-or-later 9 | */ 10 | 11 | #include "oxygenwindecobutton.h" 12 | 13 | namespace Oxygen 14 | { 15 | 16 | //! window decoration options 17 | namespace WinDeco 18 | { 19 | 20 | //! window decoration options 21 | enum Option 22 | { 23 | Maximized=1<<0, 24 | Shaded=1<<2, 25 | Resizable=1<<3, 26 | Active=1<<4, 27 | Alpha=1<<5, 28 | DrawAlphaChannel=1<<6, 29 | }; 30 | 31 | //! window decoration options 32 | typedef unsigned long Options; 33 | 34 | enum Metric 35 | { 36 | BorderLeft=0, 37 | BorderRight, 38 | BorderBottom, 39 | // BorderTop includes title and resize handle heights 40 | BorderTop, 41 | ButtonSpacing, 42 | ButtonMarginTop, 43 | ButtonMarginBottom, 44 | ShadowLeft, 45 | ShadowTop, 46 | ShadowRight, 47 | ShadowBottom, 48 | MetricsCount 49 | }; 50 | 51 | //! get frame dimensions 52 | int getMetric(Metric wm); 53 | 54 | //! get button size 55 | // all buttons are of the same size in oxygen, so no argument in internal function 56 | int getButtonSize(); 57 | 58 | } 59 | 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/oxygenxulapplicationnames.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenxulapplicationname_h 2 | #define oxygenxulapplicationname_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * inspired notably from kdelibs/kdeui/color/kcolorutils.h 8 | * SPDX-FileCopyrightText: 2007 Matthew Woehlke 9 | * SPDX-FileCopyrightText: 2007 Thomas Zander 10 | * SPDX-FileCopyrightText: 2007 Zack Rusin 11 | * 12 | * SPDX-License-Identifier: LGPL-2.0-or-later 13 | */ 14 | 15 | #include 16 | 17 | namespace Oxygen 18 | { 19 | 20 | // tag all mozilla-like applications (XUL) 21 | static const std::string XulAppNames[] = 22 | { 23 | "aurora", 24 | "earlybird", 25 | "icecat", 26 | "icedove", 27 | "iceweasel", 28 | "instantbird", 29 | "firefox", 30 | "fossamail", 31 | "komodo", 32 | "newmoon", 33 | "palemoon", 34 | "seamonkey", 35 | "thunderbird", 36 | "xulrunner", 37 | "zotero", 38 | "" 39 | }; 40 | 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/oxygenxulinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef oxygenxulinfo_h 2 | #define oxygenxulinfo_h 3 | /* 4 | * this file is part of the oxygen gtk engine 5 | * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa 6 | * 7 | * SPDX-License-Identifier: LGPL-2.0-or-later 8 | */ 9 | 10 | #include "oxygengtkutils.h" 11 | 12 | namespace Oxygen 13 | { 14 | //! checkbox info, needed for proper focus rendering in Xul applications 15 | class XulInfo 16 | { 17 | 18 | public: 19 | 20 | enum Type 21 | { 22 | Invalid, 23 | CheckBox, 24 | RadioButton 25 | }; 26 | 27 | //! constructor 28 | XulInfo( void ): 29 | _type( Invalid ), 30 | _rect( Gtk::gdk_rectangle() ) 31 | {} 32 | 33 | //! destructor 34 | virtual ~XulInfo( void ) 35 | {} 36 | 37 | //!@name accessors 38 | //@{ 39 | 40 | Type type( void ) const 41 | { return _type; } 42 | 43 | //! rectangle 44 | const GdkRectangle& rect( void ) const 45 | { return _rect; } 46 | 47 | //! validity 48 | bool isValid( void ) 49 | { return _type != Invalid && Gtk::gdk_rectangle_is_valid( &_rect ); } 50 | 51 | //@} 52 | 53 | //!@name modifiers 54 | //@{ 55 | 56 | //! type 57 | void setType( Type value ) 58 | { _type = value; } 59 | 60 | //! rectangle 61 | void setRect( const GdkRectangle& value ) 62 | { _rect = value; } 63 | 64 | //! clear 65 | void clear( void ) 66 | { 67 | _type = Invalid; 68 | _rect = Gtk::gdk_rectangle(); 69 | } 70 | 71 | //@} 72 | 73 | private: 74 | 75 | //! type 76 | Type _type; 77 | 78 | //! rectangle 79 | GdkRectangle _rect; 80 | 81 | }; 82 | 83 | } 84 | #endif 85 | --------------------------------------------------------------------------------