Minor fixes to comments.
[AROS.git] / rom / intuition / windowlimits.c
blob84acbe211d6e86df76fa5a78d829b06d5ba8afcb
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 Set the minimum and maximum size of a window.
7 */
9 #include "intuition_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <exec/types.h>
15 #include <intuition/intuition.h>
16 #include <proto/intuition.h>
18 AROS_LH5(BOOL, WindowLimits,
20 /* SYNOPSIS */
21 AROS_LHA(struct Window *, window, A0),
22 AROS_LHA(WORD, MinWidth, D0),
23 AROS_LHA(WORD, MinHeight, D1),
24 AROS_LHA(UWORD, MaxWidth, D2),
25 AROS_LHA(UWORD, MaxHeight, D3),
27 /* LOCATION */
28 struct IntuitionBase *, IntuitionBase, 53, Intuition)
30 /* FUNCTION
31 This functions sets the minimum and maximum sizes of a window.
33 INPUTS
34 Window - window to change
35 MinWidth, MinHeight - the minimum size, may be 0 for no change
36 MaxWidth, MaxHeight - the maximum size, may be 0 for no change,
37 may be -1 for no maximum size
39 RESULT
40 A boolean. FALSE is returned if any of the provided sizes is out
41 of range. Note that the other sizes take effect, though. TRUE if
42 all sizes could be set.
44 NOTES
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 OpenWindow()
53 INTERNALS
55 HISTORY
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 BOOL retval = TRUE;
63 DEBUG_WINDOWLIMITS(dprintf("WindowLimits(Window 0x%lx MinWidth %ld MinHeight %ld MaxWidth %ld MaxHeight %ld)\n",window,MinWidth,MinHeight,MaxWidth,MaxHeight));
65 IntuitionBase = IntuitionBase; /* shut up the compiler */
67 SANITY_CHECKR(window,FALSE)
69 /* convert -1 to screen width/height */
70 if ((WORD)MaxWidth == -1) MaxWidth = window->WScreen->Width;
71 if ((WORD)MaxHeight == -1) MaxHeight = window->WScreen->Height;
73 /* crop maxwidth/height to screen width/height */
74 if (MaxWidth > window->WScreen->Width) MaxWidth = window->WScreen->Width;
75 if (MaxHeight > window->WScreen->Height) MaxHeight = window->WScreen->Height;
77 if (MinWidth)
79 if(window->Width >= MinWidth)
80 window->MinWidth = MinWidth;
81 else
82 retval = FALSE;
85 if (MinHeight)
87 if(window->Height >= MinHeight)
88 window->MinHeight = MinHeight;
89 else
90 retval = FALSE;
93 if (MaxWidth)
95 if(window->Width <= MaxWidth)
96 window->MaxWidth = MaxWidth;
97 else
98 retval = FALSE;
101 if (MaxHeight)
103 if(window->Height <= MaxHeight)
104 window->MaxHeight = MaxHeight;
105 else
106 retval = FALSE;
109 return retval;
111 AROS_LIBFUNC_EXIT
113 } /* WindowLimits */