Beginnings of refactoring. Removed unnessecary member variables, removed commented out code, renamed some member v
ariables to meet style guidelines, fixed icon repainting by moving icon drawing to its own BView class. Still need to check for more unnessecary member variables, fix more style issues and resolve behavior differences between the Haiku and Be versions of this preference panel. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9830 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -35,25 +35,6 @@ DataTranslationsApplication::DataTranslationsApplication()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Unused.
|
|
||||||
void
|
|
||||||
DataTranslationsApplication::MessageReceived(BMessage *message)
|
|
||||||
{
|
|
||||||
switch(message->what) {
|
|
||||||
case ERROR_DETECTED:
|
|
||||||
{
|
|
||||||
BAlert *errorAlert = new BAlert("Error", "Unknown Error occured","OK",NULL,NULL,B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
|
|
||||||
errorAlert->Go();
|
|
||||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
BApplication::MessageReceived(message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
DataTranslationsApplication::SetWindowCorner(BPoint corner)
|
DataTranslationsApplication::SetWindowCorner(BPoint corner)
|
||||||
{
|
{
|
||||||
@@ -74,9 +55,10 @@ DataTranslationsApplication::~DataTranslationsApplication()
|
|||||||
|
|
||||||
void DataTranslationsApplication::Install_Done()
|
void DataTranslationsApplication::Install_Done()
|
||||||
{
|
{
|
||||||
(new BAlert("", "You have to quit and restart running applications\nfor the installed Translators to be available in them.", "OK"))->Go();
|
(new BAlert("",
|
||||||
// aWindow->Install_Done = true;
|
"You have to quit and restart running applications\n" \
|
||||||
return;
|
"for the installed Translators to be available in them.",
|
||||||
|
"OK"))->Go();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataTranslationsApplication::RefsReceived(BMessage *message)
|
void DataTranslationsApplication::RefsReceived(BMessage *message)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ int DataTranslationsWindow::WriteTrans()
|
|||||||
for (i=0;i<num_translators;i++) {
|
for (i=0;i<num_translators;i++) {
|
||||||
// Getting the first three Infos: Name, Info & Version
|
// Getting the first three Infos: Name, Info & Version
|
||||||
roster->GetTranslatorInfo(translators[i], &tname,&tinfo, &tversion);
|
roster->GetTranslatorInfo(translators[i], &tname,&tinfo, &tversion);
|
||||||
liste->AddItem(new BStringItem(tname));
|
fTranListView->AddItem(new BStringItem(tname));
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] translators; // Garbage collection
|
delete [] translators; // Garbage collection
|
||||||
@@ -74,7 +74,7 @@ void DataTranslationsWindow::Trans_by_ID(int32 id)
|
|||||||
|
|
||||||
// Getting the first three Infos: Name, Info & Version
|
// Getting the first three Infos: Name, Info & Version
|
||||||
roster->GetTranslatorInfo(translators[id], &translator_name,&translator_info, &translator_version);
|
roster->GetTranslatorInfo(translators[id], &translator_name,&translator_info, &translator_version);
|
||||||
roster->Archive(&archiv, true);
|
roster->Archive(&fRosterArchive, true);
|
||||||
|
|
||||||
rBox->RemoveChild(Konf);
|
rBox->RemoveChild(Konf);
|
||||||
if (roster->MakeConfigurationView( translators[id], new BMessage() , &Konf, new BRect( 0, 0, 200, 233)) != B_OK )
|
if (roster->MakeConfigurationView( translators[id], new BMessage() , &Konf, new BRect( 0, 0, 200, 233)) != B_OK )
|
||||||
@@ -110,9 +110,6 @@ void DataTranslationsWindow::Trans_by_ID(int32 id)
|
|||||||
|
|
||||||
void DataTranslationsWindow::BuildView()
|
void DataTranslationsWindow::BuildView()
|
||||||
{
|
{
|
||||||
newIcon = false;
|
|
||||||
Install_Done = false;
|
|
||||||
|
|
||||||
BRect all(0, 0, 400, 300); // Fenster-Groesse
|
BRect all(0, 0, 400, 300); // Fenster-Groesse
|
||||||
fBox = new BBox(all, "All_Window", B_FOLLOW_ALL_SIDES,
|
fBox = new BBox(all, "All_Window", B_FOLLOW_ALL_SIDES,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS,
|
B_WILL_DRAW | B_FRAME_EVENTS,
|
||||||
@@ -128,14 +125,15 @@ void DataTranslationsWindow::BuildView()
|
|||||||
|
|
||||||
BRect iconRect(0,0,31,31);
|
BRect iconRect(0,0,31,31);
|
||||||
iconRect.OffsetTo(innerRect.left,innerRect.bottom-iconRect.Height());
|
iconRect.OffsetTo(innerRect.left,innerRect.bottom-iconRect.Height());
|
||||||
Icon = new BView(iconRect, "Ikon", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
|
fIconView = new IconView(iconRect, "Ikon", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS);
|
B_WILL_DRAW | B_FRAME_EVENTS);
|
||||||
Icon->SetDrawingMode(B_OP_OVER);
|
//fIconView->SetDrawingMode(B_OP_OVER);
|
||||||
//Icon->SetViewColor(ui_color(B_BACKGROUND_COLOR));
|
// to preserve transparent areas of the icon
|
||||||
Icon->SetHighColor(217,217,217);
|
//fIconView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
rBox->AddChild(Icon);
|
|
||||||
|
|
||||||
Icon_bit = new BBitmap(BRect(0, 0, 31, 31), B_CMAP8, true);
|
//fIconView->SetViewColor(0, 255, 0);
|
||||||
|
//fIconView->SetHighColor(0, 0, 255);
|
||||||
|
rBox->AddChild(fIconView);
|
||||||
|
|
||||||
BRect infoRect(0,0,80,20);
|
BRect infoRect(0,0,80,20);
|
||||||
infoRect.OffsetTo(innerRect.right-infoRect.Width(),innerRect.bottom-10-infoRect.Height());
|
infoRect.OffsetTo(innerRect.right-infoRect.Width(),innerRect.bottom-10-infoRect.Height());
|
||||||
@@ -158,23 +156,24 @@ void DataTranslationsWindow::BuildView()
|
|||||||
rBox->AddChild(Konf);
|
rBox->AddChild(Konf);
|
||||||
|
|
||||||
BRect listRect(10, 10, 120, 288); // List View
|
BRect listRect(10, 10, 120, 288); // List View
|
||||||
liste = new DataTranslationsView(listRect, "Transen", B_SINGLE_SELECTION_LIST);
|
fTranListView = new DataTranslationsView(listRect, "Transen", B_SINGLE_SELECTION_LIST);
|
||||||
liste->SetSelectionMessage(new BMessage(SEL_CHANGE));
|
fTranListView->SetSelectionMessage(new BMessage(SEL_CHANGE));
|
||||||
|
|
||||||
// Put list into a BScrollView, to get that nice srcollbar
|
// Put list into a BScrollView, to get that nice srcollbar
|
||||||
tListe = new BScrollView("scroll_trans", liste, B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM,
|
BScrollView *scrollView = new BScrollView("scroll_trans", fTranListView,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS, false, true, B_FANCY_BORDER);
|
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS,
|
||||||
fBox->AddChild(tListe);
|
false, true, B_FANCY_BORDER);
|
||||||
|
fBox->AddChild(scrollView);
|
||||||
|
|
||||||
// Here we add the names of all installed translators
|
// Here we add the names of all installed translators
|
||||||
WriteTrans();
|
WriteTrans();
|
||||||
|
|
||||||
// Set the focus
|
// Set the focus
|
||||||
liste->MakeFocus();
|
fTranListView->MakeFocus();
|
||||||
|
|
||||||
// Select the first Translator in list
|
// Select the first Translator in list
|
||||||
liste->Select(0, false);
|
fTranListView->Select(0, false);
|
||||||
showInfo = true;
|
fTranSelected = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,10 +194,10 @@ DataTranslationsWindow::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
switch(message->what) {
|
switch(message->what) {
|
||||||
case BUTTON_MSG:
|
case BUTTON_MSG:
|
||||||
selected=liste->CurrentSelection(0);
|
selected=fTranListView->CurrentSelection(0);
|
||||||
|
|
||||||
// Should we show translator info?
|
// Should we show translator info?
|
||||||
if (!showInfo)
|
if (!fTranSelected)
|
||||||
{
|
{
|
||||||
// No => Show standard box
|
// No => Show standard box
|
||||||
(new BAlert("yo!", "Translation Settings\n\nUse this control panel to set values that various\ntranslators use when no other settings are specified\nin the application.", "OK"))->Go();
|
(new BAlert("yo!", "Translation Settings\n\nUse this control panel to set values that various\ntranslators use when no other settings are specified\nin the application.", "OK"))->Go();
|
||||||
@@ -206,37 +205,39 @@ DataTranslationsWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
// Yes => Show Translator info.
|
// Yes => Show Translator info.
|
||||||
Trans_by_ID(selected);
|
Trans_by_ID(selected);
|
||||||
archiv.FindString("be:translator_path", selected, &pfad);
|
fRosterArchive.FindString("be:translator_path", selected, &pfad);
|
||||||
tex << "Name :" << translator_name << "\nVersion: " << (int32)translator_version << "\nInfo: " << translator_info << "\nPath: " << pfad << "\n";
|
tex << "Name :" << translator_name << "\nVersion: " << (int32)translator_version << "\nInfo: " << translator_info << "\nPath: " << pfad << "\n";
|
||||||
(new BAlert("yo!", tex.String(), "OK"))->Go();
|
(new BAlert("yo!", tex.String(), "OK"))->Go();
|
||||||
tex.SetTo("");
|
tex.SetTo("");
|
||||||
DrawIcon();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEL_CHANGE:
|
case SEL_CHANGE:
|
||||||
// Now we have to update Filename and Icon
|
// Now we have to update Filename and Icon
|
||||||
// First we find the selected Translator
|
// First we find the selected Translator
|
||||||
selected=liste->CurrentSelection(0);
|
selected=fTranListView->CurrentSelection(0);
|
||||||
|
|
||||||
// If none selected, clear the old one
|
// If none selected, clear the old one
|
||||||
if (selected < 0)
|
if (selected < 0)
|
||||||
{
|
{
|
||||||
Icon->FillRect(BRect(0, 0, 31, 31));
|
fIconView->DrawIcon(false);
|
||||||
DTN->SetText("");
|
DTN->SetText("");
|
||||||
showInfo = false;
|
fTranSelected = false;
|
||||||
rBox->RemoveChild(Konf);
|
rBox->RemoveChild(Konf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
newIcon = true;
|
fTranSelected = true;
|
||||||
showInfo = true;
|
|
||||||
Trans_by_ID(selected);
|
Trans_by_ID(selected);
|
||||||
// Now we find the path, and update filename
|
// Now we find the path, and update filename
|
||||||
archiv.FindString("be:translator_path", selected, &pfad);
|
fRosterArchive.FindString("be:translator_path", selected, &pfad);
|
||||||
tex.SetTo(pfad);
|
tex.SetTo(pfad);
|
||||||
tex.Remove(0,tex.FindLast("/")+1);
|
tex.Remove(0,tex.FindLast("/")+1);
|
||||||
DTN->SetText(tex.String());
|
DTN->SetText(tex.String());
|
||||||
DrawIcon();
|
|
||||||
|
entry.SetTo(pfad);
|
||||||
|
node.SetTo(&entry);
|
||||||
|
info.SetTo(&node);
|
||||||
|
fIconView->SetIconFromNodeInfo(info);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
@@ -247,39 +248,6 @@ DataTranslationsWindow::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataTranslationsWindow::DrawIcon()
|
|
||||||
{
|
|
||||||
if (newIcon)
|
|
||||||
{
|
|
||||||
entry.SetTo(pfad);
|
|
||||||
node.SetTo(&entry);
|
|
||||||
info.SetTo(&node);
|
|
||||||
Icon->FillRect(BRect(0, 0, 31, 31));
|
|
||||||
newIcon = false;
|
|
||||||
}
|
|
||||||
if (info.GetTrackerIcon(Icon_bit) != B_OK) QuitRequested();
|
|
||||||
Icon->DrawBitmap(Icon_bit);
|
|
||||||
|
|
||||||
if (Install_Done)
|
|
||||||
{
|
|
||||||
liste->RemoveItems(0, liste->CountItems());
|
|
||||||
WriteTrans();
|
|
||||||
liste->Select(0, false);
|
|
||||||
Install_Done = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataTranslationsWindow::WindowActivated(bool state)
|
|
||||||
{
|
|
||||||
if (showInfo) DrawIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataTranslationsWindow::FrameMoved(BPoint origin)
|
|
||||||
{
|
|
||||||
if (showInfo) DrawIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
DataTranslationsWindow::~DataTranslationsWindow()
|
DataTranslationsWindow::~DataTranslationsWindow()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "DataTranslationsSettings.h"
|
#include "DataTranslationsSettings.h"
|
||||||
#include "DataTranslationsView.h"
|
#include "DataTranslationsView.h"
|
||||||
|
#include "IconView.h"
|
||||||
|
|
||||||
class DataTranslationsWindow : public BWindow
|
class DataTranslationsWindow : public BWindow
|
||||||
{
|
{
|
||||||
@@ -32,34 +33,29 @@ public:
|
|||||||
|
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual void WindowActivated(bool state);
|
|
||||||
virtual void FrameMoved(BPoint origin);
|
|
||||||
// void WindowActivated(bool state);
|
|
||||||
// void FrameMoved(BPoint origin);
|
|
||||||
void DrawIcon();
|
|
||||||
bool Install_Done; // True if an install just finished, but no List-Update done yet.
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const char *translator_name, *translator_info;
|
const char *translator_name, *translator_info;
|
||||||
int32 translator_version;
|
int32 translator_version;
|
||||||
const char* pfad;
|
const char* pfad;
|
||||||
BString tex;
|
BString tex;
|
||||||
bool showInfo;
|
bool fTranSelected;
|
||||||
bool newIcon;
|
// Indicates whether or not a translator is selected
|
||||||
|
// in the fTranListView
|
||||||
|
|
||||||
BButton* dButton; // Default-Button
|
BButton* dButton; // Default-Button
|
||||||
BBox* fBox; // Full-Window Box
|
BBox* fBox; // Full-Window Box
|
||||||
BScrollView* tListe; // To get that fancy scrollbar
|
|
||||||
BBox* rBox; // Box hosting Config View
|
BBox* rBox; // Box hosting Config View
|
||||||
|
|
||||||
DataTranslationsView* liste; // Improved list of Translators
|
DataTranslationsView *fTranListView;
|
||||||
|
// List of Translators (left pane of window)
|
||||||
|
|
||||||
BStringView* DTN; // Display the DataTranslatorName
|
BStringView* DTN; // Display the DataTranslatorName
|
||||||
BMessage archiv; // My Message
|
BMessage fRosterArchive;
|
||||||
BView* Icon; // The Icon and Config - Views
|
// Archive of the current BTranslatorRoster
|
||||||
BBitmap* Icon_bit;
|
|
||||||
|
IconView *fIconView;
|
||||||
|
|
||||||
BView* Konf;
|
BView* Konf;
|
||||||
|
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
|
|||||||
Reference in New Issue
Block a user