2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions, and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "InfoWindow.h"
38 #include <ScrollBar.h>
41 __USE_CORTEX_NAMESPACE
44 #define D_ALLOC(x) //PRINT (x)
45 #define D_HOOK(x) //PRINT (x)
46 #define D_INTERNAL(x) //PRINT (x)
47 #define D_MESSAGE(x) //PRINT (x)
49 // -------------------------------------------------------- //
51 // -------------------------------------------------------- //
53 InfoWindow::InfoWindow(
56 "", B_DOCUMENT_WINDOW
, 0),
59 D_ALLOC(("InfoWindow::InfoWindow()\n"));
63 InfoWindow::~InfoWindow() {
64 D_ALLOC(("InfoWindow::~InfoWindow()\n"));
68 // -------------------------------------------------------- //
70 // -------------------------------------------------------- //
73 InfoWindow::FrameResized(
76 D_HOOK(("InfoWindow::FrameResized()\n"));
88 D_HOOK(("InfoWindow::Show()\n"));
91 m_manualSize
= Bounds().OffsetToCopy(0.0, 0.0);
101 D_HOOK(("InfoWindow::Zoom()\n"));
105 BScreen
screen(this);
106 if (!screen
.Frame().Contains(Frame())) {
111 // resize to the ideal size
112 m_manualSize
= Bounds();
114 FindView("InfoView")->GetPreferredSize(&width
, &height
);
115 width
+= B_V_SCROLL_BAR_WIDTH
;
116 ResizeTo(width
, height
);
117 _constrainToScreen();
121 // resize to the most recent manual size
122 ResizeTo(m_manualSize
.Width(), m_manualSize
.Height());
127 // -------------------------------------------------------- //
128 // internal operations
129 // -------------------------------------------------------- //
132 InfoWindow::_constrainToScreen() {
133 D_INTERNAL(("InfoWindow::_constrainToScreen()\n"));
135 BScreen
screen(this);
136 BRect screenRect
= screen
.Frame();
137 BRect windowRect
= Frame();
139 // if the window is outside the screen rect
140 // move it to the default position
141 if (!screenRect
.Intersects(windowRect
)) {
142 windowRect
.OffsetTo(screenRect
.LeftTop());
143 MoveTo(windowRect
.LeftTop());
144 windowRect
= Frame();
147 // if the window is larger than the screen rect
148 // resize it to fit at each side
149 if (!screenRect
.Contains(windowRect
)) {
150 if (windowRect
.left
< screenRect
.left
) {
151 windowRect
.left
= screenRect
.left
+ 5.0;
152 MoveTo(windowRect
.LeftTop());
153 windowRect
= Frame();
155 if (windowRect
.top
< screenRect
.top
) {
156 windowRect
.top
= screenRect
.top
+ 5.0;
157 MoveTo(windowRect
.LeftTop());
158 windowRect
= Frame();
160 if (windowRect
.right
> screenRect
.right
) {
161 windowRect
.right
= screenRect
.right
- 5.0;
163 if (windowRect
.bottom
> screenRect
.bottom
) {
164 windowRect
.bottom
= screenRect
.bottom
- 5.0;
166 ResizeTo(windowRect
.Width(), windowRect
.Height());
170 // END -- InfoWindow.cpp --