~do-win/do/test-paths

« back to all changes in this revision

Viewing changes to Do.Interface.Windows/src/Do.Interface/PositionWindow.cs

  • Committer: Hardeep S
  • Date: 2009-06-23 03:53:12 UTC
  • Revision ID: ootz0rz@gmail.com-20090623035312-it8tb5wkha6nf31p
Added Do.Interface.Windows, and a bunch of cleanup with old MonoDevelop files elsewhere

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// PositionWindow.cs
 
2
//
 
3
// GNOME Do is the legal property of its developers. Please refer to the
 
4
// COPYRIGHT file distributed with this source distribution.
 
5
//
 
6
// This program is free software; you can redistribute it and/or modify
 
7
// it under the terms of the GNU General Public License as published by
 
8
// the Free Software Foundation; either version 2 of the License, or
 
9
// (at your option) any later version.
 
10
//
 
11
// This program is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
// GNU General Public License for more details.
 
15
// 
 
16
// You should have received a copy of the GNU General Public License
 
17
// along with this program; if not, write to the Free Software
 
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
19
//
 
20
//
 
21
 
 
22
using System;
 
23
 
 
24
using Gdk;
 
25
using Gtk;
 
26
 
 
27
using Do.Platform;
 
28
 
 
29
namespace Do.Interface
 
30
{
 
31
        
 
32
        
 
33
        public class PositionWindow
 
34
        {
 
35
                Gtk.Window w, r;
 
36
                
 
37
                public PositionWindow (Gtk.Window main, Gtk.Window results)
 
38
                {
 
39
                        this.w = main;
 
40
                        this.r = results;
 
41
                }
 
42
 
 
43
                int GetMonitor ()
 
44
                {
 
45
                        Display disp;
 
46
                        Rectangle point;
 
47
 
 
48
                        disp = w.Screen.Display;
 
49
                        disp.GetPointer(out point.X, out point.Y);
 
50
                        return w.Screen.GetMonitorAtPoint (point.X, point.Y);
 
51
                }
 
52
                
 
53
                public void UpdatePosition (int iconboxWidth, Pane currentPane, Rectangle resultsOffset)
 
54
                {
 
55
                        UpdatePosition (iconboxWidth, currentPane, resultsOffset, new Gdk.Rectangle ());
 
56
                }
 
57
                
 
58
                public void UpdatePosition (int iconboxWidth, Pane currentPane, Rectangle resultsOffset, Rectangle normalOffset) {
 
59
                        Gtk.Application.Invoke (delegate {
 
60
                                Gdk.Rectangle geo, main, results;
 
61
                                
 
62
                                w.GetPosition (out main.X, out main.Y);
 
63
                                w.GetSize (out main.Width, out main.Height);
 
64
                        
 
65
                                geo = w.Screen.GetMonitorGeometry (GetMonitor ());
 
66
                                main.X = ((geo.Width - main.Width) / 2) + geo.X + normalOffset.X;
 
67
                                main.Y = (int)((geo.Height + geo.Y - main.Height) / 2.5) + geo.Y + normalOffset.Y;
 
68
                                w.Move (main.X, main.Y);
 
69
                                
 
70
                                if (r == null) return;
 
71
                                //position resultsWindow
 
72
                                r.GetSize (out results.Width, out results.Height);
 
73
                                results.Y = main.Y + main.Height + resultsOffset.Y;
 
74
                                results.X = main.X + iconboxWidth * (int) currentPane + resultsOffset.X;
 
75
                                r.Move (results.X, results.Y);
 
76
                        });
 
77
                }
 
78
                
 
79
        }
 
80
}