Continued refactoring. Made style changes, renamed variables to improve consistency and clarity.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9891 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ac7ba0d23c
commit
347759a7e7
@ -39,7 +39,7 @@ DataTranslationsWindow::DataTranslationsWindow()
|
|||||||
if (x != winf.left || y != winf.top)
|
if (x != winf.left || y != winf.top)
|
||||||
MoveTo(x, y);
|
MoveTo(x, y);
|
||||||
|
|
||||||
BuildView();
|
SetupViews();
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ DataTranslationsWindow::~DataTranslationsWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reads the installed translators and adds them to our BListView
|
// Reads the installed translators and adds them to our BListView
|
||||||
int
|
status_t
|
||||||
DataTranslationsWindow::WriteTrans()
|
DataTranslationsWindow::PopulateListView()
|
||||||
{
|
{
|
||||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ DataTranslationsWindow::WriteTrans()
|
|||||||
delete[] translators;
|
delete[] translators;
|
||||||
translators = NULL;
|
translators = NULL;
|
||||||
|
|
||||||
return 0;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
@ -124,30 +124,30 @@ DataTranslationsWindow::ShowConfigView(int32 id)
|
|||||||
if (id >= num_translators)
|
if (id >= num_translators)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
fConfigBox->RemoveChild(fConfigView);
|
fRightBox->RemoveChild(fConfigView);
|
||||||
BMessage emptyMsg;
|
BMessage emptyMsg;
|
||||||
BRect rect(0, 0, 200, 233);
|
BRect rect(0, 0, 200, 233);
|
||||||
status_t ret = roster->MakeConfigurationView(tid, &emptyMsg, &fConfigView, &rect);
|
status_t ret = roster->MakeConfigurationView(tid, &emptyMsg, &fConfigView, &rect);
|
||||||
if (ret != B_OK) {
|
if (ret != B_OK) {
|
||||||
fConfigBox->RemoveChild(fConfigView);
|
fRightBox->RemoveChild(fConfigView);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRect konfRect(fConfigBox->Bounds());
|
BRect configRect(fRightBox->Bounds());
|
||||||
konfRect.InsetBy(3, 3);
|
configRect.InsetBy(3, 3);
|
||||||
konfRect.bottom -= 45;
|
configRect.bottom -= 45;
|
||||||
float width = 0, height = 0;
|
float width = 0, height = 0;
|
||||||
fConfigView->GetPreferredSize(&width, &height);
|
fConfigView->GetPreferredSize(&width, &height);
|
||||||
float widen = max_c(0, width - konfRect.Width());
|
float widen = max_c(0, width - configRect.Width());
|
||||||
float heighten = max_c(0, height - konfRect.Height());
|
float heighten = max_c(0, height - configRect.Height());
|
||||||
if (widen > 0 || heighten > 0) {
|
if (widen > 0 || heighten > 0) {
|
||||||
ResizeBy(widen, heighten);
|
ResizeBy(widen, heighten);
|
||||||
konfRect.right += widen;
|
configRect.right += widen;
|
||||||
konfRect.bottom += heighten;
|
configRect.bottom += heighten;
|
||||||
}
|
}
|
||||||
fConfigView->MoveTo(konfRect.left, konfRect.top);
|
fConfigView->MoveTo(configRect.left, configRect.top);
|
||||||
fConfigView->ResizeTo(konfRect.Width(), konfRect.Height());
|
fConfigView->ResizeTo(configRect.Width(), configRect.Height());
|
||||||
fConfigBox->AddChild(fConfigView);
|
fRightBox->AddChild(fConfigView);
|
||||||
|
|
||||||
UpdateIfNeeded();
|
UpdateIfNeeded();
|
||||||
|
|
||||||
@ -155,59 +155,62 @@ DataTranslationsWindow::ShowConfigView(int32 id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DataTranslationsWindow::BuildView()
|
DataTranslationsWindow::SetupViews()
|
||||||
{
|
{
|
||||||
BRect all(0, 0, 400, 300); // Fenster-Groesse
|
// Window box
|
||||||
BBox *mainBox = new BBox(all, "All_Window", B_FOLLOW_ALL_SIDES,
|
BBox *mainBox = new BBox(BRect(0, 0, DTW_RIGHT, DTW_BOTTOM),
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS,
|
"All_Window", B_FOLLOW_ALL_SIDES,
|
||||||
B_PLAIN_BORDER);
|
B_WILL_DRAW | B_FRAME_EVENTS, B_PLAIN_BORDER);
|
||||||
AddChild(mainBox);
|
AddChild(mainBox);
|
||||||
|
|
||||||
BRect configView( 150, 10, 390, 290);
|
// Box around the config and info panels
|
||||||
fConfigBox = new BBox(configView, "Right_Side", B_FOLLOW_ALL_SIDES);
|
fRightBox = new BBox(BRect(150, 10, 390, 290), "Right_Side",
|
||||||
mainBox->AddChild(fConfigBox);
|
B_FOLLOW_ALL_SIDES);
|
||||||
|
mainBox->AddChild(fRightBox);
|
||||||
|
|
||||||
BRect innerRect(fConfigBox->Bounds());
|
// Add the translator icon view
|
||||||
innerRect.InsetBy(8,8);
|
BRect rightRect(fRightBox->Bounds()), iconRect(0, 0, 31, 31);
|
||||||
|
rightRect.InsetBy(8, 8);
|
||||||
BRect iconRect(0,0,31,31);
|
iconRect.OffsetTo(rightRect.left, rightRect.bottom - iconRect.Height());
|
||||||
iconRect.OffsetTo(innerRect.left,innerRect.bottom-iconRect.Height());
|
fIconView = new IconView(iconRect, "Icon",
|
||||||
fIconView = new IconView(iconRect, "Ikon", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
|
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS);
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS);
|
fRightBox->AddChild(fIconView);
|
||||||
fConfigBox->AddChild(fIconView);
|
|
||||||
|
|
||||||
BRect infoRect(0,0,80,20);
|
// Add the translator info button
|
||||||
infoRect.OffsetTo(innerRect.right-infoRect.Width(),innerRect.bottom-10-infoRect.Height());
|
BRect infoRect(0, 0, 80, 20);
|
||||||
BButton *button = new BButton(infoRect, "STD", "Info...", new BMessage(BUTTON_MSG),
|
infoRect.OffsetTo(rightRect.right - infoRect.Width(),
|
||||||
B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT,
|
rightRect.bottom - 10 - infoRect.Height());
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
|
BButton *button = new BButton(infoRect, "STD", "Info...",
|
||||||
fConfigBox->AddChild(button);
|
new BMessage(BUTTON_MSG), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT,
|
||||||
|
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE);
|
||||||
|
fRightBox->AddChild(button);
|
||||||
|
|
||||||
BRect dataNameRect( iconRect.right+5 , iconRect.top,
|
// Add the translator name view
|
||||||
infoRect.left-5 , iconRect.bottom);
|
BRect tranNameRect(iconRect.right + 5, iconRect.top,
|
||||||
fTranNameView = new BStringView(dataNameRect, "DataName", "Test", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
infoRect.left - 5, iconRect.bottom);
|
||||||
// fTranNameView->SetViewColor(ui_color(B_BACKGROUND_COLOR));
|
fTranNameView = new BStringView(tranNameRect, "TranName", "None",
|
||||||
fConfigBox->AddChild(fTranNameView);
|
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||||
|
fRightBox->AddChild(fTranNameView);
|
||||||
|
|
||||||
BRect konfRect(innerRect);
|
// Add the translator config panel
|
||||||
konfRect.bottom = iconRect.top;
|
BRect configRect(rightRect);
|
||||||
fConfigView = new BView(konfRect, "KONF", B_FOLLOW_ALL_SIDES,
|
configRect.bottom = iconRect.top;
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS );
|
fConfigView = new BView(configRect, "ConfigPanel", B_FOLLOW_ALL_SIDES,
|
||||||
// fConfigView->SetViewColor(ui_color(B_BACKGROUND_COLOR));
|
B_WILL_DRAW | B_FRAME_EVENTS);
|
||||||
fConfigBox->AddChild(fConfigView);
|
fRightBox->AddChild(fConfigView);
|
||||||
|
|
||||||
BRect listRect(10, 10, 120, 288); // List View
|
// Add the translators list view
|
||||||
fTranListView = new DataTranslationsView(listRect, "Transen", B_SINGLE_SELECTION_LIST);
|
fTranListView = new DataTranslationsView(BRect(10, 10, 120, 288),
|
||||||
|
"TransList", B_SINGLE_SELECTION_LIST);
|
||||||
fTranListView->SetSelectionMessage(new BMessage(SEL_CHANGE));
|
fTranListView->SetSelectionMessage(new BMessage(SEL_CHANGE));
|
||||||
|
|
||||||
// Put list into a BScrollView, to get that nice srcollbar
|
|
||||||
BScrollView *scrollView = new BScrollView("scroll_trans", fTranListView,
|
BScrollView *scrollView = new BScrollView("scroll_trans", fTranListView,
|
||||||
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS,
|
B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_WILL_DRAW | B_FRAME_EVENTS,
|
||||||
false, true, B_FANCY_BORDER);
|
false, true, B_FANCY_BORDER);
|
||||||
mainBox->AddChild(scrollView);
|
mainBox->AddChild(scrollView);
|
||||||
|
|
||||||
// Here we add the names of all installed translators
|
// Populate the translators list view
|
||||||
WriteTrans();
|
PopulateListView();
|
||||||
|
|
||||||
// Set the focus
|
// Set the focus
|
||||||
fTranListView->MakeFocus();
|
fTranListView->MakeFocus();
|
||||||
@ -277,7 +280,7 @@ DataTranslationsWindow::MessageReceived(BMessage *message)
|
|||||||
// If none selected, clear the old one
|
// If none selected, clear the old one
|
||||||
fIconView->DrawIcon(false);
|
fIconView->DrawIcon(false);
|
||||||
fTranNameView->SetText("");
|
fTranNameView->SetText("");
|
||||||
fConfigBox->RemoveChild(fConfigView);
|
fRightBox->RemoveChild(fConfigView);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,14 +37,15 @@ private:
|
|||||||
|
|
||||||
status_t ShowConfigView(int32 id);
|
status_t ShowConfigView(int32 id);
|
||||||
|
|
||||||
int WriteTrans();
|
status_t PopulateListView();
|
||||||
void BuildView();
|
void SetupViews();
|
||||||
|
|
||||||
DataTranslationsView *fTranListView;
|
DataTranslationsView *fTranListView;
|
||||||
// List of Translators (left pane of window)
|
// List of Translators (left pane of window)
|
||||||
|
|
||||||
BBox *fConfigBox;
|
BBox *fRightBox;
|
||||||
// Box hosting Config View
|
// Box hosting fConfigView, fIconView,
|
||||||
|
// fTranNameView and the Info button
|
||||||
|
|
||||||
BView *fConfigView;
|
BView *fConfigView;
|
||||||
// the translator config view
|
// the translator config view
|
||||||
|
Loading…
Reference in New Issue
Block a user