Minor fixes to comments.
[AROS.git] / rom / intuition / zipwindow.c
blob4b2b0cf495b2711c3425a5ed0a26156bf046d795
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include "intuition_intern.h"
8 #include "inputhandler_actions.h"
10 struct ZipWindowActionMsg
12 struct IntuiActionMsg msg;
13 struct Window *window;
16 static VOID int_zipwindow(struct ZipWindowActionMsg *msg,
17 struct IntuitionBase *IntuitionBase);
19 /*****************************************************************************
21 NAME */
22 #include <intuition/intuition.h>
23 #include <proto/intuition.h>
25 AROS_LH1(void, ZipWindow,
27 /* SYNOPSIS */
28 AROS_LHA(struct Window *, window, A0),
30 /* LOCATION */
31 struct IntuitionBase *, IntuitionBase, 84, Intuition)
33 /* FUNCTION
34 "Zip" (move and resize) a window to the coordinates and dimensions
35 the window had at the last call of ZipWindow(), or invoked via the
36 zoom-gadget.
38 INPUTS
39 window - Which window
41 RESULT
42 None.
44 NOTES
45 This call is deferred. Wait() for IDCMP_CHANGEWINDOW if your
46 program depends on the new size.
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 ChangeWindowBox(), MoveWindow(), SizeWindow()
55 INTERNALS
57 HISTORY
59 *****************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct ZipWindowActionMsg msg;
65 DEBUG_ZIPWINDOW(dprintf("ZipWindow(Window 0x%lx)\n",window));
67 SANITY_CHECK(window)
69 msg.window = window;
71 DoASyncAction((APTR)int_zipwindow, &msg.msg, sizeof(msg), IntuitionBase);
72 // DoSyncAction((APTR)int_zipwindow, &msg.msg, IntuitionBase);
74 AROS_LIBFUNC_EXIT
76 } /* ZipWindow */
79 static VOID int_zipwindow(struct ZipWindowActionMsg *msg,
80 struct IntuitionBase *IntuitionBase)
82 struct Window *window = msg->window;
83 struct IntWindow *w = (struct IntWindow *)window;
84 LONG NewLeftEdge, NewTopEdge, NewWidth, NewHeight;
86 if (!ResourceExisting(window, RESOURCE_WINDOW, IntuitionBase)) return;
88 NewLeftEdge = window->LeftEdge;
89 if (w->ZipLeftEdge != ~0)
91 NewLeftEdge = w->ZipLeftEdge;
92 #ifdef __MORPHOS__
93 w->ZipLeftEdge = w->window.LeftEdge;
94 #else
95 w->ZipLeftEdge = w->window.RelLeftEdge;
96 #endif
99 NewTopEdge = window->TopEdge;
100 if (w->ZipTopEdge != ~0)
102 NewTopEdge = w->ZipTopEdge;
103 #ifdef __MORPHOS__
104 w->ZipTopEdge = w->window.TopEdge;
105 #else
106 w->ZipTopEdge = w->window.RelTopEdge;
107 # endif
110 NewWidth = window->Width;
111 if (w->ZipWidth != ~0)
113 NewWidth = w->ZipWidth;
114 if (window->Flags & WFLG_SIZEGADGET)
116 if (NewWidth < (ULONG)window->MinWidth) NewWidth = window->MinWidth;
117 if (NewWidth > (ULONG)window->MaxWidth) NewWidth = window->MaxWidth;
119 w->ZipWidth = w->window.Width;
122 NewHeight = window->Height;
123 if (w->ZipHeight != ~0)
125 NewHeight = w->ZipHeight;
126 if (window->Flags & WFLG_SIZEGADGET)
128 if (NewHeight < (ULONG)window->MinHeight) NewHeight = window->MinHeight;
129 if (NewHeight > (ULONG)window->MaxHeight) NewHeight = window->MaxHeight;
131 w->ZipHeight = w->window.Height;
134 DoMoveSizeWindow(window, NewLeftEdge, NewTopEdge, NewWidth, NewHeight, TRUE, IntuitionBase);
136 if (window->Flags & WFLG_ZOOMED)
137 AROS_ATOMIC_AND(window->Flags, ~WFLG_ZOOMED);
138 else
139 AROS_ATOMIC_OR(window->Flags, WFLG_ZOOMED);