Converted the Terminal Find Window to the layout api keeping (more or less)

the previous look.
Would be nice if the window was a bit wider, but I don't know how to force
that (accepting advices).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34167 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2009-11-20 22:29:11 +00:00
parent e79dab79c8
commit 143981329c
2 changed files with 34 additions and 66 deletions
+33 -63
View File
@@ -11,6 +11,8 @@
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <CheckBox.h> #include <CheckBox.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <RadioButton.h> #include <RadioButton.h>
#include <String.h> #include <String.h>
#include <TextControl.h> #include <TextControl.h>
@@ -19,95 +21,63 @@
const uint32 MSG_FIND_HIDE = 'Fhid'; const uint32 MSG_FIND_HIDE = 'Fhid';
FindWindow::FindWindow (BRect frame, BMessenger messenger , BString &str, FindWindow::FindWindow(BRect frame, BMessenger messenger , BString &str,
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) bool findSelection, bool matchWord, bool matchCase, bool forwardSearch)
: :
BWindow(frame, "Find", B_FLOATING_WINDOW, BWindow(frame, "Find", B_FLOATING_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE), B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE
| B_AUTO_UPDATE_SIZE_LIMITS),
fFindDlgMessenger(messenger) fFindDlgMessenger(messenger)
{ {
AddShortcut((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE)); AddShortcut((ulong)'W', (ulong)B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE));
//Build up view SetLayout(new BGroupLayout(B_VERTICAL));
fFindView = new BView(Bounds(), "FindView", B_FOLLOW_ALL, B_WILL_DRAW); BBox *separator = new BBox("separator");
fFindView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
AddChild(fFindView);
font_height height; BView *layoutView = BGroupLayoutBuilder(B_VERTICAL, 10)
fFindView->GetFontHeight(&height); .SetInsets(5, 5, 5, 5)
float lineHeight = height.ascent + height.descent + height.leading; .Add(fTextRadio = new BRadioButton("fTextRadio", "Use Text: ",
NULL))
//These labels are from the bottom up .Add(fFindLabel = new BTextControl("fFindLabel", "", "", NULL))
float buttonsTop = frame.Height() - 19 - lineHeight; .Add(fSelectionRadio = new BRadioButton("fSelectionRadio",
float matchWordBottom = buttonsTop - 4; "Use Selection", NULL))
float matchWordTop = matchWordBottom - lineHeight - 8; .Add(separator)
float matchCaseBottom = matchWordTop - 4; .Add(fForwardSearchBox = new BCheckBox("fForwardSearchBox",
float matchCaseTop = matchCaseBottom - lineHeight - 8; "Search Forward", NULL))
float forwardSearchBottom = matchCaseTop - 4; .Add(fMatchCaseBox = new BCheckBox("fMatchCaseBox",
float forwardSearchTop = forwardSearchBottom - lineHeight - 8; "Match Case", NULL))
.Add(fMatchWordBox = new BCheckBox("fMatchWordBox",
//These things are calculated from the top "Match Word", NULL))
float textRadioTop = 12; .Add(fFindButton = new BButton("fFindButton", "Find",
float textRadioBottom = textRadioTop + 2 + lineHeight + 2 + 1; new BMessage(MSG_FIND)))
float textRadioLeft = 14; .End();
float textRadioRight = textRadioLeft + fFindView->StringWidth("Use Text: ") + 30;
float selectionRadioTop = textRadioBottom + 4; AddChild(layoutView);
float selectionRadioBottom = selectionRadioTop + lineHeight + 8;
layoutView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
//Divider
float dividerHeight = (selectionRadioBottom + forwardSearchTop) / 2;
//Button Coordinates
float searchButtonLeft = (frame.Width() - fFindView->StringWidth("Find") - 60) / 2;
float searchButtonRight = searchButtonLeft + fFindView->StringWidth("Find") + 60;
//Build the Views
fTextRadio = new BRadioButton(BRect(textRadioLeft, textRadioTop, textRadioRight, textRadioBottom),
"fTextRadio", "Use Text: ", NULL);
fFindView->AddChild(fTextRadio);
fFindLabel = new BTextControl(BRect(textRadioRight + 4, textRadioTop, frame.Width() - 14, textRadioBottom),
"fFindLabel", "", "", NULL);
fFindLabel->SetDivider(0); fFindLabel->SetDivider(0);
fFindView->AddChild(fFindLabel);
if (!findSelection) if (!findSelection)
fFindLabel->SetText(str.String()); fFindLabel->SetText(str.String());
fFindLabel->MakeFocus(true); fFindLabel->MakeFocus(true);
fSelectionRadio = new BRadioButton(BRect(14, selectionRadioTop, frame.Width() - 14, selectionRadioBottom),
"fSelectionRadio", "Use Selection", NULL);
fFindView->AddChild(fSelectionRadio);
if (findSelection) if (findSelection)
fSelectionRadio->SetValue(B_CONTROL_ON); fSelectionRadio->SetValue(B_CONTROL_ON);
else else
fTextRadio->SetValue(B_CONTROL_ON); fTextRadio->SetValue(B_CONTROL_ON);
fSeparator = new BBox(BRect(6, dividerHeight, frame.Width() - 6, dividerHeight + 1));
fFindView->AddChild(fSeparator);
fForwardSearchBox = new BCheckBox(BRect(14, forwardSearchTop, frame.Width() - 14, forwardSearchBottom),
"fForwardSearchBox", "Search Forward", NULL);
fFindView->AddChild(fForwardSearchBox);
if (forwardSearch) if (forwardSearch)
fForwardSearchBox->SetValue(B_CONTROL_ON); fForwardSearchBox->SetValue(B_CONTROL_ON);
fMatchCaseBox = new BCheckBox(BRect(14, matchCaseTop, frame.Width() - 14, matchCaseBottom),
"fMatchCaseBox", "Match Case", NULL);
fFindView->AddChild(fMatchCaseBox);
if (matchCase) if (matchCase)
fMatchCaseBox->SetValue(B_CONTROL_ON); fMatchCaseBox->SetValue(B_CONTROL_ON);
fMatchWordBox = new BCheckBox(BRect(14, matchWordTop, frame.Width() - 14, matchWordBottom),
"fMatchWordBox", "Match Word", NULL);
fFindView->AddChild(fMatchWordBox);
if (matchWord) if (matchWord)
fMatchWordBox->SetValue(B_CONTROL_ON); fMatchWordBox->SetValue(B_CONTROL_ON);
fFindButton = new BButton(BRect(searchButtonLeft, buttonsTop, searchButtonRight, frame.Height() - 14),
"fFindButton", "Find", new BMessage(MSG_FIND));
fFindButton->MakeDefault(true); fFindButton->MakeDefault(true);
fFindView->AddChild(fFindButton);
Show(); Show();
} }
+1 -3
View File
@@ -18,7 +18,6 @@ const ulong MSG_FIND_CLOSED = 'mfcl';
class BTextControl; class BTextControl;
class BRadioButton; class BRadioButton;
class BBox;
class BCheckBox; class BCheckBox;
class FindWindow : public BWindow { class FindWindow : public BWindow {
@@ -34,11 +33,10 @@ class FindWindow : public BWindow {
void _SendFindMessage(); void _SendFindMessage();
private: private:
BView *fFindView;
BTextControl *fFindLabel; BTextControl *fFindLabel;
BRadioButton *fTextRadio; BRadioButton *fTextRadio;
BRadioButton *fSelectionRadio; BRadioButton *fSelectionRadio;
BBox *fSeparator;
BCheckBox *fForwardSearchBox; BCheckBox *fForwardSearchBox;
BCheckBox *fMatchCaseBox; BCheckBox *fMatchCaseBox;
BCheckBox *fMatchWordBox; BCheckBox *fMatchWordBox;