1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#ifndef oxygenarrowstateengine_h
#define oxygenarrowstateengine_h
/*
* this file is part of the oxygen gtk engine
* Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or(at your option ) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#include "../oxygenanimationdata.h"
#include "../oxygenstyleoptions.h"
#include "oxygenanimationengine.h"
#include "oxygengenericengine.h"
#include "oxygendatamap.h"
#include "oxygenarrowstatedata.h"
#include <gtk/gtk.h>
namespace Oxygen
{
//! forward declaration
class Animations;
//! stores data associated to editable arrowstatees
/*!
ensures that the text entry and the button of editable arrowstatees
gets hovered and focus flags at the same time
*/
class ArrowStateEngine: public GenericEngine<ArrowStateData>, public AnimationEngine
{
public:
//! constructor
ArrowStateEngine( Animations* widget ):
GenericEngine<ArrowStateData>( widget )
{}
//! destructor
virtual ~ArrowStateEngine( void )
{}
//! enable state
virtual bool setEnabled( bool value )
{
if( !BaseEngine::setEnabled( value ) ) return false;
for( DataMap<ArrowStateData>::Map::iterator iter = data().map().begin(); iter != data().map().end(); iter++ )
{
iter->second.setEnabled( value );
if( enabled() && !widgetIsBlackListed( iter->first ) ) iter->second.connect( iter->first );
else iter->second.disconnect( iter->first );
}
return true;
}
//! transition duration
virtual bool setDuration( int value )
{
if( !AnimationEngine::setDuration( value ) ) return false;
for( DataMap<ArrowStateData>::Map::iterator iter = data().map().begin(); iter != data().map().end(); iter++ )
{ iter->second.setDuration( value ); }
return true;
}
//! retrieve animation data matching a given widget for provided options
/*! note: for convenience, this method also calls ::registerWidget and ::updateState */
virtual AnimationData get( GtkWidget* widget, GtkArrowType type, const StyleOptions& options )
{
// check widget
if( !( enabled() && widget ) ) return AnimationData();
// register
registerWidget( widget );
ArrowStateData& data( this->data().value( widget ) );
data.updateState( type, (options&Hover) && !(options&Disabled) );
return data.isAnimated( type ) ? AnimationData( data.opacity( type ), AnimationHover ):AnimationData();
}
//@}
protected:
//!@name protected modifiers
//@{
//! register widget [overloaded]
virtual bool registerWidget( GtkWidget* widget )
{
const bool registered( GenericEngine<ArrowStateData>::registerWidget( widget ) );
if( registered ) {
data().value( widget ).setEnabled( enabled() );
data().value( widget ).setDuration( duration() );
}
return registered;
}
//@}
};
}
#endif
|