~ubuntu-branches/ubuntu/precise/gnome-do/precise-proposed

« back to all changes in this revision

Viewing changes to Do.Addins/src/Do.UI/DarkFrame/GlassWindow.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2008-04-14 21:36:12 UTC
  • mto: (0.1.8 sid)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080414213612-h0dfxdodm6vpcc1h
Tags: upstream-0.4.2.0
ImportĀ upstreamĀ versionĀ 0.4.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        
35
35
        public class GlassWindow : Gtk.Window, IDoWindow
36
36
        {
37
 
                protected GlassFrame frame;
38
 
                protected SymbolDisplayLabel label;
39
 
                protected ResultsWindow resultsWindow;
40
 
                protected HBox resultsHBox;
41
 
                protected IDoController controller;
42
 
                protected GlassIconBox[] iconbox;
 
37
                GlassFrame frame;
 
38
                SymbolDisplayLabel label;
 
39
                ResultsWindow resultsWindow;
 
40
                PositionWindow positionWindow;
 
41
                HBox resultsHBox;
 
42
                IDoController controller;
 
43
                GlassIconBox[] iconbox;
43
44
                
44
45
                const int IconBoxIconSize = 64;
45
46
                const uint IconBoxPadding = 2;
46
47
                const int IconBoxRadius = 5;
47
 
                
48
 
                protected int frameoffset;
49
 
                protected const int MainRadius = 13;
50
 
                
51
 
                protected Pane currentPane;
52
 
                protected bool summonable;
 
48
                const int NumberResultsDisplayed = 6;
 
49
                
 
50
                int frameoffset;
 
51
                const int MainRadius = 13;
 
52
                
 
53
                Pane currentPane;
 
54
                bool summonable;
53
55
                
54
56
                //-------------------Events-----------------------
55
57
                public new event DoEventKeyDelegate KeyPressEvent;
80
82
                        }
81
83
                }
82
84
                
 
85
                
 
86
                public PositionWindow PositionWindow {
 
87
                        get {
 
88
                                return positionWindow ?? 
 
89
                                        positionWindow = new PositionWindow(this, resultsWindow);
 
90
                        }
 
91
                }
 
92
                //---------------------ctor-----------------------
 
93
                
83
94
                /// <summary>
84
95
                /// ctor
85
96
                /// </summary>
86
97
                /// <param name="controller">
87
98
                /// A <see cref="IDoController"/>
88
99
                /// </param>
89
 
                public GlassWindow (IDoController controller) : base (Gtk.WindowType.Toplevel)
 
100
                public GlassWindow (IDoController controller) 
 
101
                        : base (Gtk.WindowType.Toplevel)
90
102
                {
91
103
                        this.controller = controller;
92
104
                        
94
106
                }
95
107
                
96
108
                /// <summary>
97
 
                /// Provides primary building and packing of the IDoWindow.  Custom widgets are packed in
 
109
                /// Provides primary building and packing of the IDoWindow.  
 
110
                /// Custom widgets are packed in
98
111
                /// here and most settings are selected.
99
112
                /// </summary>
100
113
                protected void Build ()
113
126
                        } catch { }
114
127
                        SetColormap ();
115
128
 
116
 
                        resultsWindow = new ResultsWindow (new Color(15, 15, 15));
 
129
                        resultsWindow = new ResultsWindow (new Color(15, 15, 15), 
 
130
                                                           NumberResultsDisplayed);
117
131
                        resultsWindow.SelectionChanged += OnResultsWindowSelectionChanged;
118
132
 
119
133
                        currentPane = Pane.First;
125
139
                        frame.FillColor = new Color(45, 45, 45);
126
140
                        frame.FrameColor = new Color(255, 255, 255);
127
141
                        frame.FrameAlpha = 1;
128
 
                        frame.DrawArrow = true;
129
142
                        frame.Radius = Screen.IsComposited ? MainRadius : 0;
130
143
                        Add (frame);
131
144
                        frame.Show ();
223
236
                {
224
237
                        controller.NewContextSelection (CurrentPane, args.SelectedIndex);
225
238
                }
226
 
//              
227
 
//              /// <summary>
228
 
//              /// Detect motion events in the area of the menu and show the menu button when hovered
229
 
//              /// </summary>
230
 
//              /// <param name="evnt">
231
 
//              /// A <see cref="EventMotion"/>
232
 
//              /// </param>
233
 
//              /// <returns>
234
 
//              /// A <see cref="System.Boolean"/>
235
 
//              /// </returns>
236
 
//              protected override bool OnMotionNotifyEvent (EventMotion evnt)
237
 
//              {
238
 
//                      int end_x, end_y, start_x, start_y;
239
 
//                      int point_x, point_y;
240
 
//
241
 
//                      GetPosition (out start_x, out start_y);
242
 
//                      GetSize (out end_x, out end_y);
243
 
//                      
244
 
//                      end_x += start_x;
245
 
//                      end_y += start_y;
246
 
//                      
247
 
//                      point_x = (int) evnt.XRoot;
248
 
//                      point_y = (int) evnt.YRoot;
249
 
//                      
250
 
//                      if ((end_x - 30 <= point_x) && (point_x < end_x - 10) && 
251
 
//                          (start_y <= point_y) && (point_y < start_y + 15)) {
252
 
//                              if (!frame.DrawArrow)
253
 
//                                      frame.DrawArrow = true;
254
 
//                      } else {
255
 
//                              if (frame.DrawArrow)
256
 
//                                      frame.DrawArrow = false;
257
 
//                      }
258
 
//                      
259
 
//                      return base.OnMotionNotifyEvent (evnt);
260
 
//              }
 
239
                
 
240
                /// <summary>
 
241
                /// Detect motion events in the area of the menu and show the menu button when hovered
 
242
                /// </summary>
 
243
                /// <param name="evnt">
 
244
                /// A <see cref="EventMotion"/>
 
245
                /// </param>
 
246
                /// <returns>
 
247
                /// A <see cref="System.Boolean"/>
 
248
                /// </returns>
 
249
                protected override bool OnMotionNotifyEvent (EventMotion evnt)
 
250
                {
 
251
                        int end_x, end_y, start_x, start_y;
 
252
                        int point_x, point_y;
 
253
 
 
254
                        GetPosition (out start_x, out start_y);
 
255
                        GetSize (out end_x, out end_y);
 
256
                        
 
257
                        end_x += start_x;
 
258
                        end_y += start_y;
 
259
                        
 
260
                        point_x = (int) evnt.XRoot;
 
261
                        point_y = (int) evnt.YRoot;
 
262
                        
 
263
                        if ((end_x - 35 <= point_x) && 
 
264
                                (point_x < end_x - 15) && 
 
265
                            (start_y+frameoffset <= point_y) && 
 
266
                                (point_y < start_y + frameoffset + 15)) {
 
267
                                if (!frame.HoverArrow)
 
268
                                        frame.HoverArrow = true;
 
269
                        } else {
 
270
                                if (frame.HoverArrow)
 
271
                                        frame.HoverArrow = false;
 
272
                        }
 
273
                        
 
274
                        return base.OnMotionNotifyEvent (evnt);
 
275
                }
261
276
                
262
277
                /// <summary>
263
278
                /// Detect if we have clicked on or off the window and and alert the controller.
288
303
                                Addins.Util.Appearance.PopupMainMenuAtPosition (end_x - 35, start_y + 25);
289
304
                                // Have to re-grab the pane from the menu.
290
305
                                Addins.Util.Appearance.PresentWindow (this);
291
 
                                //frame.DrawArrow = false;
 
306
                                frame.HoverArrow = false;
292
307
                        } else if (!click_on_window) {
293
308
                                controller.ButtonPressOffWindow ();
294
309
                        }
307
322
                /// </returns>
308
323
                protected override bool OnKeyPressEvent (EventKey evnt)
309
324
                {
310
 
                        KeyPressEvent (evnt);
311
 
                        
 
325
                        switch (evnt.Key) {
 
326
                                case Gdk.Key.Page_Up:
 
327
                                        resultsWindow.SelectedIndex -= NumberResultsDisplayed;
 
328
                                        break;
 
329
                                case Gdk.Key.Page_Down:
 
330
                                        resultsWindow.SelectedIndex += NumberResultsDisplayed;
 
331
                                        break;
 
332
                                default:
 
333
                                        KeyPressEvent (evnt);
 
334
                                        break;
 
335
                        }
 
336
 
312
337
                        return base.OnKeyPressEvent (evnt);
313
338
                }
314
339
                
317
342
                /// </summary>
318
343
                public void Reposition ()
319
344
                {
320
 
                        int monitor;
321
 
                        Gdk.Rectangle geo, main, results;
 
345
                        Gdk.Rectangle offset;
 
346
                        int iconboxWidth;
 
347
 
 
348
                        offset = new Rectangle (frameoffset + ((int) IconBoxPadding * 2), 0, 0 ,0);
 
349
                        iconboxWidth = (iconbox[0].Width + ((int) IconBoxPadding * 4));
322
350
                        
323
 
                        GetPosition (out main.X, out main.Y);
324
 
                        GetSize (out main.Width, out main.Height);
325
 
                        monitor = Screen.GetMonitorAtPoint (main.X, main.Y);
326
 
                        geo = Screen.GetMonitorGeometry (monitor);
327
 
                        main.X = (geo.Width - main.Width) / 2;
328
 
                        main.Y = (int)((geo.Height - main.Height) / 2.5);
329
 
                        Move (main.X, main.Y);
330
 
 
331
 
                        //use frameoffset to get proper positioning and account for additional glass framing
332
 
                        resultsWindow.GetSize (out results.Width, out results.Height);
333
 
                        results.Y = main.Y + main.Height;// - frameoffset;
334
 
                        results.X = main.X + (((iconbox[0].Width) + ((int) IconBoxPadding * 2)) * 
335
 
                                              (int) currentPane + MainRadius) + frameoffset;
336
 
                        resultsWindow.Move (results.X, results.Y);
 
351
                        PositionWindow.UpdatePosition (iconboxWidth, currentPane, offset);
337
352
                }
338
353
                
339
354
                  ///////////////////////
342
357
                
343
358
                public void Summon ()
344
359
                {
 
360
                        //needed to know where our monitor sits...
 
361
                        if (PositionWindow.GetMonitor ()) {
 
362
                                Reposition ();
 
363
                        }
345
364
                        Show ();
346
365
                        Util.Appearance.PresentWindow (this);
347
366
                }
432
451
                public void SetPaneContext (Pane pane, SearchContext context)
433
452
                {
434
453
                        if (context.Results.Length == 0) {
 
454
                                NoResultsFoundObject noRes = new NoResultsFoundObject (context.Query);
435
455
                                for (int i = (int) pane; i < 3; i++) {
436
456
                                        iconbox[i].Clear ();
437
 
                                        NoResultsFoundObject noRes = new NoResultsFoundObject (context.Query);
438
457
                                        iconbox[i].DisplayObject = noRes;
439
 
                                        if (i == (int) CurrentPane)
 
458
                                        if (i == (int) CurrentPane) {
440
459
                                                label.SetDisplayLabel (noRes.Name, noRes.Description);
 
460
                                                resultsWindow.Context = context;
 
461
                                        }
441
462
                                }
442
463
                                return;
443
464
                        }