Fix FreeBSD build.
[haiku.git] / src / tools / translation / inspector / InfoWindow.cpp
blobe9489be1aad79be69fe03480c53643d9ac2e1fb7
1 /*****************************************************************************/
2 // InfoWindow
3 // Written by Michael Wilber, OBOS Translation Kit Team
4 //
5 // InfoWindow.cpp
6 //
7 // BWindow class for displaying information about the currently open
8 // document
9 //
11 // Copyright (c) 2003 OpenBeOS Project
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 /*****************************************************************************/
32 #include "Constants.h"
33 #include "InfoWindow.h"
34 #include <Application.h>
35 #include <ScrollView.h>
36 #include <Message.h>
37 #include <String.h>
39 InfoWindow::InfoWindow(BRect rect, const char *name, const char *text)
40 : BWindow(rect, name, B_DOCUMENT_WINDOW, 0)
42 BRect rctframe = Bounds();
43 rctframe.right -= B_V_SCROLL_BAR_WIDTH;
44 rctframe.bottom -= B_H_SCROLL_BAR_HEIGHT;
46 BRect rcttext = rctframe;
47 rcttext.OffsetTo(B_ORIGIN);
49 fptextView = new BTextView(rctframe, "infoview", rcttext,
50 B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED);
52 BScrollView *psv;
53 AddChild(psv = new BScrollView("infoscrollview", fptextView,
54 B_FOLLOW_ALL_SIDES, 0, true, true));
55 fptextView->MakeEditable(false);
56 //fptextView->MakeResizable(true);
57 fptextView->SetText(text);
59 SetSizeLimits(100, 10000, 100, 10000);
61 Show();
64 InfoWindow::~InfoWindow()
69 // TextWindow::FrameResized
71 // Adjust the size of the BTextView's text rectangle
72 // when the window is resized.
74 void
75 InfoWindow::FrameResized(float width, float height)
77 BRect rcttext = fptextView->TextRect();
79 rcttext.right = rcttext.left + (width - B_V_SCROLL_BAR_WIDTH);
80 fptextView->SetTextRect(rcttext);
83 void
84 InfoWindow::MessageReceived(BMessage *pmsg)
86 switch (pmsg->what) {
87 case M_INFO_WINDOW_TEXT:
89 // App is telling me new info has arrived;
90 // The view text must be updated
91 BString bstr;
92 if (pmsg->FindString("text", &bstr) == B_OK)
93 fptextView->SetText(bstr.String());
94 break;
97 default:
98 BWindow::MessageReceived(pmsg);
99 break;
103 void
104 InfoWindow::Quit()
106 // tell the app to forget about this window
107 be_app->PostMessage(M_INFO_WINDOW_QUIT);
108 BWindow::Quit();