Added escape key support in the find window (pirated from StyledEdit :-)).
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32393 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007, Haiku, Inc.
|
* 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
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, B_NOT_RESIZABLE|B_NOT_ZOOMABLE),
|
: BWindow(frame, "Find", B_FLOATING_WINDOW, B_NOT_RESIZABLE|B_NOT_ZOOMABLE),
|
||||||
fFindDlgMessenger(messenger)
|
fFindDlgMessenger(messenger)
|
||||||
@@ -53,16 +53,16 @@ FindWindow::FindWindow (BRect frame, BMessenger messenger , BString &str,
|
|||||||
|
|
||||||
//Divider
|
//Divider
|
||||||
float dividerHeight = (selectionRadioBottom + forwardSearchTop) / 2;
|
float dividerHeight = (selectionRadioBottom + forwardSearchTop) / 2;
|
||||||
|
|
||||||
//Button Coordinates
|
//Button Coordinates
|
||||||
float searchButtonLeft = (frame.Width() - fFindView->StringWidth("Find") - 60) / 2;
|
float searchButtonLeft = (frame.Width() - fFindView->StringWidth("Find") - 60) / 2;
|
||||||
float searchButtonRight = searchButtonLeft + fFindView->StringWidth("Find") + 60;
|
float searchButtonRight = searchButtonLeft + fFindView->StringWidth("Find") + 60;
|
||||||
|
|
||||||
//Build the Views
|
//Build the Views
|
||||||
fTextRadio = new BRadioButton(BRect(14, textRadioTop, textRadioRight, textRadioBottom),
|
fTextRadio = new BRadioButton(BRect(14, textRadioTop, textRadioRight, textRadioBottom),
|
||||||
"fTextRadio", "Use Text: ", NULL);
|
"fTextRadio", "Use Text: ", NULL);
|
||||||
fFindView->AddChild(fTextRadio);
|
fFindView->AddChild(fTextRadio);
|
||||||
|
|
||||||
fFindLabel = new BTextControl(BRect(textRadioRight + 4, textRadioTop, frame.Width() - 14, textRadioBottom),
|
fFindLabel = new BTextControl(BRect(textRadioRight + 4, textRadioTop, frame.Width() - 14, textRadioBottom),
|
||||||
"fFindLabel", "", "", NULL);
|
"fFindLabel", "", "", NULL);
|
||||||
fFindLabel->SetDivider(0);
|
fFindLabel->SetDivider(0);
|
||||||
@@ -74,7 +74,7 @@ FindWindow::FindWindow (BRect frame, BMessenger messenger , BString &str,
|
|||||||
fSelectionRadio = new BRadioButton(BRect(14, selectionRadioTop, frame.Width() - 14, selectionRadioBottom),
|
fSelectionRadio = new BRadioButton(BRect(14, selectionRadioTop, frame.Width() - 14, selectionRadioBottom),
|
||||||
"fSelectionRadio", "Use Selection", NULL);
|
"fSelectionRadio", "Use Selection", NULL);
|
||||||
fFindView->AddChild(fSelectionRadio);
|
fFindView->AddChild(fSelectionRadio);
|
||||||
|
|
||||||
if (findSelection)
|
if (findSelection)
|
||||||
fSelectionRadio->SetValue(B_CONTROL_ON);
|
fSelectionRadio->SetValue(B_CONTROL_ON);
|
||||||
else
|
else
|
||||||
@@ -82,30 +82,30 @@ FindWindow::FindWindow (BRect frame, BMessenger messenger , BString &str,
|
|||||||
|
|
||||||
fSeparator = new BBox(BRect(6, dividerHeight, frame.Width() - 6, dividerHeight + 1));
|
fSeparator = new BBox(BRect(6, dividerHeight, frame.Width() - 6, dividerHeight + 1));
|
||||||
fFindView->AddChild(fSeparator);
|
fFindView->AddChild(fSeparator);
|
||||||
|
|
||||||
fForwardSearchBox = new BCheckBox(BRect(14, forwardSearchTop, frame.Width() - 14, forwardSearchBottom),
|
fForwardSearchBox = new BCheckBox(BRect(14, forwardSearchTop, frame.Width() - 14, forwardSearchBottom),
|
||||||
"fForwardSearchBox", "Search Forward", NULL);
|
"fForwardSearchBox", "Search Forward", NULL);
|
||||||
fFindView->AddChild(fForwardSearchBox);
|
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 = new BCheckBox(BRect(14, matchCaseTop, frame.Width() - 14, matchCaseBottom),
|
||||||
"fMatchCaseBox", "Match Case", NULL);
|
"fMatchCaseBox", "Match Case", NULL);
|
||||||
fFindView->AddChild(fMatchCaseBox);
|
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 = new BCheckBox(BRect(14, matchWordTop, frame.Width() - 14, matchWordBottom),
|
||||||
"fMatchWordBox", "Match Word", NULL);
|
"fMatchWordBox", "Match Word", NULL);
|
||||||
fFindView->AddChild(fMatchWordBox);
|
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 = new BButton(BRect(searchButtonLeft, buttonsTop, searchButtonRight, frame.Height() - 14),
|
||||||
"fFindButton", "Find", new BMessage(MSG_FIND));
|
"fFindButton", "Find", new BMessage(MSG_FIND));
|
||||||
fFindButton->MakeDefault(true);
|
fFindButton->MakeDefault(true);
|
||||||
fFindView->AddChild(fFindButton);
|
fFindView->AddChild(fFindButton);
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +138,23 @@ FindWindow::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FindWindow::DispatchMessage(BMessage *message, BHandler *handler)
|
||||||
|
{
|
||||||
|
if (message->what == B_KEY_DOWN) {
|
||||||
|
int8 key;
|
||||||
|
if (message->FindInt8("byte", 0, &key) == B_OK) {
|
||||||
|
if (key == B_ESCAPE) {
|
||||||
|
message->MakeEmpty();
|
||||||
|
message->what = B_QUIT_REQUESTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BWindow::DispatchMessage(message, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FindWindow::Quit()
|
FindWindow::Quit()
|
||||||
{
|
{
|
||||||
@@ -156,12 +173,12 @@ FindWindow::_SendFindMessage()
|
|||||||
message.AddBool("findselection", false);
|
message.AddBool("findselection", false);
|
||||||
} else
|
} else
|
||||||
message.AddBool("findselection", true);
|
message.AddBool("findselection", true);
|
||||||
|
|
||||||
//Add the other parameters
|
//Add the other parameters
|
||||||
message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON);
|
message.AddBool("usetext", fTextRadio->Value() == B_CONTROL_ON);
|
||||||
message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON);
|
message.AddBool("forwardsearch", fForwardSearchBox->Value() == B_CONTROL_ON);
|
||||||
message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON);
|
message.AddBool("matchcase", fMatchCaseBox->Value() == B_CONTROL_ON);
|
||||||
message.AddBool("matchword", fMatchWordBox->Value() == B_CONTROL_ON);
|
message.AddBool("matchword", fMatchWordBox->Value() == B_CONTROL_ON);
|
||||||
|
|
||||||
fFindDlgMessenger.SendMessage(&message);
|
fFindDlgMessenger.SendMessage(&message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007, Haiku, Inc.
|
* 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.
|
||||||
*/
|
*/
|
||||||
#ifndef FINDDLG_H_INCLUDED
|
#ifndef FINDDLG_H_INCLUDED
|
||||||
@@ -23,12 +23,13 @@ class BCheckBox;
|
|||||||
|
|
||||||
class FindWindow : public BWindow {
|
class FindWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
FindWindow (BRect frame, BMessenger messenger, BString &str,
|
FindWindow (BRect frame, BMessenger messenger, BString &str,
|
||||||
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch);
|
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch);
|
||||||
virtual ~FindWindow();
|
virtual ~FindWindow();
|
||||||
|
|
||||||
virtual void Quit();
|
virtual void Quit();
|
||||||
virtual void MessageReceived(BMessage *msg);
|
virtual void MessageReceived(BMessage *msg);
|
||||||
|
virtual void DispatchMessage(BMessage* message, BHandler* handler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _SendFindMessage();
|
void _SendFindMessage();
|
||||||
|
|||||||
Reference in New Issue
Block a user