diff --git a/src/tools/translation/inspector/Constants.h b/src/tools/translation/inspector/Constants.h index e6ea4e2592..a4f8bbe6f3 100644 --- a/src/tools/translation/inspector/Constants.h +++ b/src/tools/translation/inspector/Constants.h @@ -32,14 +32,14 @@ #define MESSAGES_H // BMessage 'what' values - #define M_OPEN_IMAGE 'opim' #define M_SAVE_IMAGE 'saim' #define M_OPEN_FILE_PANEL 'ofpl' +#define M_INFO_WINDOW 'infw' +#define M_INFO_WINDOW_QUIT 'infq' // String constants - #define APP_SIG "application/x-vnd.OBOS-Inspector" #define IMAGEWINDOW_TITLE "Inspector" diff --git a/src/tools/translation/inspector/ImageWindow.cpp b/src/tools/translation/inspector/ImageWindow.cpp index f327cf9aa6..4b6316534e 100644 --- a/src/tools/translation/inspector/ImageWindow.cpp +++ b/src/tools/translation/inspector/ImageWindow.cpp @@ -44,8 +44,8 @@ ImageWindow::ImageWindow(BRect rect, const char *name) // Setup menu bar BRect rctbar(0, 0, 100, 10); BMenuBar *pbar = new BMenuBar(rctbar, "MenuBar"); - BMenu *pmnufile = new BMenu("File"); + BMenu *pmnufile = new BMenu("File"); BMenuItem *pitmopen = new BMenuItem("Open...", new BMessage(M_OPEN_IMAGE), 'O', 0); @@ -60,6 +60,15 @@ ImageWindow::ImageWindow(BRect rect, const char *name) pmnufile->AddSeparatorItem(); pmnufile->AddItem(pitmquit); pbar->AddItem(pmnufile); + + BMenu *pmnuwindow = new BMenu("Window"); + BMenuItem *pitminfo = new BMenuItem("Info", + new BMessage(M_INFO_WINDOW), 'I', 0); + pitminfo->SetTarget(be_app); + + pmnuwindow->AddItem(pitminfo); + pbar->AddItem(pmnuwindow); + AddChild(pbar); // Setup image view @@ -74,7 +83,8 @@ ImageWindow::ImageWindow(BRect rect, const char *name) // Setup file open panel fpopenPanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(this), - (const entry_ref*)NULL, 0L, false, new BMessage(M_OPEN_FILE_PANEL), NULL, false, true); + (const entry_ref *)NULL, 0L, false, new BMessage(M_OPEN_FILE_PANEL), + NULL, false, true); SetSizeLimits(200, 10000, 150, 10000); } diff --git a/src/tools/translation/inspector/ImageWindow.h b/src/tools/translation/inspector/ImageWindow.h index 131d8d6df8..9ebcb698f1 100644 --- a/src/tools/translation/inspector/ImageWindow.h +++ b/src/tools/translation/inspector/ImageWindow.h @@ -38,7 +38,7 @@ class ImageWindow : public BWindow { public: - ImageWindow(BRect rec, const char *name); + ImageWindow(BRect rect, const char *name); ~ImageWindow(); void MessageReceived(BMessage *pmsg); bool QuitRequested(); diff --git a/src/tools/translation/inspector/InfoWindow.cpp b/src/tools/translation/inspector/InfoWindow.cpp new file mode 100644 index 0000000000..1657f0bb30 --- /dev/null +++ b/src/tools/translation/inspector/InfoWindow.cpp @@ -0,0 +1,99 @@ +/*****************************************************************************/ +// InfoWindow +// Written by Michael Wilber, OBOS Translation Kit Team +// +// InfoWindow.cpp +// +// BWindow class for displaying information about the currently open +// document +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#include "Constants.h" +#include "InfoWindow.h" +#include +#include +#include + +InfoWindow::InfoWindow(BRect rect, const char *name) + : BWindow(rect, name, B_DOCUMENT_WINDOW, 0) +{ + BRect rctframe = Bounds(); + rctframe.right -= B_V_SCROLL_BAR_WIDTH; + rctframe.bottom -= B_H_SCROLL_BAR_HEIGHT; + + BRect rcttext = rctframe; + rcttext.OffsetTo(B_ORIGIN); + + fptextView = new BTextView(rctframe, "infoview", rcttext, + B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED); + + BScrollView *psv; + AddChild(psv = new BScrollView("infoscrollview", fptextView, + B_FOLLOW_ALL_SIDES, 0, true, true)); + fptextView->MakeEditable(false); + fptextView->MakeResizable(true); + fptextView->SetText("Sample text here! blah blah blah blah blah blah"); + fptextView->MakeFocus(true); + + SetSizeLimits(100, 10000, 100, 10000); + + Show(); +} + +InfoWindow::~InfoWindow() +{ +} + +// +// TextWindow::FrameResized +// +// Adjust the size of the BTextView's text rectangle +// when the window is resized. +// +void +InfoWindow::FrameResized(float width, float height) +{ + BRect rcttext = fptextView->TextRect(); + + rcttext.right = rcttext.left + (width - B_V_SCROLL_BAR_WIDTH); + fptextView->SetTextRect(rcttext); +} + +void +InfoWindow::MessageReceived(BMessage *pmsg) +{ + switch (pmsg->what) { + default: + BWindow::MessageReceived(pmsg); + break; + } +} + +void +InfoWindow::Quit() +{ + // tell the app to forget about this window + be_app->PostMessage(M_INFO_WINDOW_QUIT); + BWindow::Quit(); +} diff --git a/src/tools/translation/inspector/InfoWindow.h b/src/tools/translation/inspector/InfoWindow.h new file mode 100644 index 0000000000..880bde9b53 --- /dev/null +++ b/src/tools/translation/inspector/InfoWindow.h @@ -0,0 +1,50 @@ +/*****************************************************************************/ +// InfoWindow +// Written by Michael Wilber, OBOS Translation Kit Team +// +// InfoWindow.h +// +// BWindow class for displaying information about the currently open +// document +// +// +// Copyright (c) 2003 OpenBeOS Project +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +/*****************************************************************************/ + +#ifndef INFOWINDOW_H +#define INFOWINDOW_H + +#include +#include + +class InfoWindow : public BWindow { +public: + InfoWindow(BRect rect, const char *name); + ~InfoWindow(); + void FrameResized(float width, float height); + void MessageReceived(BMessage *pmsg); + void Quit(); + +private: + BTextView *fptextView; +}; + +#endif // #ifndef INFOWINDOW_H diff --git a/src/tools/translation/inspector/InspectorApp.cpp b/src/tools/translation/inspector/InspectorApp.cpp index 16484ff1e1..b93256c49d 100644 --- a/src/tools/translation/inspector/InspectorApp.cpp +++ b/src/tools/translation/inspector/InspectorApp.cpp @@ -38,12 +38,34 @@ InspectorApp::InspectorApp() : BApplication(APP_SIG) { + fpinfowin = NULL; + // Show application window BRect rect(100, 100, 500, 400); ImageWindow *pwin = new ImageWindow(rect, IMAGEWINDOW_TITLE); pwin->Show(); } +void +InspectorApp::MessageReceived(BMessage *pmsg) +{ + switch (pmsg->what) { + case M_INFO_WINDOW: + if (!fpinfowin) + fpinfowin = new InfoWindow( + BRect(50, 50, 150, 150), "Info Win"); + break; + + case M_INFO_WINDOW_QUIT: + fpinfowin = NULL; + break; + + default: + BApplication::MessageReceived(pmsg); + break; + } +} + void InspectorApp::RefsReceived(BMessage *pmsg) { diff --git a/src/tools/translation/inspector/InspectorApp.h b/src/tools/translation/inspector/InspectorApp.h index aeb263be5c..e9021d0a49 100644 --- a/src/tools/translation/inspector/InspectorApp.h +++ b/src/tools/translation/inspector/InspectorApp.h @@ -33,12 +33,17 @@ #ifndef INSPECTORAPP_H #define INSPECTORAPP_H +#include "InfoWindow.h" #include class InspectorApp : public BApplication { public: InspectorApp(); + void MessageReceived(BMessage *pmsg); void RefsReceived(BMessage *pmsg); + +private: + InfoWindow *fpinfowin; }; #endif // #ifndef INSPECTORAPP_H diff --git a/src/tools/translation/inspector/Jamfile b/src/tools/translation/inspector/Jamfile index 50b9bf09c9..13d7bc4ef8 100644 --- a/src/tools/translation/inspector/Jamfile +++ b/src/tools/translation/inspector/Jamfile @@ -4,6 +4,7 @@ AddResources Inspector : Inspector.rsrc ; App Inspector : StatusCheck.cpp + InfoWindow.cpp ImageView.cpp ImageWindow.cpp InspectorApp.cpp ;