added beginnings of InfoWindow -- window that displays as much info as possible for currently open document
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3616 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
031858645f
commit
ce5a2573d3
@ -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"
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
|
99
src/tools/translation/inspector/InfoWindow.cpp
Normal file
99
src/tools/translation/inspector/InfoWindow.cpp
Normal file
@ -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 <Application.h>
|
||||
#include <ScrollView.h>
|
||||
#include <Message.h>
|
||||
|
||||
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();
|
||||
}
|
50
src/tools/translation/inspector/InfoWindow.h
Normal file
50
src/tools/translation/inspector/InfoWindow.h
Normal file
@ -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 <Window.h>
|
||||
#include <TextView.h>
|
||||
|
||||
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
|
@ -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)
|
||||
{
|
||||
|
@ -33,12 +33,17 @@
|
||||
#ifndef INSPECTORAPP_H
|
||||
#define INSPECTORAPP_H
|
||||
|
||||
#include "InfoWindow.h"
|
||||
#include <Application.h>
|
||||
|
||||
class InspectorApp : public BApplication {
|
||||
public:
|
||||
InspectorApp();
|
||||
void MessageReceived(BMessage *pmsg);
|
||||
void RefsReceived(BMessage *pmsg);
|
||||
|
||||
private:
|
||||
InfoWindow *fpinfowin;
|
||||
};
|
||||
|
||||
#endif // #ifndef INSPECTORAPP_H
|
||||
|
@ -4,6 +4,7 @@ AddResources Inspector : Inspector.rsrc ;
|
||||
|
||||
App Inspector :
|
||||
StatusCheck.cpp
|
||||
InfoWindow.cpp
|
||||
ImageView.cpp
|
||||
ImageWindow.cpp
|
||||
InspectorApp.cpp ;
|
||||
|
Loading…
Reference in New Issue
Block a user