File indexing completed on 2024-05-12 05:34:33
0001 #ifndef oxygencomboboxentryengine_h 0002 #define oxygencomboboxentryengine_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 "oxygengenericengine.h" 0012 #include "oxygendatamap.h" 0013 #include "oxygencomboboxentrydata.h" 0014 0015 #include <gtk/gtk.h> 0016 0017 namespace Oxygen 0018 { 0019 //! forward declaration 0020 class Animations; 0021 0022 //! stores data associated to editable comboboxentryes 0023 /*! 0024 ensures that the text entry and the button of editable comboboxentryes 0025 gets hovered and focus flags at the same time 0026 */ 0027 class ComboBoxEntryEngine: public GenericEngine<ComboBoxEntryData> 0028 { 0029 0030 public: 0031 0032 //! constructor 0033 ComboBoxEntryEngine( Animations* widget ): 0034 GenericEngine<ComboBoxEntryData>( widget ) 0035 {} 0036 0037 //! destructor 0038 virtual ~ComboBoxEntryEngine( void ) 0039 {} 0040 0041 //!@name modifiers 0042 //@{ 0043 0044 //! assign button to data matching widget 0045 void setButton( GtkWidget* widget, GtkWidget* value ) 0046 { data().value( widget ).setButton( value ); } 0047 0048 //! assign entry to data matching widget 0049 void setEntry( GtkWidget* widget, GtkWidget* value ) 0050 { data().value( widget ).setEntry( value ); } 0051 0052 //! button focus 0053 void setButtonFocus( GtkWidget* widget, bool value ) 0054 { data().value( widget ).setButtonFocus( value ); } 0055 0056 //! button focus 0057 void setButtonHovered( GtkWidget* widget, bool value ) 0058 { data().value( widget ).setButtonHovered( value ); } 0059 0060 //! entry focus 0061 void setEntryFocus( GtkWidget* widget, bool value ) 0062 { data().value( widget ).setEntryFocus( value ); } 0063 0064 //@} 0065 0066 //!@name accessors 0067 //@{ 0068 0069 //! returns pressed combobox if any 0070 inline GtkWidget* find( GtkWidget* ); 0071 0072 //! true if either button or entry has focus 0073 bool hasFocus( GtkWidget* widget ) 0074 { return data().value( widget ).hasFocus(); } 0075 0076 //! true if comboBox is hovered 0077 bool hovered( GtkWidget* widget ) 0078 { return data().value( widget ).hovered(); } 0079 0080 //@} 0081 0082 }; 0083 0084 //_________________________________________________ 0085 GtkWidget* ComboBoxEntryEngine::find( GtkWidget* value ) 0086 { 0087 GtkWidget* topLevel( gtk_widget_get_toplevel( value ) ); 0088 DataMap<ComboBoxEntryData>::Map& dataMap( data().map() ); 0089 for( DataMap<ComboBoxEntryData>::Map::iterator iter = dataMap.begin(); iter != dataMap.end(); iter++ ) 0090 { 0091 if( iter->second.pressed() ) 0092 { 0093 iter->second.setList( topLevel ); 0094 return iter->first; 0095 } 0096 } 0097 0098 for( DataMap<ComboBoxEntryData>::Map::iterator iter = dataMap.begin(); iter != dataMap.end(); iter++ ) 0099 { if( iter->second.list() == topLevel ) return iter->first; } 0100 0101 return 0L; 0102 0103 } 0104 0105 } 0106 0107 #endif