linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #00607
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2112: starting changes for common text-box menus
------------------------------------------------------------
revno: 2112
committer: poy <poy@xxxxxxxxxx>
branch nick: repo
timestamp: Fri 2010-03-26 18:15:26 +0100
message:
starting changes for common text-box menus
removed:
win32/TextBox.cpp
win32/TextBox.h
modified:
dwt/include/dwt/widgets/RichTextBox.h
dwt/include/dwt/widgets/TextBox.h
dwt/src/widgets/RichTextBox.cpp
win32/AspectChat.h
win32/NotepadFrame.cpp
win32/RichTextBox.cpp
win32/RichTextBox.h
win32/SystemFrame.cpp
win32/WinUtil.cpp
win32/WinUtil.h
win32/stdafx.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/RichTextBox.h'
--- dwt/include/dwt/widgets/RichTextBox.h 2010-02-11 21:44:13 +0000
+++ dwt/include/dwt/widgets/RichTextBox.h 2010-03-26 17:15:26 +0000
@@ -117,7 +117,7 @@
void setScrollPos(Point& scrollPos);
- tstring textUnderCursor(const ScreenCoordinate& p);
+ tstring textUnderCursor(const ScreenCoordinate& p, bool includeSpaces = false);
void setText(const tstring& txt);
=== modified file 'dwt/include/dwt/widgets/TextBox.h'
--- dwt/include/dwt/widgets/TextBox.h 2010-03-06 22:24:26 +0000
+++ dwt/include/dwt/widgets/TextBox.h 2010-03-26 17:15:26 +0000
@@ -156,6 +156,8 @@
unsigned getLineCount() const;
+ virtual tstring textUnderCursor(const ScreenCoordinate& p, bool includeSpaces = false) = 0;
+
void setModify(bool modify = false);
bool getModify();
=== modified file 'dwt/src/widgets/RichTextBox.cpp'
--- dwt/src/widgets/RichTextBox.cpp 2010-03-06 22:24:26 +0000
+++ dwt/src/widgets/RichTextBox.cpp 2010-03-26 17:15:26 +0000
@@ -131,16 +131,17 @@
sendMessage(EM_SETSCROLLPOS, 0, reinterpret_cast< LPARAM >(&scrollPos));
}
-tstring RichTextBox::textUnderCursor(const ScreenCoordinate& p) {
+tstring RichTextBox::textUnderCursor(const ScreenCoordinate& p, bool includeSpaces) {
tstring tmp = getText();
- tstring::size_type start = tmp.find_last_of(_T(" <\t\r\n"), fixupLineEndings(tmp.begin(), tmp.end(), charFromPos(p)));
+ tstring::size_type start = tmp.find_last_of(includeSpaces ? _T("<\t\r\n") : _T(" <\t\r\n"),
+ fixupLineEndings(tmp.begin(), tmp.end(), charFromPos(p)));
if(start == tstring::npos)
start = 0;
else
start++;
- tstring::size_type end = tmp.find_first_of(_T(" >\t\r\n"), start + 1);
+ tstring::size_type end = tmp.find_first_of(includeSpaces ? _T(">\t\r\n") : _T(" >\t\r\n"), start + 1);
if(end == tstring::npos)
end = tmp.size();
=== modified file 'win32/AspectChat.h'
--- win32/AspectChat.h 2010-03-20 17:04:00 +0000
+++ win32/AspectChat.h 2010-03-26 17:15:26 +0000
@@ -44,6 +44,7 @@
cs.style |= ES_READONLY;
chat = t().addChild(cs);
chat->setTextLimit(32768);
+ WinUtil::handleDblClicks(chat);
}
{
=== modified file 'win32/NotepadFrame.cpp'
--- win32/NotepadFrame.cpp 2010-02-14 16:06:46 +0000
+++ win32/NotepadFrame.cpp 2010-03-26 17:15:26 +0000
@@ -35,6 +35,7 @@
cs.style |= WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_NOHIDESEL | ES_WANTRETURN;
pad = addChild(cs);
addWidget(pad, false, false);
+ WinUtil::handleDblClicks(pad);
}
initStatus();
=== modified file 'win32/RichTextBox.cpp'
--- win32/RichTextBox.cpp 2010-03-06 22:24:26 +0000
+++ win32/RichTextBox.cpp 2010-03-26 17:15:26 +0000
@@ -29,7 +29,6 @@
}
RichTextBox::RichTextBox(dwt::Widget* parent) : BaseType(parent) {
- onLeftMouseDblClick(std::tr1::bind(&RichTextBox::handleLeftDblClick, this, _1));
}
bool RichTextBox::handleMessage(const MSG& msg, LRESULT& retVal) {
@@ -82,14 +81,34 @@
return false;
}
+#define ID_EDIT_CLEAR 0xE120
+#define ID_EDIT_CLEAR_ALL 0xE121
+#define ID_EDIT_COPY 0xE122
+#define ID_EDIT_CUT 0xE123
+#define ID_EDIT_FIND 0xE124
+#define ID_EDIT_PASTE 0xE125
+#define ID_EDIT_PASTE_LINK 0xE126
+#define ID_EDIT_PASTE_SPECIAL 0xE127
+#define ID_EDIT_REPEAT 0xE128
+#define ID_EDIT_REPLACE 0xE129
+#define ID_EDIT_SELECT_ALL 0xE12A
+#define ID_EDIT_UNDO 0xE12B
+#define ID_EDIT_REDO 0xE12C
+
bool RichTextBox::handleContextMenu(dwt::ScreenCoordinate pt) {
if(pt.x() == -1 || pt.y() == -1) {
pt = getContextMenuPos();
}
- // This context menu is specialized for non-user-modifiable controls.
- /// @todo add other commands depending on whether the style has ES_READONLY
+ const bool writable = !hasStyle(ES_READONLY);
+
MenuPtr menu(dwt::WidgetCreator<Menu>::create(getParent(), WinUtil::Seeds::menu));
+ if(writable) {
+ menu->appendItem(T_("&Undo\tCtrl+Z"),
+ std::tr1::bind(&RichTextBox::sendMessage, this, WM_COMMAND, MAKEWPARAM(ID_EDIT_UNDO, 0), 0),
+ dwt::IconPtr(), sendMessage(EM_CANUNDO));
+ menu->appendSeparator();
+ }
menu->appendItem(T_("&Copy\tCtrl+C"), std::tr1::bind(&RichTextBox::handleCopy, this));
menu->appendSeparator();
menu->appendItem(T_("&Find...\tF3"), std::tr1::bind(&RichTextBox::handleFind, this));
@@ -120,7 +139,3 @@
void RichTextBox::findTextNext() {
findText(currentNeedle.empty() ? findTextPopup() : currentNeedle);
}
-
-bool RichTextBox::handleLeftDblClick(const dwt::MouseEvent& ev) {
- return WinUtil::parseDBLClick(textUnderCursor(ev.pos));
-}
=== modified file 'win32/RichTextBox.h'
--- win32/RichTextBox.h 2010-02-11 21:44:13 +0000
+++ win32/RichTextBox.h 2010-03-26 17:15:26 +0000
@@ -19,7 +19,7 @@
#ifndef DCPLUSPLUS_WIN32_RichTextBox_H_
#define DCPLUSPLUS_WIN32_RichTextBox_H_
-/** Our own flavour of rich text boxes that handle double clicks and have fancy menus */
+/// our rich text boxes that provide find functions
class RichTextBox : public dwt::RichTextBox {
typedef dwt::RichTextBox BaseType;
friend class dwt::WidgetCreator<RichTextBox>;
@@ -44,7 +44,6 @@
private:
bool handleKeyDown(int c);
bool handleContextMenu(dwt::ScreenCoordinate pt);
- bool handleLeftDblClick(const dwt::MouseEvent& ev);
void handleCopy();
void handleFind();
=== modified file 'win32/SystemFrame.cpp'
--- win32/SystemFrame.cpp 2010-03-06 22:24:26 +0000
+++ win32/SystemFrame.cpp 2010-03-26 17:15:26 +0000
@@ -39,6 +39,7 @@
addWidget(log);
log->onContextMenu(std::tr1::bind(&SystemFrame::handleContextMenu, this, _1));
log->onLeftMouseDblClick(std::tr1::bind(&SystemFrame::handleDoubleClick, this, _1));
+ WinUtil::handleDblClicks(log);
}
initStatus();
=== removed file 'win32/TextBox.cpp'
--- win32/TextBox.cpp 2010-02-11 21:44:13 +0000
+++ win32/TextBox.cpp 1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2001-2010 Jacek Sieka, arnetheduck on gmail point com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "stdafx.h"
-
-#include "TextBox.h"
-
-#include "WinUtil.h"
-
-TextBox::Seed::Seed(const tstring& caption) :
- BaseType::Seed(caption)
-{
-}
-
-TextBox::TextBox( dwt::Widget * parent ) : BaseType(parent) {
- this->onLeftMouseDblClick(std::tr1::bind(&TextBox::handleLeftDblClick, this, _1));
-
- /*
- * unlike usual controls, the edit control doesn't send WM_INITMENUPOPUP when its standard
- * menu is being opened. however, we can catch WM_ENTERIDLE and sub-class the menu then.
- *
- * method described by Jeff Partch in http://groups.google.com/group/microsoft.public.vc.mfc/msg/5e07dc60be3d3baa
- */
- this->onRaw(std::tr1::bind(&TextBox::handleEnterIdle, this, _1, _2), dwt::Message(WM_ENTERIDLE));
- this->onRaw(std::tr1::bind(&TextBox::handleMenuSelect, this, _1, _2), dwt::Message(WM_MENUSELECT));
-}
-
-bool TextBox::handleLeftDblClick(const dwt::MouseEvent& ev) {
- return WinUtil::parseDBLClick(textUnderCursor(ev.pos));
-}
-
-LRESULT TextBox::handleEnterIdle(WPARAM wParam, LPARAM lParam) {
- if(wParam == MSGF_MENU && !menu) {
- GUITHREADINFO gti = { sizeof(gti) };
- if(::GetGUIThreadInfo(NULL, >i) && (gti.flags & GUI_POPUPMENUMODE) && (gti.hwndMenuOwner == handle())) {
- HMENU hMenu = reinterpret_cast<HMENU>(::SendMessage(reinterpret_cast<HWND>(lParam), MN_GETHMENU, 0, 0));
- if(!hMenu)
- return 0;
- menu = dwt::WidgetCreator<dwt::Menu>::attach(this, hMenu, WinUtil::Seeds::menu);
- }
- }
- return 0;
-}
-
-LRESULT TextBox::handleMenuSelect(WPARAM wParam, LPARAM lParam) {
- if((HIWORD(wParam) == 0xFFFF) && (lParam == 0))
- menu.reset();
- return 0;
-}
=== removed file 'win32/TextBox.h'
--- win32/TextBox.h 2010-02-11 21:44:13 +0000
+++ win32/TextBox.h 1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2001-2010 Jacek Sieka, arnetheduck on gmail point com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef DCPLUSPLUS_WIN32_TextBox_H_
-#define DCPLUSPLUS_WIN32_TextBox_H_
-
-/** Our own flavour of text boxes that handle double clicks and have fancy menus */
-class TextBox : public dwt::TextBox {
- typedef dwt::TextBox BaseType;
- friend class dwt::WidgetCreator<TextBox>;
-public:
- typedef TextBox ThisType;
-
- typedef ThisType* ObjectType;
-
- struct Seed : public BaseType::Seed {
- typedef ThisType WidgetType;
-
- Seed(const tstring& caption = tstring());
- };
-
- explicit TextBox( dwt::Widget * parent );
-
-private:
- bool handleLeftDblClick(const dwt::MouseEvent& ev);
-
- LRESULT handleEnterIdle(WPARAM wParam, LPARAM lParam);
- LRESULT handleMenuSelect(WPARAM wParam, LPARAM lParam);
-
- dwt::Menu::ObjectType menu;
-};
-
-typedef TextBox::ObjectType TextBoxPtr;
-
-#endif /*TextBox_H_*/
=== modified file 'win32/WinUtil.cpp'
--- win32/WinUtil.cpp 2010-03-20 16:51:58 +0000
+++ win32/WinUtil.cpp 2010-03-26 17:15:26 +0000
@@ -310,6 +310,14 @@
return true;
}
+void WinUtil::handleDblClicks(dwt::TextBoxBase* box) {
+ box->onLeftMouseDblClick(std::tr1::bind(&WinUtil::handleBoxDblClick, box, _1));
+}
+
+bool WinUtil::handleBoxDblClick(dwt::TextBoxBase* box, const dwt::MouseEvent& ev) {
+ return parseDBLClick(box->textUnderCursor(ev.pos));
+}
+
#define LINE2 _T("-- http://dcplusplus.sourceforge.net <DC++ ") _T(VERSIONSTRING) _T(">")
const TCHAR
*msgs[] = {
=== modified file 'win32/WinUtil.h'
--- win32/WinUtil.h 2010-02-14 16:06:46 +0000
+++ win32/WinUtil.h 2010-03-26 17:15:26 +0000
@@ -101,6 +101,7 @@
static void setStaticWindowState(const string& id, bool open);
static bool checkNick();
+ static void handleDblClicks(dwt::TextBoxBase* box);
/**
* Check if this is a common /-command.
@@ -219,6 +220,8 @@
#endif
private:
+ static bool handleBoxDblClick(dwt::TextBoxBase* box, const dwt::MouseEvent& ev);
+
static void init_helpPath();
static DWORD helpCookie;
=== modified file 'win32/stdafx.h'
--- win32/stdafx.h 2010-02-11 21:44:13 +0000
+++ win32/stdafx.h 2010-03-26 17:15:26 +0000
@@ -54,14 +54,6 @@
#include <dwt/widgets/ToolTip.h>
#include <dwt/widgets/Window.h>
-#ifdef PORT_ME
-
-// Fix nt4 startup
-#include <multimon.h>
-
-
-#endif
-
using namespace dcpp;
using dwt::Button;
@@ -92,6 +84,8 @@
using dwt::SpinnerPtr;
using dwt::TabView;
using dwt::TabViewPtr;
+using dwt::TextBox;
+using dwt::TextBoxPtr;
using dwt::ToolBar;
using dwt::ToolBarPtr;
using dwt::Tree;
@@ -118,7 +112,6 @@
#endif
#endif
-#include "TextBox.h"
#include "ComboBox.h"
#include "RichTextBox.h"
#include "ShellMenu.h"