* Fix ticket #5249.
* Cleanup and some layout changes. * Disable the text control when using the selection. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35061 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,16 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007-2009, Haiku, Inc. All rights reserved.
|
* Copyright 2007, Haiku, Inc.
|
||||||
* Copyright 2003-2004 Kian Duffy, [email protected]
|
* Copyright 2003-2004 Kian Duffy, [email protected]
|
||||||
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
* Parts Copyright 1998-1999 Kazuho Okui and Takashi Murai.
|
||||||
* All rights reserved. Distributed under the terms of the MIT license.
|
* All rights reserved. Distributed under the terms of the MIT license.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "FindWindow.h"
|
#include "FindWindow.h"
|
||||||
|
|
||||||
|
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include <GridLayoutBuilder.h>
|
||||||
#include <GroupLayout.h>
|
#include <GroupLayout.h>
|
||||||
#include <GroupLayoutBuilder.h>
|
#include <GroupLayoutBuilder.h>
|
||||||
#include <RadioButton.h>
|
#include <RadioButton.h>
|
||||||
@@ -19,12 +21,12 @@
|
|||||||
|
|
||||||
|
|
||||||
const uint32 MSG_FIND_HIDE = 'Fhid';
|
const uint32 MSG_FIND_HIDE = 'Fhid';
|
||||||
|
const uint32 TOGGLE_FIND_CONTROL = 'MTFG';
|
||||||
|
const BRect kWindowFrame(10, 30, 250, 200);
|
||||||
|
|
||||||
const BRect kWindowFrame(0, 0, 240, 170);
|
|
||||||
|
|
||||||
FindWindow::FindWindow(BMessenger messenger, BString &str,
|
FindWindow::FindWindow(BMessenger messenger, const BString& str,
|
||||||
bool findSelection, bool matchWord, bool matchCase,
|
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch)
|
||||||
bool forwardSearch)
|
|
||||||
:
|
:
|
||||||
BWindow(kWindowFrame, "Find", B_FLOATING_WINDOW,
|
BWindow(kWindowFrame, "Find", B_FLOATING_WINDOW,
|
||||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE
|
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE
|
||||||
@@ -32,41 +34,42 @@ FindWindow::FindWindow(BMessenger messenger, BString &str,
|
|||||||
fFindDlgMessenger(messenger)
|
fFindDlgMessenger(messenger)
|
||||||
{
|
{
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
|
|
||||||
BBox *separator = new BBox("separator");
|
|
||||||
separator->SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
|
|
||||||
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
|
|
||||||
|
|
||||||
BView *layoutView = BGroupLayoutBuilder(B_VERTICAL, 10)
|
BBox *separator = new BBox("separator");
|
||||||
.SetInsets(5, 5, 5, 5)
|
separator->SetExplicitMinSize(BSize(250.0, B_SIZE_UNSET));
|
||||||
.Add(fTextRadio = new BRadioButton("fTextRadio", "Use text: ",
|
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1.0));
|
||||||
NULL))
|
|
||||||
.Add(fFindLabel = new BTextControl("fFindLabel", "", "", NULL))
|
BRadioButton* useSelection = NULL;
|
||||||
.Add(fSelectionRadio = new BRadioButton("fSelectionRadio",
|
const float spacing = be_control_look->DefaultItemSpacing();
|
||||||
"Use selection", NULL))
|
BView* layoutView = BGroupLayoutBuilder(B_VERTICAL, 5.0)
|
||||||
|
.SetInsets(spacing, spacing, spacing, spacing)
|
||||||
|
.Add(BGridLayoutBuilder()
|
||||||
|
.Add(fTextRadio = new BRadioButton("Use text:",
|
||||||
|
new BMessage(TOGGLE_FIND_CONTROL)), 0, 0)
|
||||||
|
.Add(fFindLabel = new BTextControl(NULL, NULL, NULL), 1, 0)
|
||||||
|
.Add(useSelection = new BRadioButton("Use selection",
|
||||||
|
new BMessage(TOGGLE_FIND_CONTROL)), 0, 1))
|
||||||
.Add(separator)
|
.Add(separator)
|
||||||
.Add(fForwardSearchBox = new BCheckBox("fForwardSearchBox",
|
.Add(fForwardSearchBox = new BCheckBox("Search forward"))
|
||||||
"Search forward", NULL))
|
.Add(fMatchCaseBox = new BCheckBox("Match case"))
|
||||||
.Add(fMatchCaseBox = new BCheckBox("fMatchCaseBox",
|
.Add(fMatchWordBox = new BCheckBox("Match word"))
|
||||||
"Match case", NULL))
|
.Add(fFindButton = new BButton("Find", new BMessage(MSG_FIND)))
|
||||||
.Add(fMatchWordBox = new BCheckBox("fMatchWordBox",
|
|
||||||
"Match word", NULL))
|
|
||||||
.Add(fFindButton = new BButton("fFindButton", "Find",
|
|
||||||
new BMessage(MSG_FIND)))
|
|
||||||
.End();
|
.End();
|
||||||
|
AddChild(layoutView);
|
||||||
AddChild(layoutView);
|
|
||||||
|
|
||||||
layoutView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
layoutView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
|
|
||||||
fFindLabel->SetDivider(0);
|
fFindLabel->SetDivider(0.0);
|
||||||
|
|
||||||
if (!findSelection)
|
if (!findSelection) {
|
||||||
fFindLabel->SetText(str.String());
|
fFindLabel->SetText(str.String());
|
||||||
fFindLabel->MakeFocus(true);
|
fFindLabel->MakeFocus(true);
|
||||||
|
} else {
|
||||||
|
fFindLabel->SetEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (findSelection)
|
if (findSelection)
|
||||||
fSelectionRadio->SetValue(B_CONTROL_ON);
|
useSelection->SetValue(B_CONTROL_ON);
|
||||||
else
|
else
|
||||||
fTextRadio->SetValue(B_CONTROL_ON);
|
fTextRadio->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
@@ -75,15 +78,14 @@ FindWindow::FindWindow(BMessenger messenger, BString &str,
|
|||||||
|
|
||||||
if (matchCase)
|
if (matchCase)
|
||||||
fMatchCaseBox->SetValue(B_CONTROL_ON);
|
fMatchCaseBox->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
if (matchWord)
|
if (matchWord)
|
||||||
fMatchWordBox->SetValue(B_CONTROL_ON);
|
fMatchWordBox->SetValue(B_CONTROL_ON);
|
||||||
|
|
||||||
fFindButton->MakeDefault(true);
|
fFindButton->MakeDefault(true);
|
||||||
|
|
||||||
AddShortcut((ulong)'W', (ulong)B_COMMAND_KEY,
|
AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE));
|
||||||
new BMessage(MSG_FIND_HIDE));
|
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +111,10 @@ FindWindow::MessageReceived(BMessage *msg)
|
|||||||
Quit();
|
Quit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TOGGLE_FIND_CONTROL:
|
||||||
|
fFindLabel->SetEnabled(fTextRadio->Value() == B_CONTROL_ON);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(msg);
|
BWindow::MessageReceived(msg);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -16,34 +16,35 @@ const ulong MSG_FIND = 'msgf';
|
|||||||
const ulong MSG_FIND_START = 'msac';
|
const ulong MSG_FIND_START = 'msac';
|
||||||
const ulong MSG_FIND_CLOSED = 'mfcl';
|
const ulong MSG_FIND_CLOSED = 'mfcl';
|
||||||
|
|
||||||
|
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
class BRadioButton;
|
class BRadioButton;
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
|
|
||||||
|
|
||||||
class FindWindow : public BWindow {
|
class FindWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
FindWindow (BMessenger messenger, BString &str,
|
FindWindow (BMessenger messenger, const BString& str,
|
||||||
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch);
|
bool findSelection, bool matchWord,
|
||||||
virtual ~FindWindow();
|
bool matchCase, bool forwardSearch);
|
||||||
|
virtual ~FindWindow();
|
||||||
|
|
||||||
virtual void Quit();
|
virtual void Quit();
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage* msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _SendFindMessage();
|
void _SendFindMessage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTextControl *fFindLabel;
|
BTextControl* fFindLabel;
|
||||||
BRadioButton *fTextRadio;
|
BRadioButton* fTextRadio;
|
||||||
BRadioButton *fSelectionRadio;
|
|
||||||
|
|
||||||
BCheckBox *fForwardSearchBox;
|
|
||||||
BCheckBox *fMatchCaseBox;
|
|
||||||
BCheckBox *fMatchWordBox;
|
|
||||||
BButton *fFindButton;
|
|
||||||
|
|
||||||
BString *fFindString;
|
BCheckBox* fForwardSearchBox;
|
||||||
BMessenger fFindDlgMessenger;
|
BCheckBox* fMatchCaseBox;
|
||||||
|
BCheckBox* fMatchWordBox;
|
||||||
|
BButton* fFindButton;
|
||||||
|
|
||||||
|
BMessenger fFindDlgMessenger;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FINDDLG_H_INCLUDED
|
#endif // FINDDLG_H_INCLUDED
|
||||||
|
|||||||
Reference in New Issue
Block a user