3
// Copyright (C) 2008 GNOME-Do
5
// This program is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program. If not, see <http://www.gnu.org/licenses/>.
20
using System.Collections.Generic;
29
using Do.Platform.Windows;
32
namespace Do.Interface.AnimationBase
36
public abstract class AbstractAnimatedInterface : Gtk.Window, IDoWindow, IConfigurable
38
BezelDrawingArea bezel_drawing_area;
39
BezelGlassResults bezel_glass_results;
40
BezelGlassWindow bezel_glass_window;
41
IDoController controller;
44
public Pane CurrentPane {
45
get { return bezel_drawing_area.Focus; }
46
set { bezel_drawing_area.Focus = value; }
49
public new string Name {
50
get { return RenderTheme.Name; }
53
protected abstract IRenderTheme RenderTheme { get; }
55
public AbstractAnimatedInterface () : base (Gtk.WindowType.Toplevel)
59
public void Initialize (IDoController controller)
61
this.controller = controller;
71
TypeHint = WindowTypeHint.Splashscreen;
74
bezel_drawing_area = new BezelDrawingArea (controller, RenderTheme, false);
75
bezel_drawing_area.Show ();
77
bezel_glass_results = bezel_drawing_area.Results;
78
bezel_glass_window = new BezelGlassWindow (bezel_glass_results);
80
Add (bezel_drawing_area);
82
pw = new PositionWindow (this, bezel_glass_window);
85
protected override void OnDestroyed ()
88
bezel_drawing_area.Destroy ();
89
bezel_drawing_area = null;
90
bezel_glass_results.Destroy ();
91
bezel_glass_results = null;
94
protected override bool OnButtonPressEvent (EventButton evnt)
96
Gdk.Point global_point = new Gdk.Point ((int) evnt.XRoot, (int) evnt.YRoot);
97
Gdk.Point local_point = new Gdk.Point ((int) evnt.X, (int) evnt.Y);
99
switch (bezel_drawing_area.GetPointLocation (local_point)) {
100
case PointLocation.Close:
101
case PointLocation.Outside:
102
controller.ButtonPressOffWindow ();
104
case PointLocation.Preferences:
105
Services.Windowing.ShowMainMenu (global_point.X, global_point.Y);
106
// Have to re-grab the pane from the menu.
107
Interface.Windowing.PresentWindow (this);
111
return base.OnButtonPressEvent (evnt);
114
protected override bool OnKeyPressEvent (EventKey evnt)
116
KeyPressEvent (evnt);
118
return base.OnKeyPressEvent (evnt);
121
protected override bool OnExposeEvent (EventExpose evnt)
124
Cairo.Context cr = Gdk.CairoHelper.Create (GdkWindow);
125
cr.Operator = Cairo.Operator.Source;
127
(cr as IDisposable).Dispose ();
129
return base.OnExposeEvent (evnt);
133
protected virtual void SetColormap ()
135
Gdk.Colormap colormap;
137
colormap = Screen.RgbaColormap;
138
if (colormap == null) {
139
colormap = Screen.RgbColormap;
140
Console.Error.WriteLine ("No alpha support.");
147
public void Summon ()
150
GetSize (out width, out height);
152
pw.UpdatePosition (0, Pane.First, new Gdk.Rectangle (((int) (bezel_drawing_area.WindowWidth - bezel_glass_results.WidthRequest) / 2), -10, 0, 0));
154
bezel_glass_window.Show ();
155
Interface.Windowing.PresentWindow (this);
158
public void Vanish ()
160
Interface.Windowing.UnpresentWindow (this);
162
bezel_glass_window.Hide ();
167
bezel_drawing_area.Clear ();
168
bezel_glass_results.Clear ();
173
bezel_drawing_area.ThirdPaneVisible = true;
176
public void Shrink ()
178
bezel_drawing_area.ThirdPaneVisible = false;
181
public void GrowResults ()
183
bezel_glass_results.SlideIn ();
186
public void ShrinkResults ()
188
bezel_glass_results.SlideOut ();
191
public void SetPaneContext (Pane pane, IUIContext context)
193
// This prevents the odd situation of nothing drawing in the third pane. Ultimately what has
194
// happened is the universe has "nulled" the pane by fluke. We detect this and replace the
195
// query with an invisible space.
197
if (pane == Pane.Third && context.Selection == null && string.IsNullOrEmpty (context.Query) && !context.Results.Any ()) {
200
query = context.Query;
202
bezel_drawing_area.BezelSetPaneObject (pane, context.Selection);
203
bezel_drawing_area.BezelSetQuery (pane, query);
204
bezel_drawing_area.BezelSetTextMode (pane, context.LargeTextDisplay);
205
bezel_drawing_area.BezelSetEntryMode (pane, context.LargeTextModeType == TextModeType.Explicit);
207
if (CurrentPane == pane) {
208
bezel_glass_results.Context = context;
212
public void ClearPane (Pane pane)
214
bezel_drawing_area.BezelSetPaneObject (pane, null);
215
bezel_drawing_area.BezelSetQuery (pane, "");
216
bezel_drawing_area.BezelSetEntryMode (pane, false);
218
if (pane == CurrentPane) {
219
bezel_glass_results.Clear ();
223
#region IConfigurable implementation
224
public Bin GetConfiguration ()
226
return new AnimationBaseConfigurationWidget (bezel_drawing_area);
229
public string Description {
231
return "Animated Interface Configuration";
235
public new string Icon {
237
return "preferences";
243
public bool ResultsCanHide { get { return true; } }
245
public new event DoEventKeyDelegate KeyPressEvent;