linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #02084
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2254: simplify text-box menu customization
------------------------------------------------------------
revno: 2254
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-10-07 18:40:23 +0200
message:
simplify text-box menu customization
modified:
dwt/include/dwt/widgets/TextBox.h
dwt/src/widgets/TextBox.cpp
win32/HubFrame.cpp
win32/PrivateFrame.cpp
win32/RichTextBox.cpp
win32/RichTextBox.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dwt/include/dwt/widgets/TextBox.h'
--- dwt/include/dwt/widgets/TextBox.h 2010-03-26 21:55:05 +0000
+++ dwt/include/dwt/widgets/TextBox.h 2010-10-07 16:40:23 +0000
@@ -171,7 +171,7 @@
virtual Point getPreferedSize();
- virtual void addCommands(MenuPtr menu);
+ virtual MenuPtr getMenu();
virtual bool handleMessage(const MSG& msg, LRESULT& retVal);
=== modified file 'dwt/src/widgets/TextBox.cpp'
--- dwt/src/widgets/TextBox.cpp 2010-09-27 20:29:29 +0000
+++ dwt/src/widgets/TextBox.cpp 2010-10-07 16:40:23 +0000
@@ -177,11 +177,13 @@
return ret;
}
-void TextBoxBase::addCommands(MenuPtr menu) {
+MenuPtr TextBoxBase::getMenu() {
const bool writable = !hasStyle(ES_READONLY);
const bool text = !getText().empty();
const bool selection = !getSelection().empty();
+ MenuPtr menu(WidgetCreator<Menu>::create(getParent(), menuSeed));
+
if(writable) {
menu->appendItem(Texts::get(Texts::undo), [this] { this->sendMessage(WM_UNDO); },
IconPtr(), sendMessage(EM_CANUNDO));
@@ -199,6 +201,8 @@
menu->appendSeparator();
menu->appendItem(Texts::get(Texts::selAll), [this] { this->setSelection(0, -1);},
IconPtr(), text);
+
+ return menu;
}
bool TextBoxBase::handleMessage(const MSG& msg, LRESULT& retVal) {
@@ -223,9 +227,7 @@
pt = getContextMenuPos();
}
- MenuPtr menu(WidgetCreator<Menu>::create(getParent(), menuSeed));
- addCommands(menu);
- menu->open(pt);
+ getMenu()->open(pt);
return true;
}
=== modified file 'win32/HubFrame.cpp'
--- win32/HubFrame.cpp 2010-09-09 18:16:26 +0000
+++ win32/HubFrame.cpp 2010-10-07 16:40:23 +0000
@@ -1090,9 +1090,7 @@
if(userClick(pt) && handleUsersContextMenu(pt))
return true;
- // imitate TextBoxBase's menu creation
- MenuPtr menu(dwt::WidgetCreator<Menu>::create(chat->getParent(), WinUtil::Seeds::menu));
- chat->addCommands(menu);
+ MenuPtr menu = chat->getMenu();
prepareMenu(menu, UserCommand::CONTEXT_HUB, url);
=== modified file 'win32/PrivateFrame.cpp'
--- win32/PrivateFrame.cpp 2010-07-10 14:36:48 +0000
+++ win32/PrivateFrame.cpp 2010-10-07 16:40:23 +0000
@@ -324,9 +324,7 @@
pt = chat->getContextMenuPos();
}
- // imitate TextBoxBase's menu creation
- MenuPtr menu(dwt::WidgetCreator<Menu>::create(chat->getParent(), WinUtil::Seeds::menu));
- chat->addCommands(menu);
+ MenuPtr menu = chat->getMenu();
prepareMenu(menu, UserCommand::CONTEXT_USER, ClientManager::getInstance()->getHubs(replyTo.getUser().user->getCID(),
replyTo.getUser().hint, priv));
=== modified file 'win32/RichTextBox.cpp'
--- win32/RichTextBox.cpp 2010-10-02 22:00:14 +0000
+++ win32/RichTextBox.cpp 2010-10-07 16:40:23 +0000
@@ -58,11 +58,13 @@
return false;
}
-void RichTextBox::addCommands(MenuPtr menu) {
- BaseType::addCommands(menu);
+MenuPtr RichTextBox::getMenu() {
+ MenuPtr menu = BaseType::getMenu();
menu->appendSeparator();
- menu->appendItem(T_("&Find...\tF3"), std::bind(&RichTextBox::handleFind, this), dwt::IconPtr(), !getText().empty());
+ menu->appendItem(T_("&Find...\tF3"), [this]() { findText(findTextPopup()); }, dwt::IconPtr(), !getText().empty());
+
+ return menu;
}
bool RichTextBox::handleKeyDown(int c) {
@@ -79,10 +81,6 @@
return false;
}
-void RichTextBox::handleFind() {
- findText(findTextPopup());
-}
-
tstring RichTextBox::findTextPopup() {
tstring param = Util::emptyStringT;
ParamDlg lineFind(this, T_("Search"), T_("Specify search string"), Util::emptyStringT, false);
=== modified file 'win32/RichTextBox.h'
--- win32/RichTextBox.h 2010-10-02 22:00:14 +0000
+++ win32/RichTextBox.h 2010-10-07 16:40:23 +0000
@@ -38,7 +38,7 @@
bool handleMessage(const MSG& msg, LRESULT& retVal);
- void addCommands(MenuPtr menu);
+ MenuPtr getMenu();
tstring findTextPopup();
void findTextNext();