~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/xwt/Xwt.Gtk/Xwt.GtkBackend/ScrollAdjustmentBackend.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// ScrollAdjustmentBackend.cs
 
3
//  
 
4
// Author:
 
5
//       Lluis Sanchez <lluis@xamarin.com>
 
6
// 
 
7
// Copyright (c) 2012 Xamarin Inc
 
8
// 
 
9
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
10
// of this software and associated documentation files (the "Software"), to deal
 
11
// in the Software without restriction, including without limitation the rights
 
12
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
13
// copies of the Software, and to permit persons to whom the Software is
 
14
// furnished to do so, subject to the following conditions:
 
15
// 
 
16
// The above copyright notice and this permission notice shall be included in
 
17
// all copies or substantial portions of the Software.
 
18
// 
 
19
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
24
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
25
// THE SOFTWARE.
 
26
using System;
 
27
using Xwt.Backends;
 
28
using Xwt.Engine;
 
29
 
 
30
namespace Xwt.GtkBackend
 
31
{
 
32
        public class ScrollAdjustmentBackend: IScrollAdjustmentBackend
 
33
        {
 
34
                Gtk.Adjustment adjustment;
 
35
                IScrollAdjustmentEventSink eventSink;
 
36
                
 
37
                public Gtk.Adjustment Adjustment {
 
38
                        get { return adjustment; }
 
39
                }
 
40
                
 
41
                public ScrollAdjustmentBackend ()
 
42
                {
 
43
                }
 
44
                
 
45
                public ScrollAdjustmentBackend (Gtk.Adjustment adjustment)
 
46
                {
 
47
                        this.adjustment = adjustment;
 
48
                }
 
49
                
 
50
                #region IBackend implementation
 
51
                public void InitializeBackend (object frontend)
 
52
                {
 
53
                        if (adjustment == null)
 
54
                                adjustment = new Gtk.Adjustment (0, 0, 0, 0, 0, 0);
 
55
                }
 
56
 
 
57
                public void Initialize (IScrollAdjustmentEventSink eventSink)
 
58
                {
 
59
                        this.eventSink = eventSink;
 
60
                }
 
61
 
 
62
                public void EnableEvent (object eventId)
 
63
                {
 
64
                        ScrollAdjustmentEvent ev = (ScrollAdjustmentEvent) eventId;
 
65
                        if (ev == ScrollAdjustmentEvent.ValueChanged) {
 
66
                                adjustment.ValueChanged += HandleValueChanged;
 
67
                        }
 
68
                }
 
69
 
 
70
                public void DisableEvent (object eventId)
 
71
                {
 
72
                        ScrollAdjustmentEvent ev = (ScrollAdjustmentEvent) eventId;
 
73
                        if (ev == ScrollAdjustmentEvent.ValueChanged) {
 
74
                                adjustment.ValueChanged -= HandleValueChanged;
 
75
                        }
 
76
                }
 
77
 
 
78
                void HandleValueChanged (object sender, EventArgs e)
 
79
                {
 
80
                        Toolkit.Invoke (delegate {
 
81
                                eventSink.OnValueChanged ();
 
82
                        });
 
83
                }
 
84
                #endregion
 
85
 
 
86
                #region IScrollAdjustmentBackend implementation
 
87
                public double Value {
 
88
                        get {
 
89
                                return adjustment.Value;
 
90
                        }
 
91
                        set {
 
92
                                adjustment.Value = value;
 
93
                        }
 
94
                }
 
95
 
 
96
                public double LowerValue {
 
97
                        get {
 
98
                                return adjustment.Lower;
 
99
                        }
 
100
                        set {
 
101
                                adjustment.Lower = value;
 
102
                        }
 
103
                }
 
104
 
 
105
                public double UpperValue {
 
106
                        get {
 
107
                                return adjustment.Upper;
 
108
                        }
 
109
                        set {
 
110
                                adjustment.Upper = value;
 
111
                        }
 
112
                }
 
113
 
 
114
                public double PageIncrement {
 
115
                        get {
 
116
                                return adjustment.PageIncrement;
 
117
                        }
 
118
                        set {
 
119
                                adjustment.PageIncrement = value;
 
120
                        }
 
121
                }
 
122
 
 
123
                public double StepIncrement {
 
124
                        get {
 
125
                                return adjustment.StepIncrement;
 
126
                        }
 
127
                        set {
 
128
                                adjustment.StepIncrement = value;
 
129
                        }
 
130
                }
 
131
 
 
132
                public double PageSize {
 
133
                        get {
 
134
                                return adjustment.PageSize;
 
135
                        }
 
136
                        set {
 
137
                                adjustment.PageSize = value;
 
138
                        }
 
139
                }
 
140
                #endregion
 
141
        }
 
142
}
 
143