Added beginnings of Active Translators window -- allows the user to select which translators will be active when an image is opened or saved

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3782 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matthew Wilber
2003-07-01 03:48:17 +00:00
parent 57b75f140b
commit d1360823ff
8 changed files with 203 additions and 15 deletions
@@ -0,0 +1,116 @@
/*****************************************************************************/
// ActiveTranslatorsWindow
// Written by Michael Wilber, OBOS Translation Kit Team
//
// ActiveTranslatorsWindow.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 "ActiveTranslatorsWindow.h"
#include <Application.h>
#include <ScrollView.h>
#include <Message.h>
#include <String.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
ActiveTranslatorsWindow::ActiveTranslatorsWindow(BRect rect, const char *name)
: BWindow(rect, name, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
BRect rctframe = Bounds();
rctframe.InsetBy(5, 5);
rctframe.right -= B_V_SCROLL_BAR_WIDTH;
fplist = new BOutlineListView(rctframe, "translators_list",
B_MULTIPLE_SELECTION_LIST);
fplist->AddItem(fpuserItem = new BStringItem("User Translators"));
fplist->AddItem(fpsystemItem = new BStringItem("System Translators"));
AddTranslatorsToList("/boot/home/config/add-ons/Translators", fpuserItem);
AddTranslatorsToList("/system/add-ons/Translators", fpsystemItem);
AddChild(new BScrollView("scroll_list", fplist, B_FOLLOW_LEFT | B_FOLLOW_TOP,
0, false, true));
SetSizeLimits(100, 10000, 100, 10000);
Show();
}
void
ActiveTranslatorsWindow::AddTranslatorsToList(const char *path,
BStringItem *pparent)
{
DIR *dir = opendir(path);
if (!dir) {
return;
}
struct dirent *dent;
struct stat stbuf;
char cwd[PATH_MAX] = "";
while (NULL != (dent = readdir(dir))) {
strcpy(cwd, path);
strcat(cwd, "/");
strcat(cwd, dent->d_name);
status_t err = stat(cwd, &stbuf);
if (!err && S_ISREG(stbuf.st_mode) &&
strcmp(dent->d_name, ".") && strcmp(dent->d_name, ".."))
fplist->AddUnder(new BStringItem(dent->d_name), pparent);
}
closedir(dir);
}
ActiveTranslatorsWindow::~ActiveTranslatorsWindow()
{
}
void
ActiveTranslatorsWindow::FrameResized(float width, float height)
{
}
void
ActiveTranslatorsWindow::MessageReceived(BMessage *pmsg)
{
switch (pmsg->what) {
default:
BWindow::MessageReceived(pmsg);
break;
}
}
void
ActiveTranslatorsWindow::Quit()
{
// tell the app to forget about this window
be_app->PostMessage(M_ACTIVE_TRANSLATORS_WINDOW_QUIT);
BWindow::Quit();
}
@@ -0,0 +1,54 @@
/*****************************************************************************/
// ActiveTranslatorsWindow
// Written by Michael Wilber, OBOS Translation Kit Team
//
// ActiveTranslatorsWindow.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 ACTIVETRANSLATORSWINDOW_H
#define ACTIVETRANSLATORSWINDOW_H
#include <Window.h>
#include <OutlineListView.h>
class ActiveTranslatorsWindow : public BWindow {
public:
ActiveTranslatorsWindow(BRect rect, const char *name);
~ActiveTranslatorsWindow();
void FrameResized(float width, float height);
void MessageReceived(BMessage *pmsg);
void Quit();
private:
void AddTranslatorsToList(const char *path, BStringItem *pparent);
BOutlineListView *fplist;
BStringItem *fpuserItem;
BStringItem *fpsystemItem;
};
#endif // #ifndef ACTIVETRANSLATORSWINDOW_H
+8 -6
View File
@@ -32,12 +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'
#define M_INFO_WINDOW_TEXT 'inft'
#define M_OPEN_IMAGE 'opim'
#define M_SAVE_IMAGE 'saim'
#define M_OPEN_FILE_PANEL 'ofpl'
#define M_ACTIVE_TRANSLATORS_WINDOW 'atrn'
#define M_ACTIVE_TRANSLATORS_WINDOW_QUIT 'atrq'
#define M_INFO_WINDOW 'infw'
#define M_INFO_WINDOW_QUIT 'infq'
#define M_INFO_WINDOW_TEXT 'inft'
// String constants
@@ -414,7 +414,7 @@ ImageView::SetImage(BMessage *pmsg)
AdjustScrollBars();
pwin->Zoom();
//pwin->Zoom();
// Perform all of the hard work of resizing the
// window while taking into account the size of
// the screen, the tab and borders of the window
@@ -62,10 +62,15 @@ ImageWindow::ImageWindow(BRect rect, const char *name)
pbar->AddItem(pmnufile);
BMenu *pmnuwindow = new BMenu("Window");
BMenuItem *pitmactives = new BMenuItem("Active Translators",
new BMessage(M_ACTIVE_TRANSLATORS_WINDOW), 'T', 0);
pitmactives->SetTarget(be_app);
BMenuItem *pitminfo = new BMenuItem("Info",
new BMessage(M_INFO_WINDOW), 'I', 0);
pitminfo->SetTarget(be_app);
pmnuwindow->AddItem(pitmactives);
pmnuwindow->AddItem(pitminfo);
pbar->AddItem(pmnuwindow);
@@ -40,6 +40,7 @@
InspectorApp::InspectorApp()
: BApplication(APP_SIG)
{
fpactiveswin = NULL;
fpinfowin = NULL;
// Show application window
@@ -52,12 +53,23 @@ void
InspectorApp::MessageReceived(BMessage *pmsg)
{
switch (pmsg->what) {
case M_INFO_WINDOW:
if (!fpinfowin)
fpinfowin = new InfoWindow(BRect(50, 50, 150, 150),
"Info Win", fbstrInfo.String());
case M_ACTIVE_TRANSLATORS_WINDOW:
if (!fpactiveswin)
fpactiveswin = new ActiveTranslatorsWindow(
BRect(625, 350, 800, 600), "Active Translators");
break;
case M_ACTIVE_TRANSLATORS_WINDOW_QUIT:
fpactiveswin = NULL;
break;
case M_INFO_WINDOW:
if (!fpinfowin)
fpinfowin = new InfoWindow(BRect(625, 50, 800, 300),
"Info Win", fbstrInfo.String());
break;
case M_INFO_WINDOW_QUIT:
fpinfowin = NULL;
break;
case M_INFO_WINDOW_TEXT:
// If image view is telling me to
// update the info window...
@@ -66,10 +78,6 @@ InspectorApp::MessageReceived(BMessage *pmsg)
fpinfowin->PostMessage(pmsg);
break;
case M_INFO_WINDOW_QUIT:
fpinfowin = NULL;
break;
default:
BApplication::MessageReceived(pmsg);
break;
@@ -33,6 +33,7 @@
#ifndef INSPECTORAPP_H
#define INSPECTORAPP_H
#include "ActiveTranslatorsWindow.h"
#include "InfoWindow.h"
#include <Application.h>
#include <String.h>
@@ -45,6 +46,7 @@ public:
private:
BString fbstrInfo;
ActiveTranslatorsWindow *fpactiveswin;
InfoWindow *fpinfowin;
};
+1
View File
@@ -4,6 +4,7 @@ AddResources Inspector : Inspector.rsrc ;
App Inspector :
StatusCheck.cpp
ActiveTranslatorsWindow.cpp
InfoWindow.cpp
ImageView.cpp
ImageWindow.cpp