* Fixed various minor font sensitivity/resize problems.

* Fixed translator version info; didn't correctly displayed versions < 1.
* Drastically improved looks of that info alert.
* Nicer version alert.
* Renamed class DataTranslationsView to TranslatorListView.
* Added license.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16722 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-03-11 20:14:13 +00:00
parent e7df4a4829
commit 5ac11f960a
10 changed files with 381 additions and 299 deletions

View File

@ -1,67 +1,80 @@
/*
* DataTranslations.cpp
* DataTranslations mccall@digitalparadise.co.uk
* Copyright 2002-2006, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Oliver Siebenmarck
* Andrew McCall, mccall@digitalparadise.co.uk
* Michael Wilber
*/
#include <Alert.h>
#include <Screen.h>
#include "DataTranslations.h"
#include "DataTranslationsWindow.h"
#include "DataTranslationsSettings.h"
#include "DataTranslationsMessages.h"
const char DataTranslationsApplication::kDataTranslationsApplicationSig[] = "application/x-vnd.OpenBeOS-prefs-translations";
#include <Alert.h>
#include <Directory.h>
#include <TranslatorRoster.h>
#include <TextView.h>
int main(int, char**)
{
DataTranslationsApplication myApplication;
myApplication.Run();
const char* kApplicationSignature = "application/x-vnd.haiku-translations";
return(0);
}
DataTranslationsApplication::DataTranslationsApplication()
:BApplication(kDataTranslationsApplicationSig)
: BApplication(kApplicationSignature)
{
DataTranslationsWindow *window;
fSettings = new DataTranslationsSettings();
window = new DataTranslationsWindow();
new DataTranslationsWindow();
}
DataTranslationsApplication::~DataTranslationsApplication()
{
delete fSettings;
}
void
DataTranslationsApplication::SetWindowCorner(BPoint corner)
{
fSettings->SetWindowCorner(corner);
}
void
DataTranslationsApplication::AboutRequested(void)
DataTranslationsApplication::AboutRequested()
{
(new BAlert("", "... written by Oliver Siebenmarck", "Cool!"))->Go();
return;
BAlert *alert = new BAlert("about", "DataTranslations\n"
"\twritten by Oliver Siebenmarck and others\n"
"\tCopyright 2002-2006, Haiku.\n", "Ok");
BTextView *view = alert->TextView();
BFont font;
view->SetStylable(true);
view->GetFont(&font);
font.SetSize(18);
font.SetFace(B_BOLD_FACE);
view->SetFontAndColor(0, 16, &font);
alert->Go();
}
DataTranslationsApplication::~DataTranslationsApplication()
{
delete fSettings;
}
void DataTranslationsApplication::Install_Done()
void
DataTranslationsApplication::InstallDone()
{
(new BAlert("",
"You have to quit and restart running applications\n"
"for the installed Translators to be available in them.",
"for the installed Translators to be available for them.",
"OK"))->Go();
}
void DataTranslationsApplication::RefsReceived(BMessage *message)
void
DataTranslationsApplication::RefsReceived(BMessage *message)
{
uint32 type;
int32 count;
@ -94,15 +107,14 @@ void DataTranslationsApplication::RefsReceived(BMessage *message)
if (keep->Go() == 0)
moveit = true;
if (moveit) // Just a quick move
{
if (dirt.Contains(newfile.String()))
{
if (moveit) {
// Just a quick move
if (dirt.Contains(newfile.String())) {
string.SetTo("");
string << "An item named '" << e_name <<"' already is in the \nTranslators folder";
BAlert *myAlert = new BAlert("title", string.String() , "Overwrite", "Stop");
myAlert->SetShortcut(1, B_ESCAPE);
if (myAlert->Go() != 0)
return;
// File exists, we are still here. Kill it.
@ -111,58 +123,70 @@ void DataTranslationsApplication::RefsReceived(BMessage *message)
dele.Remove();
}
entry.MoveTo(&dirt); // Move it.
Install_Done(); // Installation done
InstallDone(); // Installation done
return;
}
if (dirt.Contains(newfile.String()))
{
if (dirt.Contains(newfile.String())) {
// File exists, What are we supposed to do now (Overwrite/_Stopp_?)
string.SetTo("");
string << "An item named '" << e_name <<"' already is in the \nTranslators folder";
BAlert *myAlert = new BAlert("title", string.String() , "Overwrite", "Stop");
myAlert->SetShortcut(1, B_ESCAPE);
if (myAlert->Go() != 0)
return;
}
string.SetTo(path.Path()); // Fullpath+Filename
BString
command = "copyattr -d -r ";
BString command;
#ifdef __HAIKU__
command = "cp ";
#else
command = "copyattr -d -r ";
#endif
command << string.String() << " " << newfile.String(); // Prepare Copy
system(command.String()); // Execute copy command
string.SetTo("");
string << "Filename: " << e_name << "\nPath: " << path.Path() ;
// The new Translator has been installed by now.
// And done we are
Install_Done();
return;
}
else
{
InstallDone();
} else {
// Not a Translator
no_trans(e_name);
NoTranslatorError(e_name);
}
}
else
{
} else {
// Not even a file...
no_trans(e_name);
NoTranslatorError(e_name);
}
}
}
void DataTranslationsApplication::no_trans(char item_name[B_FILE_NAME_LENGTH])
void
DataTranslationsApplication::NoTranslatorError(const char* name)
{
BString text;
text.SetTo("The item '");
text << item_name << "' does not appear to be a Translator and will not be installed";
text << name << "' does not appear to be a Translator and will not be installed.";
(new BAlert("", text.String(), "Stop"))->Go();
return;
}
// #pragma mark -
int
main(int, char**)
{
DataTranslationsApplication app;
app.Run();
return 0;
}

View File

@ -1,41 +1,45 @@
/*
* Copyright 2002-2006, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Oliver Siebenmarck
* Andrew McCall, mccall@digitalparadise.co.uk
* Michael Wilber
*/
#ifndef DATA_TRANSLATIONS_H
#define DATA_TRANSLATIONS_H
#include "DataTranslationsWindow.h"
#include "DataTranslationsSettings.h"
#include <Application.h>
#include <String.h>
#include <Alert.h>
#include <stdlib.h>
#include "DataTranslationsWindow.h"
#include "DataTranslationsView.h"
#include "DataTranslationsSettings.h"
class DataTranslationsApplication : public BApplication
{
public:
DataTranslationsApplication();
virtual ~DataTranslationsApplication();
class DataTranslationsApplication : public BApplication {
public:
DataTranslationsApplication();
virtual ~DataTranslationsApplication();
// void MessageReceived(BMessage *message);
virtual void RefsReceived(BMessage *message);
BPoint WindowCorner() const {return fSettings->WindowCorner(); }
void SetWindowCorner(BPoint corner);
virtual void RefsReceived(BMessage *message);
virtual void AboutRequested(void);
void AboutRequested(void);
private:
void Install_Done();
static const char kDataTranslationsApplicationSig[];
BPoint WindowCorner() const {return fSettings->WindowCorner(); }
void SetWindowCorner(BPoint corner);
DataTranslationsSettings *fSettings;
// Tell User our installation is done
void no_trans(char item_name[B_FILE_NAME_LENGTH]);
// Tell User he didn´t drop a translator
bool overwrite, moveit;
BString string;
private:
void InstallDone();
void NoTranslatorError(const char* name);
DataTranslationsSettings* fSettings;
bool overwrite, moveit;
BString string;
};
#endif
#endif // DATA_TRANSLATIONS_H

View File

@ -1,4 +1,6 @@
resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.haiku-translations";
resource(1, "BEOS:FILE_TYPES") message;
resource(101, "BEOS:L:STD_ICON") #'ICON' array
@ -57,8 +59,6 @@ resource(101, "BEOS:M:STD_ICON") #'MICN' array
$"FFFFFFFFFFFFFFFFFF00000E0F0F0F0F"
};
resource(1, "BEOS:APP_SIG") #'MIMS' "application/x-vnd.OpenBeOS-prefs-translations";
resource(1, "BEOS:APP_VERSION") #'APPV' array
{
$"00000000000000000100000001000000010000004F70656E42654F5300000000"

View File

@ -1,15 +1,21 @@
/*
DataTranslationsMessages.h
*/
* Copyright 2003-2006, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Unknown?
* Michael Wilber
*/
#ifndef DATA_TRANSLATIONS_MESSAGES_H
#define DATA_TRANSLATIONS_MESSAGES_H
#include <SupportDefs.h>
#define BUTTON_MSG 'PRES'
const uint32 SEL_CHANGE = 'SEch';
const uint32 ERROR_DETECTED = 'ERor';
#endif
#endif // DATA_TRANSLATIONS_MESSAGES_H

View File

@ -1,26 +0,0 @@
/*
*
* DataTranslationsView.h
*
* by Oliver Siebenmarck
*/
#ifndef DATA_TRANSLATIONS_VIEW_H
#define DATA_TRANSLATIONS_VIEW_H
#include <interface/View.h>
#include <interface/ListView.h>
class DataTranslationsView : public BListView {
public:
DataTranslationsView(BRect rect, const char *name,
list_view_type type = B_SINGLE_SELECTION_LIST);
~DataTranslationsView();
void MessageReceived(BMessage *message);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *msg);
};
#endif

View File

@ -1,22 +1,43 @@
/*
* DataTranslationsWindow.cpp
* Copyright 2002-2006, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Oliver Siebenmarck
* Andrew McCall, mccall@digitalparadise.co.uk
* Michael Wilber
*/
#include <Application.h>
#include <Message.h>
#include <Screen.h>
#include <TranslationDefs.h>
#include "DataTranslationsMessages.h"
#include "DataTranslationsWindow.h"
#include "DataTranslations.h"
#include "DataTranslationsMessages.h"
#include "DataTranslationsSettings.h"
#include "DataTranslationsWindow.h"
#include "IconView.h"
#include "TranslatorListView.h"
#include <Application.h>
#include <Screen.h>
#include <Alert.h>
#include <Bitmap.h>
#include <Box.h>
#include <Button.h>
#include <ListView.h>
#include <Path.h>
#include <ScrollView.h>
#include <String.h>
#include <StringView.h>
#include <TextView.h>
#include <TranslationDefs.h>
#include <TranslatorRoster.h>
#define DTW_RIGHT 400
#define DTW_BOTTOM 300
DataTranslationsWindow::DataTranslationsWindow()
: BWindow(BRect(0, 0, DTW_RIGHT, DTW_BOTTOM),
"DataTranslations", B_TITLED_WINDOW, B_NOT_ZOOMABLE|B_NOT_RESIZABLE)
"DataTranslations", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE)
{
MoveTo(dynamic_cast<DataTranslationsApplication *>(be_app)->WindowCorner());
@ -35,46 +56,47 @@ DataTranslationsWindow::DataTranslationsWindow()
y = scrf.top;
if (winf.bottom > scrf.bottom)
y = scrf.bottom - winf.Height() - 15;
if (x != winf.left || y != winf.top)
MoveTo(x, y);
SetupViews();
_SetupViews();
Show();
}
DataTranslationsWindow::~DataTranslationsWindow()
{
}
// Reads the installed translators and adds them to our BListView
status_t
DataTranslationsWindow::PopulateListView()
DataTranslationsWindow::_PopulateListView()
{
BTranslatorRoster *roster = BTranslatorRoster::Default();
// Get all Translators on the system. Gives us the number of translators
// installed in num_translators and a reference to the first one
int32 num_translators;
translator_id *translators;
roster->GetAllTranslators(&translators, &num_translators);
int32 numTranslators;
translator_id *translators = NULL;
roster->GetAllTranslators(&translators, &numTranslators);
for (int32 i = 0; i < numTranslators; i++) {
// Getting the first three Infos: Name, Info & Version
int32 version;
const char *name, *info;
roster->GetTranslatorInfo(translators[i], &name, &info, &version);
fTranslatorListView->AddItem(new BStringItem(name));
}
for (int32 i = 0; i < num_translators; i++) {
// Getting the first three Infos: Name, Info & Version
int32 tversion;
const char *tname, *tinfo;
roster->GetTranslatorInfo(translators[i], &tname, &tinfo, &tversion);
fTranListView->AddItem(new BStringItem(tname));
}
delete[] translators;
translators = NULL;
return B_OK;
}
status_t
DataTranslationsWindow::GetTranInfo(int32 id, const char *&tranName,
DataTranslationsWindow::_GetTranslatorInfo(int32 id, const char *&tranName,
const char *&tranInfo, int32 &tranVersion, BPath &tranPath)
{
// Returns information about the translator with the given id
@ -82,15 +104,14 @@ DataTranslationsWindow::GetTranInfo(int32 id, const char *&tranName,
if (id < 0)
return B_BAD_VALUE;
int32 num_translators = 0;
int32 numTranslators = 0;
translator_id tid = 0, *translators = NULL;
BTranslatorRoster *roster = BTranslatorRoster::Default();
roster->GetAllTranslators(&translators, &num_translators);
tid = ((id < num_translators) ? translators[id] : 0);
roster->GetAllTranslators(&translators, &numTranslators);
tid = ((id < numTranslators) ? translators[id] : 0);
delete[] translators;
translators = NULL;
if (id >= num_translators)
if (id >= numTranslators)
return B_BAD_VALUE;
// Getting the first three Infos: Name, Info & Version
@ -105,23 +126,23 @@ DataTranslationsWindow::GetTranInfo(int32 id, const char *&tranName,
return B_OK;
}
status_t
DataTranslationsWindow::ShowConfigView(int32 id)
DataTranslationsWindow::_ShowConfigView(int32 id)
{
// Shows the config panel for the translator with the given id
if (id < 0)
return B_BAD_VALUE;
int32 num_translators = 0;
int32 numTranslators = 0;
translator_id tid = 0, *translators = NULL;
BTranslatorRoster *roster = BTranslatorRoster::Default();
roster->GetAllTranslators(&translators, &num_translators);
tid = ((id < num_translators) ? translators[id] : 0);
roster->GetAllTranslators(&translators, &numTranslators);
tid = ((id < numTranslators) ? translators[id] : 0);
delete[] translators;
translators = NULL;
if (id >= num_translators)
if (id >= numTranslators)
return B_BAD_VALUE;
// fConfigView is NULL the first time this function
@ -159,23 +180,33 @@ DataTranslationsWindow::ShowConfigView(int32 id)
return B_OK;
}
void
DataTranslationsWindow::SetupViews()
DataTranslationsWindow::_SetupViews()
{
fConfigView = NULL;
// This is NULL until a translator is
// selected from the listview
// Window box
BBox *mainBox = new BBox(BRect(0, 0, DTW_RIGHT, DTW_BOTTOM),
"All_Window", B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
AddChild(mainBox);
BView* mainView = new BView(Bounds(), "", B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS);
mainView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(mainView);
// Add the translators list view
fTranslatorListView = new TranslatorListView(BRect(10, 10, 120, Bounds().Height() - 10),
"TransList", B_SINGLE_SELECTION_LIST);
fTranslatorListView->SetSelectionMessage(new BMessage(SEL_CHANGE));
BScrollView *scrollView = new BScrollView("scroll_trans", fTranslatorListView,
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS,
false, true, B_FANCY_BORDER);
mainView->AddChild(scrollView);
// Box around the config and info panels
fRightBox = new BBox(BRect(150, 10, 390, 290), "Right_Side",
B_FOLLOW_ALL_SIDES);
mainBox->AddChild(fRightBox);
fRightBox = new BBox(BRect(130 + B_V_SCROLL_BAR_WIDTH, 10, Bounds().Width() - 10,
Bounds().Height() - 10), "Right_Side", B_FOLLOW_ALL);
mainView->AddChild(fRightBox);
// Add the translator icon view
BRect rightRect(fRightBox->Bounds()), iconRect(0, 0, 31, 31);
@ -184,43 +215,32 @@ DataTranslationsWindow::SetupViews()
fIconView = new IconView(iconRect, "Icon",
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS);
fRightBox->AddChild(fIconView);
// Add the translator info button
BRect infoRect(0, 0, 80, 20);
infoRect.OffsetTo(rightRect.right - infoRect.Width(),
rightRect.bottom - 10 - infoRect.Height());
BButton *button = new BButton(infoRect, "STD", "Info...",
new BMessage(BUTTON_MSG), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
button->ResizeToPreferred();
button->MoveTo(fRightBox->Bounds().Width() - button->Bounds().Width() - 10.0f,
fRightBox->Bounds().Height() - button->Bounds().Height() - 10.0f);
fRightBox->AddChild(button);
// Add the translator name view
BRect tranNameRect(iconRect.right + 5, iconRect.top,
infoRect.left - 5, iconRect.bottom);
fTranNameView = new BStringView(tranNameRect, "TranName", "None",
B_FOLLOW_LEFT | B_FOLLOW_V_CENTER);
fRightBox->AddChild(fTranNameView);
// Add the translators list view
fTranListView = new DataTranslationsView(BRect(10, 10, 120, 288),
"TransList", B_SINGLE_SELECTION_LIST);
fTranListView->SetSelectionMessage(new BMessage(SEL_CHANGE));
BScrollView *scrollView = new BScrollView("scroll_trans", fTranListView,
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS,
false, true, B_FANCY_BORDER);
mainBox->AddChild(scrollView);
fTranslatorNameView = new BStringView(tranNameRect, "TranName", "None",
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fRightBox->AddChild(fTranslatorNameView);
// Populate the translators list view
PopulateListView();
// Set the focus
fTranListView->MakeFocus();
// Select the first Translator in list
fTranListView->Select(0, false);
_PopulateListView();
fTranslatorListView->MakeFocus();
fTranslatorListView->Select(0, false);
}
bool
DataTranslationsWindow::QuitRequested()
{
@ -231,18 +251,52 @@ DataTranslationsWindow::QuitRequested()
return true;
}
void
DataTranslationsWindow::_ShowInfoAlert(int32 id)
{
const char* name = NULL;
const char* info = NULL;
BPath path;
int32 version = 0;
_GetTranslatorInfo(id, name, info, version, path);
BString message;
message << "Name:\t" << name << "\nVersion:\t";
// Convert the version number into a readable format
message << (int)B_TRANSLATION_MAJOR_VERSION(version)
<< '.' << (int)B_TRANSLATION_MINOR_VERSION(version)
<< '.' << (int)B_TRANSLATION_REVISION_VERSION(version);
message << "\nInfo:\t\t" << info <<
"\n\nPath:\n" << path.Path() << "\n";
BAlert *alert = new BAlert("info", message.String(), "OK");
BTextView *view = alert->TextView();
BFont font;
view->SetStylable(true);
view->GetFont(&font);
font.SetFace(B_BOLD_FACE);
const char* labels[] = {"Name:", "Version:", "Info:", "Path:", NULL};
for (int32 i = 0; labels[i]; i++) {
int32 index = message.FindFirst(labels[i]);
view->SetFontAndColor(index, index + strlen(labels[i]), &font);
}
alert->Go();
}
void
DataTranslationsWindow::MessageReceived(BMessage *message)
{
BPath tranPath;
BString strInfoMsg;
const char *tranName = NULL, *tranInfo = NULL;
int32 selected = -1, tranVersion = 0;
switch (message->what) {
case BUTTON_MSG:
selected = fTranListView->CurrentSelection(0);
{
int32 selected = fTranslatorListView->CurrentSelection(0);
if (selected < 0) {
// If no translator is selected, show a message explaining
// what the config panel is for
@ -254,44 +308,37 @@ DataTranslationsWindow::MessageReceived(BMessage *message)
"OK"))->Go();
break;
}
GetTranInfo(selected, tranName, tranInfo, tranVersion, tranPath);
strInfoMsg << "Name: " << tranName << "\nVersion: ";
if (tranVersion < 0x100)
// If the version number doesn't follow the standard format,
// just print it as is
strInfoMsg << tranVersion;
else {
// Convert the version number into a readable format
strInfoMsg <<
static_cast<int>(B_TRANSLATION_MAJOR_VERSION(tranVersion)) << '.' <<
static_cast<int>(B_TRANSLATION_MINOR_VERSION(tranVersion)) << '.' <<
static_cast<int>(B_TRANSLATION_REVISION_VERSION(tranVersion));
}
strInfoMsg << "\nInfo: " << tranInfo <<
"\nPath: " << tranPath.Path() << "\n";
(new BAlert("Panel Info", strInfoMsg.String(), "OK"))->Go();
_ShowInfoAlert(selected);
break;
}
case SEL_CHANGE:
{
// Update the icon and translator info panel
// to match the new selection
selected = fTranListView->CurrentSelection(0);
int32 selected = fTranslatorListView->CurrentSelection(0);
if (selected < 0) {
// If none selected, clear the old one
fIconView->DrawIcon(false);
fTranNameView->SetText("");
fTranslatorNameView->SetText("");
fRightBox->RemoveChild(fConfigView);
break;
}
ShowConfigView(selected);
GetTranInfo(selected, tranName, tranInfo, tranVersion, tranPath);
fTranNameView->SetText(tranPath.Leaf());
fIconView->SetIcon(tranPath);
_ShowConfigView(selected);
const char* name = NULL;
const char* info = NULL;
int32 version = 0;
BPath path;
_GetTranslatorInfo(selected, name, info, version, path);
fTranslatorNameView->SetText(path.Leaf());
fIconView->SetIcon(path);
break;
}
default:
BWindow::MessageReceived(message);
break;

View File

@ -1,61 +1,56 @@
#ifndef DATATRANSLATIONS_WINDOW_H
#define DATATRANSLATIONS_WINDOW_H
/*
* Copyright 2002-2006, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Oliver Siebenmarck
* Andrew McCall, mccall@digitalparadise.co.uk
* Michael Wilber
*/
#ifndef DATA_TRANSLATIONS_WINDOW_H
#define DATA_TRANSLATIONS_WINDOW_H
#ifndef _WINDOW_H
#include <Window.h>
#endif
#include <Box.h>
#include <Button.h>
#include <SupportDefs.h>
#include <ListView.h>
#include <TranslatorRoster.h>
#include <TranslationDefs.h>
#include <ScrollView.h>
#include <Alert.h>
#include <String.h>
#include <StringView.h>
#include <Bitmap.h>
#include <storage/Path.h>
#include <storage/Directory.h>
#include <storage/Entry.h>
#include "DataTranslationsSettings.h"
#include "DataTranslationsView.h"
//#include "DataTranslationsSettings.h"
#include "IconView.h"
class DataTranslationsWindow : public BWindow {
public:
DataTranslationsWindow();
~DataTranslationsWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* message);
private:
status_t GetTranInfo(int32 id, const char *&tranName, const char *&tranInfo,
int32 &tranVersion, BPath &tranPath);
status_t ShowConfigView(int32 id);
status_t PopulateListView();
void SetupViews();
DataTranslationsView *fTranListView;
// List of Translators (left pane of window)
BBox *fRightBox;
// Box hosting fConfigView, fIconView,
// fTranNameView and the Info button
BView *fConfigView;
// the translator config view
IconView *fIconView;
// icon in the info panel
#include <Window.h>
BStringView *fTranNameView;
// the translator name, in the info panel
class BBox;
class BView;
class IconView;
class TranslatorListView;
class DataTranslationsWindow : public BWindow {
public:
DataTranslationsWindow();
~DataTranslationsWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage* message);
private:
status_t _GetTranslatorInfo(int32 id, const char *&name, const char *&info,
int32 &version, BPath &path);
void _ShowInfoAlert(int32 id);
status_t _ShowConfigView(int32 id);
status_t _PopulateListView();
void _SetupViews();
TranslatorListView *fTranslatorListView;
BBox *fRightBox;
// Box hosting fConfigView, fIconView,
// fTranNameView and the Info button
BView *fConfigView;
// the translator config view
IconView *fIconView;
BStringView *fTranslatorNameView;
};
#endif // DATATRANSLATIONS_WINDOW_H
#endif // DATA_TRANSLATIONS_WINDOW_H

View File

@ -3,10 +3,10 @@ SubDir HAIKU_TOP src preferences datatranslations ;
Preference DataTranslations :
DataTranslations.cpp
DataTranslationsWindow.cpp
DataTranslationsView.cpp
DataTranslationsSettings.cpp
IconView.cpp
: libbe.so libtranslation.so
TranslatorListView.cpp
: be translation
: DataTranslations.rdef
;

View File

@ -1,32 +1,38 @@
/*
DataTranslationsView.cpp
*/
* Copyright 2002-2006, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Oliver Siebenmarck
* Andrew McCall, mccall@digitalparadise.co.uk
* Michael Wilber
*/
#include "TranslatorListView.h"
#ifndef _APPLICATION_H
#include <Application.h>
#endif
#include "DataTranslationsView.h"
DataTranslationsView::DataTranslationsView(BRect rect, const char *name,
list_view_type type)
TranslatorListView::TranslatorListView(BRect rect, const char *name,
list_view_type type)
: BListView(rect, name, B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES)
{
}
DataTranslationsView::~DataTranslationsView()
TranslatorListView::~TranslatorListView()
{
}
void
DataTranslationsView::MessageReceived(BMessage *message)
TranslatorListView::MessageReceived(BMessage *message)
{
uint32 type;
int32 count;
switch (message->what) {
case B_SIMPLE_DATA:
// Tell the application object that a
@ -38,26 +44,25 @@ DataTranslationsView::MessageReceived(BMessage *message)
Invalidate();
}
break;
default:
BView::MessageReceived(message);
break;
}
}
void
DataTranslationsView::MouseMoved(BPoint point, uint32 transit, const BMessage *msg)
TranslatorListView::MouseMoved(BPoint point, uint32 transit, const BMessage *dragMessage)
{
if (msg && transit == B_ENTERED_VIEW) {
if (dragMessage != NULL && transit == B_ENTERED_VIEW) {
// Draw a red box around the inside of the view
// to tell the user that this view accepts drops
SetHighColor(220,0,0);
SetPenSize(4);
StrokeRect(Bounds());
SetHighColor(0,0,0);
} else if (msg && transit == B_EXITED_VIEW)
} else if (dragMessage != NULL && transit == B_EXITED_VIEW)
Invalidate();
}

View File

@ -0,0 +1,27 @@
/*
* Copyright 2002-2006, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Authors:
* Oliver Siebenmarck
* Andrew McCall, mccall@digitalparadise.co.uk
* Michael Wilber
*/
#ifndef TRANSLATOR_LIST_VIEW_H
#define TRANSLATOR_LIST_VIEW_H
#include <ListView.h>
class TranslatorListView : public BListView {
public:
TranslatorListView(BRect rect, const char *name,
list_view_type type = B_SINGLE_SELECTION_LIST);
virtual ~TranslatorListView();
virtual void MessageReceived(BMessage *message);
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *msg);
};
#endif // TRANSLATOR_LIST_VIEW_H