* BUG: The Move() method now correctly works on top-level windows.

[GB.SETTINGS]
* NEW: Support for multiple screens and desktop layout when saving or 
  loading window geometry in a setting file.


git-svn-id: svn://localhost/gambas/trunk@3423 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2011-01-01 20:49:21 +00:00
parent caefe95103
commit 8793112d29
4 changed files with 76 additions and 22 deletions

View file

@ -1,4 +1,5 @@
[Component]
Key=gb.settings
Version=2.99.0
Authors=Benoît Minisini

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -4,6 +4,8 @@ Export
Create Static
Class Window
Class Desktop
Class Screens
Static Property Read Path As String
@ -303,26 +305,39 @@ End
Public Sub ReadWindow(hWindow As Window, sKey As String)
Dim sPos As String
Dim aPos As Integer[]
Dim X, Y, W, H, S As Integer
Dim sPos As String
aPos = Me[sKey &/ "Geometry"]
If Not aPos Or If aPos.Count < 2 Then Return
aPos[0] = Max(0, aPos[0])
aPos[1] = Max(0, aPos[1])
If aPos.Count = 4 Then
aPos[2] = Max(32, aPos[2])
aPos[3] = Max(32, aPos[3])
X = aPos[0]
Y = aPos[1]
If aPos.Count >= 2 Then
W = aPos[2]
H = aPos[3]
If aPos.Count >= 5 Then
S = aPos[4]
If S >= Screens.Count Then S = 0
Endif
Endif
'cPos = Split(sPos, ",")
If aPos.Count = 4 And hWindow.Resizable Then
X += Screens[S].AvailableX
Y += Screens[S].AvailableY
' If Object.Type(hWindow) = "FHelpBrowser" Then
' Print "ReadWindow: "; X;; Y; " / "; S;; Screens[S].AvailableX;; Screens[S].AvailableY
' Endif
If aPos.Count >= 4 And hWindow.Resizable Then
W = Max(32, W)
H = Max(32, H)
If hWindow.Modal Then
hWindow.Resize(aPos[2], aPos[3])
hWindow.Resize(W, H)
hWindow.Center
Else
hWindow.Move(Max(0, aPos[0]), Max(0, aPos[1]), aPos[2], aPos[3])
hWindow.Move(X, Y, W, H)
Endif
Else
If Not hWindow.Modal Then hWindow.Move(aPos[0], aPos[1])
@ -333,7 +348,19 @@ End
Public Sub WriteWindow(hWindow As Window, sKey As String)
Me[sKey &/ "Geometry"] = [hWindow.X, hWindow.Y, hWindow.Width, hWindow.Height]
Dim X, Y, W, H, S As Integer
' If Object.Type(hWindow) = "FHelpBrowser" Then
' Print "WriteWindow: "; hWindow.X;; hWindow.Y; " / "; S;; Screens[S].AvailableX;; Screens[S].AvailableY
' Endif
S = hWindow.Screen
X = hWindow.X - Screens[S].AvailableX
Y = hWindow.Y - Screens[S].AvailableY
W = hWindow.Width
H = hWindow.Height
Me[sKey &/ "Geometry"] = [X, Y, W, H, S]
End

View file

@ -495,6 +495,42 @@ void CWIDGET_resize_cached(void *_object, int w, int h)
}
void CWIDGET_move_resize(void *_object, int x, int y, int w, int h)
{
QWidget *wid = get_widget(THIS);
if (wid)
{
if (w < 0)
w = wid->width();
if (h < 0)
h = wid->height();
if (x == wid->x() && y == wid->y() && w == wid->width() && h == wid->height())
return;
if (GB.Is(THIS, CLASS_Window))
{
wid->move(x, y);
wid->resize(qMax(0, w), qMax(0, h));
}
else
wid->setGeometry(x, y, qMax(0, w), qMax(0, h));
}
if (GB.Is(THIS, CLASS_Window))
{
((CWINDOW *)_object)->x = x;
((CWINDOW *)_object)->y = y;
((CWINDOW *)_object)->w = w;
((CWINDOW *)_object)->h = h;
}
CWIDGET_after_geometry_change(THIS, true);
}
#if 0
void CWIDGET_move_resize(void *_object, int x, int y, int w, int h)
{
QWidget *wid = get_widget(THIS);
@ -530,6 +566,7 @@ void CWIDGET_move_resize(void *_object, int x, int y, int w, int h)
CWIDGET_after_geometry_change(THIS, true);
}
#endif
void CWIDGET_move_resize_cached(void *_object, int x, int y, int w, int h)
{
@ -1992,20 +2029,9 @@ static void handle_focus_change()
void CWIDGET_handle_focus(CWIDGET *control, bool on)
{
static int cpt = 0;
if (on == (CWIDGET_active_control == control))
return;
//qDebug("CWIDGET_handle_focus: %s %d", control->name, on);
/*if (!qstrcmp(control->name, "Form1") && on)
{
cpt++;
if (cpt == 2)
BREAKPOINT();
}*/
CWIDGET_active_control = on ? control : NULL;
handle_focus_change();
}