2
// ScrollAdjustmentBackend.cs
5
// Lluis Sanchez <lluis@xamarin.com>
7
// Copyright (c) 2012 Xamarin Inc
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:
16
// The above copyright notice and this permission notice shall be included in
17
// all copies or substantial portions of the Software.
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
30
namespace Xwt.GtkBackend
32
public class ScrollAdjustmentBackend: IScrollAdjustmentBackend
34
Gtk.Adjustment adjustment;
35
IScrollAdjustmentEventSink eventSink;
37
public Gtk.Adjustment Adjustment {
38
get { return adjustment; }
41
public ScrollAdjustmentBackend ()
45
public ScrollAdjustmentBackend (Gtk.Adjustment adjustment)
47
this.adjustment = adjustment;
50
#region IBackend implementation
51
public void InitializeBackend (object frontend)
53
if (adjustment == null)
54
adjustment = new Gtk.Adjustment (0, 0, 0, 0, 0, 0);
57
public void Initialize (IScrollAdjustmentEventSink eventSink)
59
this.eventSink = eventSink;
62
public void EnableEvent (object eventId)
64
ScrollAdjustmentEvent ev = (ScrollAdjustmentEvent) eventId;
65
if (ev == ScrollAdjustmentEvent.ValueChanged) {
66
adjustment.ValueChanged += HandleValueChanged;
70
public void DisableEvent (object eventId)
72
ScrollAdjustmentEvent ev = (ScrollAdjustmentEvent) eventId;
73
if (ev == ScrollAdjustmentEvent.ValueChanged) {
74
adjustment.ValueChanged -= HandleValueChanged;
78
void HandleValueChanged (object sender, EventArgs e)
80
Toolkit.Invoke (delegate {
81
eventSink.OnValueChanged ();
86
#region IScrollAdjustmentBackend implementation
89
return adjustment.Value;
92
adjustment.Value = value;
96
public double LowerValue {
98
return adjustment.Lower;
101
adjustment.Lower = value;
105
public double UpperValue {
107
return adjustment.Upper;
110
adjustment.Upper = value;
114
public double PageIncrement {
116
return adjustment.PageIncrement;
119
adjustment.PageIncrement = value;
123
public double StepIncrement {
125
return adjustment.StepIncrement;
128
adjustment.StepIncrement = value;
132
public double PageSize {
134
return adjustment.PageSize;
137
adjustment.PageSize = value;