1
#ifndef oxygencomboboxentryengine_h
2
#define oxygencomboboxentryengine_h
4
* this file is part of the oxygen gtk engine
5
* Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or(at your option ) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
24
#include "oxygengenericengine.h"
25
#include "oxygendatamap.h"
26
#include "oxygencomboboxentrydata.h"
32
//! forward declaration
35
//! stores data associated to editable comboboxentryes
37
ensures that the text entry and the button of editable comboboxentryes
38
gets hovered and focus flags at the same time
40
class ComboBoxEntryEngine: public GenericEngine<ComboBoxEntryData>
46
ComboBoxEntryEngine( Animations* widget ):
47
GenericEngine<ComboBoxEntryData>( widget )
51
virtual ~ComboBoxEntryEngine( void )
57
//! assign button to data matching widget
58
void setButton( GtkWidget* widget, GtkWidget* value )
59
{ data().value( widget ).setButton( value ); }
61
//! assign entry to data matching widget
62
void setEntry( GtkWidget* widget, GtkWidget* value )
63
{ data().value( widget ).setEntry( value ); }
66
void setButtonFocus( GtkWidget* widget, bool value )
67
{ data().value( widget ).setButtonFocus( value ); }
70
void setButtonHovered( GtkWidget* widget, bool value )
71
{ data().value( widget ).setButtonHovered( value ); }
74
void setEntryFocus( GtkWidget* widget, bool value )
75
{ data().value( widget ).setEntryFocus( value ); }
82
//! returns pressed combobox if any
83
inline GtkWidget* find( GtkWidget* );
85
//! true if either button or entry has focus
86
bool hasFocus( GtkWidget* widget )
87
{ return data().value( widget ).hasFocus(); }
89
//! true if comboBox is hovered
90
bool hovered( GtkWidget* widget )
91
{ return data().value( widget ).hovered(); }
97
//_________________________________________________
98
GtkWidget* ComboBoxEntryEngine::find( GtkWidget* value )
100
GtkWidget* topLevel( gtk_widget_get_toplevel( value ) );
101
DataMap<ComboBoxEntryData>::Map& dataMap( data().map() );
102
for( DataMap<ComboBoxEntryData>::Map::iterator iter = dataMap.begin(); iter != dataMap.end(); iter++ )
104
if( iter->second.pressed() )
106
iter->second.setList( topLevel );
111
for( DataMap<ComboBoxEntryData>::Map::iterator iter = dataMap.begin(); iter != dataMap.end(); iter++ )
112
{ if( iter->second.list() == topLevel ) return iter->first; }