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:
@@ -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>
|
||||||
@@ -23,91 +25,59 @@ 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))
|
||||||
|
.Add(fFindLabel = new BTextControl("fFindLabel", "", "", NULL))
|
||||||
|
.Add(fSelectionRadio = new BRadioButton("fSelectionRadio",
|
||||||
|
"Use Selection", NULL))
|
||||||
|
.Add(separator)
|
||||||
|
.Add(fForwardSearchBox = new BCheckBox("fForwardSearchBox",
|
||||||
|
"Search Forward", NULL))
|
||||||
|
.Add(fMatchCaseBox = new BCheckBox("fMatchCaseBox",
|
||||||
|
"Match Case", NULL))
|
||||||
|
.Add(fMatchWordBox = new BCheckBox("fMatchWordBox",
|
||||||
|
"Match Word", NULL))
|
||||||
|
.Add(fFindButton = new BButton("fFindButton", "Find",
|
||||||
|
new BMessage(MSG_FIND)))
|
||||||
|
.End();
|
||||||
|
|
||||||
//These labels are from the bottom up
|
AddChild(layoutView);
|
||||||
float buttonsTop = frame.Height() - 19 - lineHeight;
|
|
||||||
float matchWordBottom = buttonsTop - 4;
|
|
||||||
float matchWordTop = matchWordBottom - lineHeight - 8;
|
|
||||||
float matchCaseBottom = matchWordTop - 4;
|
|
||||||
float matchCaseTop = matchCaseBottom - lineHeight - 8;
|
|
||||||
float forwardSearchBottom = matchCaseTop - 4;
|
|
||||||
float forwardSearchTop = forwardSearchBottom - lineHeight - 8;
|
|
||||||
|
|
||||||
//These things are calculated from the top
|
layoutView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
float textRadioTop = 12;
|
|
||||||
float textRadioBottom = textRadioTop + 2 + lineHeight + 2 + 1;
|
|
||||||
float textRadioLeft = 14;
|
|
||||||
float textRadioRight = textRadioLeft + fFindView->StringWidth("Use Text: ") + 30;
|
|
||||||
float selectionRadioTop = textRadioBottom + 4;
|
|
||||||
float selectionRadioBottom = selectionRadioTop + lineHeight + 8;
|
|
||||||
|
|
||||||
//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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user