~ubuntu-branches/ubuntu/lucid/gbrainy/lucid

« back to all changes in this revision

Viewing changes to src/Core/Toolkit/Widget.cs

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-03-08 11:11:11 UTC
  • mfrom: (13.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100308111111-pxz008t81zfu1w8q
Tags: 1.40-1ubuntu1
* Update from Debian unstable, remaining changes: (LP: #534113)
* debian/patches/01_lpi.patch:
* debian/patches/99_autoreconf.patch:
* debian/control:
  - Add Launchpad integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Jordi Mas i Hernàndez <jmas@softcatala.org>
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License as
 
6
 * published by the Free Software Foundation; either version 2 of the
 
7
 * License, or (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public
 
15
 * License along with this program; if not, write to the
 
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
 * Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
using System;
 
21
using System.ComponentModel;
 
22
 
 
23
using gbrainy.Core.Main;
 
24
using gbrainy.Core.Libraries;
 
25
 
 
26
namespace gbrainy.Core.Toolkit
 
27
{
 
28
        /*
 
29
                This is a set of classes that help to model a minimal widget library over
 
30
                Cairo that handles RTL and mouse events
 
31
        */
 
32
 
 
33
        public abstract class Widget : IDrawable, IDrawRequest, IMouseEvent
 
34
        {
 
35
                public delegate void WidgetDrawEventHandler (object sender, DrawEventArgs e);
 
36
 
 
37
                public event EventHandler DrawRequest;
 
38
                public event EventHandler <SeletectedEventArgs> SelectedEvent;
 
39
                ISynchronizeInvoke synchronize;
 
40
                bool sensitive;
 
41
 
 
42
                public Widget (double width, double height)
 
43
                {
 
44
                        if (width < 0 || width > 1)
 
45
                                throw new ArgumentOutOfRangeException ("width");
 
46
 
 
47
                        if (height < 0 || height > 1)
 
48
                                throw new ArgumentOutOfRangeException ("height");
 
49
 
 
50
                        Width = width;
 
51
                        Height = height;
 
52
                }
 
53
 
 
54
                public virtual bool Sensitive { 
 
55
                        set {
 
56
                                sensitive = value;
 
57
                                OnDrawRequest ();
 
58
                        }
 
59
                        get {return sensitive; }
 
60
                }
 
61
 
 
62
                public object Data { get; set; }
 
63
                public object DataEx { get; set; }
 
64
 
 
65
                public double X { get; set; }
 
66
                public double Y { get; set; }
 
67
                public double Width { get; set; }
 
68
                public double Height { get; set; }
 
69
 
 
70
                public ISynchronizeInvoke SynchronizingObject { 
 
71
                        set { synchronize = value; }
 
72
                        get { return synchronize; }
 
73
                }
 
74
 
 
75
                protected void OnDrawRequest ()
 
76
                {
 
77
                        if (DrawRequest == null)
 
78
                                return;
 
79
 
 
80
                        DrawRequest (this, EventArgs.Empty);
 
81
                }
 
82
 
 
83
                protected void OnSelected (SeletectedEventArgs e)
 
84
                {
 
85
                        if (SelectedEvent == null)
 
86
                                return;
 
87
 
 
88
                        SelectedEvent (this, e);
 
89
                }
 
90
 
 
91
                public virtual void Draw (CairoContextEx gr, int area_width, int area_height, bool rtl) 
 
92
                {
 
93
                        throw new InvalidOperationException ();
 
94
                }
 
95
 
 
96
                public virtual void MouseEvent (object obj, MouseEventArgs args)
 
97
                {
 
98
                        throw new InvalidOperationException ();
 
99
                }
 
100
        }
 
101
}