File indexing completed on 2024-05-12 17:05:47
0001 #ifndef oxygencomboengine_h 0002 #define oxygencomboengine_h 0003 /* 0004 * this file is part of the oxygen gtk engine 0005 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0006 * 0007 * SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 0011 #include "oxygenbaseengine.h" 0012 0013 #include <gtk/gtk.h> 0014 #include <set> 0015 0016 namespace Oxygen 0017 { 0018 //! forward declaration 0019 class Animations; 0020 0021 //! stores data associated to editable comboes 0022 /*! 0023 ensures that the text and the button of editable comboes 0024 gets hovered and focus flags at the same time 0025 */ 0026 class ComboEngine: public BaseEngine 0027 { 0028 0029 public: 0030 0031 //! constructor 0032 ComboEngine( Animations* widget ): 0033 BaseEngine( widget ) 0034 {} 0035 0036 //! destructor 0037 virtual ~ComboEngine( void ) 0038 {} 0039 0040 //! register widget 0041 virtual bool registerWidget( GtkWidget* widget ) 0042 { 0043 if( contains( widget ) ) return false; 0044 _data.insert( widget ); 0045 return true; 0046 } 0047 0048 //! unregister widget 0049 virtual void unregisterWidget( GtkWidget* widget ) 0050 { _data.erase( widget ); } 0051 0052 //! true if widget is included 0053 virtual bool contains( GtkWidget* widget ) 0054 { return _data.find( widget ) != _data.end(); } 0055 0056 //@} 0057 0058 //!@name accessors 0059 //@{ 0060 0061 //! find combo matching widget 0062 /*! the widget can be any of those in a visible list */ 0063 inline GtkWidget* find( GtkWidget* ) const; 0064 0065 //@} 0066 0067 private: 0068 0069 //! store registered widgets 0070 std::set<GtkWidget*> _data; 0071 0072 }; 0073 0074 //_________________________________________________ 0075 GtkWidget* ComboEngine::find( GtkWidget* value ) const 0076 { 0077 GtkWidget* topLevel( gtk_widget_get_toplevel( value ) ); 0078 for( std::set<GtkWidget*>::const_iterator iter = _data.begin(); iter != _data.end(); iter++ ) 0079 { 0080 0081 if( GTK_IS_COMBO( *iter ) && topLevel == GTK_COMBO( *iter )->popwin ) 0082 { return *iter; } 0083 0084 } 0085 0086 return 0L; 0087 0088 } 0089 0090 } 0091 0092 #endif