From b9879bc7ee0c20075abcd4e2bbcc6037ecb33859 Mon Sep 17 00:00:00 2001 From: Ada Majorek Date: Sun, 2 Apr 2017 09:41:14 -0700 Subject: [PATCH 1/3] Popup Feature for supporting an Extended Display (Dual Monitor) (#112) Broke out the edit window into a newly created popup window. A timer in the main dasher grabs the current display text on the edit window and presents it on the popup window. Preference Page also added and a Quick Mode button on the tool bar. Preferences include font size, window placement, and auto detect additional monitors. **Not the most efficient implementation- enhancements will follow. --- Src/Common/AppSettingsData.h | 7 +- Src/Common/AppSettingsHeader.h | 8 +- Src/Win32/Dasher.cpp | 11 +- Src/Win32/Dasher.h | 9 +- Src/Win32/Dasher.rc | 28 +++ Src/Win32/Dasher.vcxproj | 4 + Src/Win32/DasherWindow.cpp | 38 +++- Src/Win32/DasherWindow.h | 7 + Src/Win32/UpgradeLog.htm | Bin 0 -> 38574 bytes Src/Win32/Widgets/AdvancedPage.cpp | 2 +- Src/Win32/Widgets/Edit.cpp | 7 + Src/Win32/Widgets/Edit.h | 4 +- Src/Win32/Widgets/Popup.cpp | 301 +++++++++++++++++++++++++++++ Src/Win32/Widgets/Popup.h | 110 +++++++++++ Src/Win32/Widgets/PopupPage.cpp | 198 +++++++++++++++++++ Src/Win32/Widgets/PopupPage.h | 38 ++++ Src/Win32/Widgets/Prefs.cpp | 14 +- Src/Win32/Widgets/Prefs.h | 2 + Src/Win32/Widgets/Toolbar.cpp | 9 +- Src/Win32/Widgets/ViewPage.cpp | 1 - Src/Win32/resource.h | 14 +- 21 files changed, 788 insertions(+), 24 deletions(-) create mode 100644 Src/Win32/UpgradeLog.htm create mode 100644 Src/Win32/Widgets/Popup.cpp create mode 100644 Src/Win32/Widgets/Popup.h create mode 100644 Src/Win32/Widgets/PopupPage.cpp create mode 100644 Src/Win32/Widgets/PopupPage.h diff --git a/Src/Common/AppSettingsData.h b/Src/Common/AppSettingsData.h index 5beddc2dc..3aaed26a9 100644 --- a/Src/Common/AppSettingsData.h +++ b/Src/Common/AppSettingsData.h @@ -26,7 +26,10 @@ Dasher::Settings::bp_table app_boolparamtable[] = { { APP_BP_TIME_STAMP, "TimeStampNewFiles", Persistence::PERSISTENT, true, "TimeStampNewFiles" }, { APP_BP_CONFIRM_UNSAVED, "ConfirmUnsavedFiles", Persistence::PERSISTENT, true, "ConfirmUnsavedFiles" }, - {APP_BP_SHOW_TOOLBAR, "ViewToolbar", Persistence::PERSISTENT, true, "ViewToolbar"}, + { APP_BP_SHOW_TOOLBAR, "ViewToolbar", Persistence::PERSISTENT, true, "ViewToolbar"}, + { APP_BP_POPUP_ENABLE, "PopupEnable", Persistence::PERSISTENT, false, "PopupEnable"}, + { APP_BP_POPUP_EXTERNAL_SCREEN, "PopupFullScreen", Persistence::PERSISTENT, false, "PopupFullScreen"}, + { APP_BP_POPUP_INFRONT, "PopupInfront", Persistence::PERSISTENT, false, "PopupInfront"}, #ifdef WITH_MAEMO { APP_BP_SHOW_STATUSBAR, "ViewStatusbar", Persistence::PERSISTENT, false, "ViewStatusbar" }, #else @@ -39,6 +42,7 @@ Dasher::Settings::bp_table app_boolparamtable[] = { Dasher::Settings::lp_table app_longparamtable[] = { {APP_LP_FILE_ENCODING, "FileEncodingFormat", Persistence::PERSISTENT, -1, "FileEncodingFormat"}, {APP_LP_EDIT_FONT_SIZE, "EditFontSize", Persistence::PERSISTENT, 0, "EditFontSize"}, + {APP_LP_POPUP_FONT_SIZE, "PopupFontSize", Persistence::PERSISTENT, 0, "PopupFontSize"}, {APP_LP_EDIT_SIZE, "EditSize", Persistence::PERSISTENT, 75, "The size of the edit window"}, {APP_LP_SCREEN_WIDTH, "ScreenWidth", Persistence::PERSISTENT, 400, "ScreenWidth"}, {APP_LP_SCREEN_HEIGHT, "ScreenHeight", Persistence::PERSISTENT, 500, "ScreenHeight"}, @@ -55,6 +59,7 @@ Dasher::Settings::sp_table app_stringparamtable[] = { {APP_SP_EDIT_FONT, "EditFont", Persistence::PERSISTENT, "Sans 20", "EditFont"}, #else {APP_SP_EDIT_FONT, "EditFont", Persistence::PERSISTENT, "Sans 10", "EditFont"}, + {APP_SP_POPUP_FONT, "PopupFont", Persistence::PERSISTENT, "Sans 10", "PopupFont"}, #endif { APP_SP_TOOLBAR_ID, "ToolbarID", Persistence::PERSISTENT, "", "ToolbarID" }, }; diff --git a/Src/Common/AppSettingsHeader.h b/Src/Common/AppSettingsHeader.h index bde7e7e21..20f9d068a 100644 --- a/Src/Common/AppSettingsHeader.h +++ b/Src/Common/AppSettingsHeader.h @@ -8,11 +8,14 @@ enum { APP_BP_TIME_STAMP = END_OF_SPS, APP_BP_CONFIRM_UNSAVED, APP_BP_SHOW_TOOLBAR, - APP_BP_SHOW_STATUSBAR, APP_BP_MIRROR_LAYOUT, APP_BP_FULL_SCREEN, END_OF_APP_BPS + APP_BP_SHOW_STATUSBAR, APP_BP_MIRROR_LAYOUT, APP_BP_FULL_SCREEN, + APP_BP_POPUP_ENABLE, APP_BP_POPUP_EXTERNAL_SCREEN, APP_BP_POPUP_INFRONT, + END_OF_APP_BPS }; enum { APP_LP_FILE_ENCODING = END_OF_APP_BPS, APP_LP_EDIT_FONT_SIZE, // TODO Extract font size from APP_SP_EDIT_FONT as linux + APP_LP_POPUP_FONT_SIZE, APP_LP_EDIT_SIZE, APP_LP_SCREEN_WIDTH, APP_LP_SCREEN_HEIGHT, APP_LP_STYLE, APP_LP_X, APP_LP_Y, @@ -23,7 +26,8 @@ enum { }; enum { - APP_SP_EDIT_FONT = END_OF_APP_LPS, + APP_SP_EDIT_FONT = END_OF_APP_LPS, + APP_SP_POPUP_FONT, APP_SP_TOOLBAR_ID, END_OF_APP_SPS }; diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp index f515d3873..1728f2dcf 100644 --- a/Src/Win32/Dasher.cpp +++ b/Src/Win32/Dasher.cpp @@ -10,6 +10,7 @@ #include "DasherMouseInput.h" #include "DasherWindow.h" #include "Widgets/Edit.h" +#include "Widgets/Popup.h" #include "Sockets/SocketInput.h" #include "BTSocketInput.h" @@ -26,8 +27,8 @@ using namespace WinUTF8; CONST UINT WM_DASHER_FOCUS = RegisterWindowMessage(L"WM_DASHER_FOCUS"); -CDasher::CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, Dasher::CSettingsStore* settings, CFileUtils* fileUtils) - : CDashIntfScreenMsgs(settings, fileUtils), m_hParent(Parent), m_pWindow(pWindow), m_pEdit(pEdit) { +CDasher::CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, CPopup *pPopup, Dasher::CSettingsStore* settings, CFileUtils* fileUtils) + : CDashIntfScreenMsgs(settings, fileUtils), m_hParent(Parent), m_pWindow(pWindow), m_pEdit(pEdit), m_pPopup(pPopup) { // This class will be a wrapper for the Dasher 'control' - think ActiveX // Set up COM for the accessibility stuff @@ -109,6 +110,7 @@ void Dasher::CDasher::HandleEvent(int iParameter) { CDashIntfScreenMsgs::HandleEvent(iParameter); m_pWindow->HandleParameterChange(iParameter); m_pEdit->HandleParameterChange(iParameter); + m_pPopup->HandleParameterChange(iParameter); if (iParameter == SP_DASHER_FONT) m_pCanvas->SetFont(GetStringParameter(SP_DASHER_FONT)); } @@ -350,3 +352,8 @@ int CDasher::GetAllContextLenght(){ std::string CDasher::GetTextAroundCursor(CControlManager::EditDistance iDist) { return m_pEdit->GetTextAroundCursor(iDist); } + +void CDasher::configurePopupTimer(bool enable) { + //Timer is managed by the window object + m_pWindow->configurePopupTimer(enable); +} \ No newline at end of file diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h index fce443a4f..63e1370af 100644 --- a/Src/Win32/Dasher.h +++ b/Src/Win32/Dasher.h @@ -15,6 +15,7 @@ extern CONST UINT WM_DASHER_FOCUS; class CCanvas; class CEdit; +class CPopup; class CDasherWindow; namespace Dasher { @@ -35,7 +36,7 @@ class CWinFileUtils :public CFileUtils { class CDasher : public CDashIntfScreenMsgs { public: - CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, Dasher::CSettingsStore* settings, CFileUtils* fileUtils); + CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, CPopup *pPopup, Dasher::CSettingsStore* settings, CFileUtils* fileUtils); ~CDasher(void); // The following functions will not be part of the final interface @@ -70,18 +71,20 @@ class CDasher : public CDashIntfScreenMsgs #endif bool SupportsClipboard() override { return true; }; void CopyToClipboard(const std::string &text) override; - + bool GetWindowSize(int* pTop, int* pLeft, int* pBottom, int* pRight); + void configurePopupTimer(bool enable); private: virtual void CreateModules() override; void ScanDirectory(const Tstring &strMask, std::vector &vFileList); - bool GetWindowSize(int* pTop, int* pLeft, int* pBottom, int* pRight); + void Log(); // Does the logging CCanvas *m_pCanvas; HWND m_hParent; CDasherWindow *m_pWindow; CEdit *m_pEdit; + CPopup *m_pPopup; #ifdef WIN32_SPEECH ISpVoice* getVoice(const string& lang); CComPtr m_pDefaultVoice; diff --git a/Src/Win32/Dasher.rc b/Src/Win32/Dasher.rc index 80f57e31f..ed3fab7d1 100644 --- a/Src/Win32/Dasher.rc +++ b/Src/Win32/Dasher.rc @@ -251,6 +251,19 @@ BEGIN GROUPBOX "File Encoding:",IDC_STATIC,193,194,180,30 END +IDS_PREFS_POPUP DIALOGEX 0, 0, 381, 238 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Dasher Popup:", IDC_STATIC, 7, 7, 180, 50 + CONTROL "Enable Popup Window", IDC_POPUP_ENABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 18, 110, 10 + CONTROL "Use External Monitor", IDC_POPUP_EXTERNAL, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 30, 110, 10 + CONTROL "Always On Top", IDC_POPUP_ALWAYSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 42, 110, 10 + GROUPBOX "Popup Style:", IDC_STATIC, 7, 60, 180, 40 + PUSHBUTTON "Change Font", IDC_DFONT_BUTTON, 12, 75, 166, 14 +END + IDD_MODULESETTINGS DIALOGEX 0, 0, 309, 177 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" @@ -321,6 +334,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 170 END + + IDS_PREFS_POPUP, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 374 + TOPMARGIN, 7 + BOTTOMMARGIN, 231 + END END #endif // APSTUDIO_INVOKED @@ -482,9 +503,16 @@ BEGIN IDS_UNTITLED_FILE "Untitled" IDS_UNSAVED_CHANGES "Unsaved changes" IDS_PREFS_LM "Application" + IDS_PREFS_POPUP "External Display" IDS_ERR_SOCKET_TITLE "Dasher Socket Input error" END +STRINGTABLE +BEGIN + IDC_POPUP_QUICK "Popup" +END + + #endif // English (United Kingdom) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/Src/Win32/Dasher.vcxproj b/Src/Win32/Dasher.vcxproj index bd984ef66..a4c8d9bfd 100644 --- a/Src/Win32/Dasher.vcxproj +++ b/Src/Win32/Dasher.vcxproj @@ -170,6 +170,8 @@ + + @@ -196,6 +198,8 @@ + + diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp index 2273b4422..fed35a06c 100644 --- a/Src/Win32/DasherWindow.cpp +++ b/Src/Win32/DasherWindow.cpp @@ -57,6 +57,7 @@ CDasherWindow::CDasherWindow(const wstring& configName) : m_configName(configNam m_pAppSettings = 0; m_pToolbar = 0; m_pEdit = 0; + m_pPopup = 0; m_pSpeedAlphabetBar = 0; m_pSplitter = 0; m_pDasher = 0; @@ -93,8 +94,6 @@ HWND CDasherWindow::Create() { m_pAppSettings = new CAppSettings(0, 0, settings); // Takes ownership of the settings store. int iStyle(m_pAppSettings->GetLongParameter(APP_LP_STYLE)); - HWND hWnd; - if (iStyle == APP_STYLE_DIRECT) { hWnd = CWindowImpl::Create(NULL, NULL, WindowTitle.c_str(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, WS_EX_NOACTIVATE | WS_EX_APPWINDOW | WS_EX_TOPMOST); ::SetMenu(hWnd, NULL); @@ -109,7 +108,12 @@ HWND CDasherWindow::Create() { m_pEdit->Create(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP)); m_pEdit->SetFont(m_pAppSettings->GetStringParameter(APP_SP_EDIT_FONT), m_pAppSettings->GetLongParameter(APP_LP_EDIT_FONT_SIZE)); - m_pDasher = new CDasher(hWnd, this, m_pEdit, settings, &fileUtils); + // Create Pop-Out Window - for multiple display support + m_pPopup = new CPopup(m_pAppSettings); + m_pPopup->Create(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP)); + m_pPopup->SetFont(m_pAppSettings->GetStringParameter(APP_SP_POPUP_FONT), m_pAppSettings->GetLongParameter(APP_LP_POPUP_FONT_SIZE)); + + m_pDasher = new CDasher(hWnd, this, m_pEdit, m_pPopup, settings, &fileUtils); // Create a CAppSettings m_pAppSettings->SetHwnd(hWnd); @@ -121,6 +125,7 @@ HWND CDasherWindow::Create() { // but at the moment it does, for training, blanking the display etc m_pEdit->SetInterface(m_pDasher); + m_pPopup->SetInterface(m_pDasher); m_pSpeedAlphabetBar = new CStatusControl(m_pDasher->GetSettingsUser(), m_pAppSettings); m_pSpeedAlphabetBar->Create(hWnd); @@ -136,6 +141,7 @@ HWND CDasherWindow::Create() { CDasherWindow::~CDasherWindow() { delete m_pToolbar; delete m_pEdit; + delete m_pPopup; delete m_pSplitter; delete m_pDasher; delete m_pSpeedAlphabetBar; @@ -145,7 +151,6 @@ CDasherWindow::~CDasherWindow() { } void CDasherWindow::Show(int nCmdShow) { - RECT r = { m_pAppSettings->GetLongParameter(APP_LP_X), m_pAppSettings->GetLongParameter(APP_LP_Y), @@ -160,7 +165,15 @@ void CDasherWindow::Show(int nCmdShow) { nCmdShow = SW_MAXIMIZE; ShowWindow(nCmdShow); } - +//This starts a brute force timer to update the popup window display +void CDasherWindow::configurePopupTimer(bool enable){ + if (enable) { + ::SetTimer(hWnd, 2, 1270, TIMERPROC(NULL)); + } + else { + ::KillTimer(hWnd, 2); + } +} void CDasherWindow::HandleParameterChange(int iParameter) { switch (iParameter) { case APP_BP_SHOW_TOOLBAR: @@ -223,6 +236,10 @@ LRESULT CDasherWindow::OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOO CPrefs Prefs(m_hWnd, m_pDasher, m_pAppSettings); return 0; } + case ID_QUICK_POPUP: { + m_pPopup->processToolbarButtonPress(); + return 0; + } case ID_HELP_CONTENTS: HtmlHelp(m_hWnd, L"Dasher.chm", HH_DISPLAY_INDEX, NULL); return 0; @@ -375,6 +392,15 @@ LRESULT CDasherWindow::OnOther(UINT message, WPARAM wParam, LPARAM lParam, BOOL& return 0; } +/* Handles Timer Callbacks*/ +LRESULT CDasherWindow::OnTimer(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + //Brute force timer to update the external display with a copy of the current Dasher edit display + //Timer should only be in use (created) by the Popup (when enabled) + string currentOutput = m_pEdit->getOutput(); + m_pPopup->updateDisplay(currentOutput); + return false; +} + void CDasherWindow::Layout() { if (!m_bFullyCreated) @@ -429,6 +455,7 @@ void CDasherWindow::Layout() { m_pEdit->Move(Width / 2, ToolbarHeight, Width - Width / 2, CanvasHeight); } m_pEdit->ShowWindow(SW_SHOW); + m_pPopup->setupPopup(); //Checks configuration and shows if enabled m_pSplitter->ShowWindow(SW_HIDE); break; @@ -460,6 +487,7 @@ void CDasherWindow::Layout() { m_pSplitter->Move(SplitterY, Width); } m_pEdit->ShowWindow(SW_SHOW); + m_pPopup->setupPopup(); //Checks configuration and shows if enabled m_pSplitter->ShowWindow(SW_SHOW); if (m_bSizeRestored) m_pAppSettings->SetLongParameter(APP_LP_EDIT_SIZE, EditHeight); diff --git a/Src/Win32/DasherWindow.h b/Src/Win32/DasherWindow.h index d7ec449a9..89a2defd2 100644 --- a/Src/Win32/DasherWindow.h +++ b/Src/Win32/DasherWindow.h @@ -14,6 +14,7 @@ #include "Widgets/Splitter.h" #include "Widgets/StatusControl.h" #include "Widgets/Edit.h" +#include "Widgets/Popup.h" class CToolbar; namespace Dasher { @@ -39,6 +40,7 @@ class CDasherWindow : MESSAGE_HANDLER(WM_INITMENUPOPUP,OnInitMenuPopup) MESSAGE_HANDLER(WM_SETFOCUS,OnSetFocus) MESSAGE_HANDLER(WM_WINDOWPOSCHANGED,OnWindowPosChanged) + MESSAGE_HANDLER(WM_TIMER,OnTimer) MESSAGE_RANGE_HANDLER(0xC000,0xFFFF,OnOther) END_MSG_MAP() @@ -52,6 +54,7 @@ class CDasherWindow : LRESULT OnDestroy(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClose(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnTimer(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // Create window (and children) @@ -59,6 +62,7 @@ class CDasherWindow : HWND Create(); void Show(int nCmdShow); + void configurePopupTimer(bool enable); void HandleWinEvent(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime); @@ -74,12 +78,15 @@ class CDasherWindow : bool m_bFullyCreated; Dasher::CDasher *m_pDasher; + + HWND hWnd; HACCEL hAccelTable; // Widgets: CToolbar *m_pToolbar; CEdit *m_pEdit; + CPopup *m_pPopup; //CCanvas *m_pCanvas; CSplitter *m_pSplitter; CStatusControl *m_pSpeedAlphabetBar; diff --git a/Src/Win32/UpgradeLog.htm b/Src/Win32/UpgradeLog.htm new file mode 100644 index 0000000000000000000000000000000000000000..3c6c78886d909b9f47a9d4d45b2b19a45101287f GIT binary patch literal 38574 zcmeI5`BNLolE?ek-H81kH0HfAvmS1n!}B~7LI@jkn9E>$aJ;~XTO3B5o_YJH@9yVY zNm1P`(N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-SW+VBL%y`H)BlY8<**qg| zXS#t=MRy6>zlY>#H?`sgT2<7)*ea&bZuDQ#(d4MMU9`!StoVNVUz{#zJl_tUuI_vk z$#`qgINfh?lB-^l(s&fCQd}k;iA&cBdpi6K)81fNbJC%9)qXlIn2hn7uCo|~ z-_vVRn{+HC#A&uTr*&Pl#qt#8i_=3sc!*5a$7$k`w|O|Ef2tJjK7uFu#$$xZ2vf30 zim_-_Ncg5>iOFcz;uVhZ_SJH-oQ<^*t@N=j^(juX5Tmg^gjjZckA45ziI<5oiiySB zu5Te=6F8TxGp?hf+Dq!Fo5adqHeA&)?U;=F1#P(q_qEeo|9YlkMfkNP}gh9v>eByX+dsHtHkrvRx7$D zUMD`v|4LfMG~xA{LStW&niUyMN2ISC>-9QQZ{SMm!`kHuAL+0-eYGFZP9OO*Oj^H8 zwp2rgvsU{3YND>DcP&QWx&+0&rL+Xa^IDalc%4TH3hO#azGhk7Yzd0f_u)y9qoq2e&>3cYR#iuw>fw9 zaj|sN&tq34Hlk>#j~i+CSh8n!CLn%NO1qenv`F_c2|=anwYtJJP>MJw&(nZ2_{w9|XF zSetDirty(true); } +std::string CEdit::getOutput() { + CString displayText; + GetWindowText(displayText); + std::wstring s(displayText); + return WinUTF8::wstring_to_UTF8string(s.c_str()); +} + void CEdit::TNew(const Tstring &filename) { // TODO: Send a message to the parent to say that the buffer has // changed (as in the Linux version). diff --git a/Src/Win32/Widgets/Edit.h b/Src/Win32/Widgets/Edit.h index b6cd43fc4..341833d1d 100644 --- a/Src/Win32/Widgets/Edit.h +++ b/Src/Win32/Widgets/Edit.h @@ -74,7 +74,6 @@ class CEdit : public ATL::CWindowImpl { HRESULT OnKeyUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); HRESULT OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - void Move(int x, int y, int Width, int Height); unsigned int OffsetAfterMove(unsigned int offsetBefore, bool bForwards, Dasher::CControlManager::EditDistance iDist); @@ -113,6 +112,9 @@ class CEdit : public ATL::CWindowImpl { //ACL Making these public so can be called directly from CDasher void HandleParameterChange(int iParameter); + //Expose current text- Used by the Popup Window to update external display window + std::string getOutput(); + protected: bool m_dirty; diff --git a/Src/Win32/Widgets/Popup.cpp b/Src/Win32/Widgets/Popup.cpp new file mode 100644 index 000000000..cc3400a85 --- /dev/null +++ b/Src/Win32/Widgets/Popup.cpp @@ -0,0 +1,301 @@ +// Popup.cpp +// +// Copyright (c) 2016 The Dasher Team +// +// This file is part of Dasher. +// +// Dasher 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. +// +// Dasher 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 Dasher; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// +// NOTES: Created by Jeremy Cope to facilitate extended (multiple) displays. +// + +#include "WinCommon.h" + +#include "Popup.h" +#include +#include "../../DasherCore/Event.h" +#include "FilenameGUI.h" +#include "../resource.h" +#include "../../DasherCore/DasherInterfaceBase.h" +#include "../Dasher.h" + +/** +* This class manages the external popup window +* to be used to be used on an 2nd monitor (extended display). +* +* Known Issues: +* -> Setting the font- seems to capture size but not name +* +* +* +*/ + + +using namespace Dasher; +using namespace std; +using namespace WinLocalisation; +using namespace WinUTF8; + +BOOL contains(RECT rectA, RECT rectB); +BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); + + +/** +* Constructors, Destructors, Initializers, Setup Functions +*/ +CPopup::CPopup(CAppSettings *pAppSettings) { + m_pAppSettings = pAppSettings; + + UINT CodePage = GetUserCodePage(); + m_Font = GetCodePageFont(CodePage, 14); + + m_setup = false; + m_externalMonitorRect = RECT(); + m_dasherWindwowRect = RECT(); + m_popupRect = RECT(); +} + +HWND CPopup::Create(HWND hParent, bool bNewWithDate) { + RECT r = getInitialWindow(); + m_popup = CWindowImpl::Create(hParent, r, NULL, WS_OVERLAPPEDWINDOW| ES_MULTILINE ); + return *this; +} + +CPopup::~CPopup() { + DeleteObject(m_Font); +} + +void CPopup::setupPopup() { + if (!m_setup) { + m_setup = true; + + //Calculate the size of the windows,displays + calculateDisplayProperties(); + + //Determine the placement of the popup + positionPopup(); + + //If enabled, show and start the auto update timer + if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true) { + //Show the Popup + ShowWindow(SW_SHOW); + //Fire the update timer + CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation + dasher->configurePopupTimer(true); + } + } +} + +void CPopup::SetFont(string Name, long Size) { + Tstring FontName; + UTF8string_to_wstring(Name, FontName); + + if(Size == 0) + Size = 14; + + DeleteObject(m_Font); + if (Name == "") { + UINT CodePage = GetUserCodePage(); + m_Font = GetCodePageFont(CodePage, -Size); + } + else { + m_Font = CreateFont(-Size, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, FontName.c_str()); // DEFAULT_CHARSET => font made just from Size and FontName + } + SendMessage(WM_SETFONT, (WPARAM) m_Font, true); +} + +void CPopup::SetInterface(Dasher::CDasherInterfaceBase *DasherInterface) { + m_pDasherInterface = DasherInterface; +} + + +/** +* Text Display Management- used to update the display with different text +*/ +//Timer callback function +void CPopup::updateDisplay(const std::string sText) { + //If the display output has changed.. update the popup window + if (sText.compare(m_Output) != 0) { + m_Output = sText; + output(m_Output); + } +} +//Exposed Method so outside classes can force an update on the screen +void CPopup::output(const std::string &sText) { + wstring String; + WinUTF8::UTF8string_to_wstring(sText, String); + InsertText(String); +} +//Actually updates the window with the provided text +void CPopup::InsertText(Tstring InsertText) { + //Update entire screen + SendMessage(WM_SETTEXT, TRUE, (LPARAM)InsertText.c_str()); + //Scroll to bottom + SendMessage(EM_LINESCROLL, 0, INT_MAX); //Force to end of buffer with max integer +} + + +/** +* Popup Actionables- called when parameter changes in settings, or toolbar button is pressed +* BUG: Seems to be called twice on parameter changes +*/ +void CPopup::HandleParameterChange(int iParameter) { + switch(iParameter) { + case APP_SP_POPUP_FONT: + case APP_LP_POPUP_FONT_SIZE: + SetFont(m_pAppSettings->GetStringParameter(APP_SP_POPUP_FONT), m_pAppSettings->GetLongParameter(APP_LP_POPUP_FONT_SIZE)); + break; + case APP_BP_POPUP_ENABLE: + if(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true){ + ShowWindow(SW_SHOW); + CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation + dasher->configurePopupTimer(true); + } + else { + ShowWindow(SW_HIDE); + } + break; + case APP_BP_POPUP_EXTERNAL_SCREEN: + positionPopup(); + break; + case APP_BP_POPUP_INFRONT: + break; + default: + break; + } +} +//Toolbar quick action ignores 'use external monitor' setting +//Forces external monitor usages (fi exists) +bool CPopup::processToolbarButtonPress() { + bool popupEnabled = false; + popupEnabled = m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE); + //Action depends on current status + if (popupEnabled == false) { + //Quick button possitions fully on the external monitor, if monitor exists + LPRECT popupDisplayRect; + if (isExtMonitorDetected()) { + popupDisplayRect = &m_externalMonitorRect; + } + else { + popupDisplayRect = &m_popupRect; + } + MoveWindow(popupDisplayRect); + } + + //Update the state flag + popupEnabled = !popupEnabled; + m_pAppSettings->SetBoolParameter(APP_BP_POPUP_ENABLE, popupEnabled); //Setting the parameter triggers action + //Return the current state + return popupEnabled; +} + +/** +* Popup Management and Placement +*/ +void CPopup::Move(int x, int y, int Width, int Height) { + MoveWindow(x, y, Width, Height, TRUE); +} + +RECT CPopup::getInitialWindow() { + RECT rect; + rect = { + 1000,100,1800,500 + }; + return rect; +} + +void CPopup::calculateDisplayProperties() { + getDasherWidnowInfo(); + //Warning, assync call, enumerates all displays + getMonitorInfo(); +} + +void CPopup::positionPopup() { + LPRECT popupDisplayRect; + if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN) == true) { + //May have setting to use external, but does external screen exists? + if (isExtMonitorDetected()) { + popupDisplayRect = &m_externalMonitorRect; + } + else { + popupDisplayRect = &m_popupRect; + } + } + else { + popupDisplayRect = &m_popupRect; + } + + //Redraw in the correct location + MoveWindow(popupDisplayRect, true); +} + +bool CPopup::isExtMonitorDetected() { + bool retVal = false; + if (!IsRectEmpty(&m_externalMonitorRect)){ + retVal = true; + } + return retVal; +} + +void CPopup::getMonitorInfo(){ + RECT* userData[2] = { &m_dasherWindwowRect, &m_externalMonitorRect }; + EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&userData); +} + +void CPopup::getDasherWidnowInfo() { + //Get Dasher Window position and size + CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation + int iTop = 0; + int iLeft = 0; + int iBottom = 0; + int iRight = 0; + + dasher->GetWindowSize(&iTop, &iLeft, &iBottom, &iRight); + + m_dasherWindwowRect.top = iTop; + m_dasherWindwowRect.left = iLeft; + m_dasherWindwowRect.right = iRight; + m_dasherWindwowRect.bottom = iBottom; + + //Initialize our window based on the dasher window + m_popupRect.top = m_dasherWindwowRect.top + 100; + m_popupRect.left = m_dasherWindwowRect.left + 100; + m_popupRect.right = m_dasherWindwowRect.right + 100; + m_popupRect.bottom = m_dasherWindwowRect.top + (m_dasherWindwowRect.bottom - m_dasherWindwowRect.top)/2; +} + +BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { + RECT monitorCoordinates = *lprcMonitor; + RECT** userData = (RECT**)dwData; + RECT* dasherRect = userData[0]; + RECT* externRect = userData[1]; + + //If this monitor contains the dasher Window, it is primary monitor + //Else it is external monitor, and should be used for popup. + //Else window spans multiple monitors.. + if (contains(monitorCoordinates, *dasherRect)) { + + } + else { + //Never called if no extra monitor + *externRect = monitorCoordinates; + } + return TRUE; +} + +BOOL contains(RECT rectA, RECT rectB) { + return (rectA.left < rectB.right && rectA.right > rectB.left && + rectA.top < rectB.bottom && rectA.bottom > rectB.top); +} \ No newline at end of file diff --git a/Src/Win32/Widgets/Popup.h b/Src/Win32/Widgets/Popup.h new file mode 100644 index 000000000..868edf01f --- /dev/null +++ b/Src/Win32/Widgets/Popup.h @@ -0,0 +1,110 @@ +// Popup.cpp +// +// Copyright (c) 2016 The Dasher Team +// +// This file is part of Dasher. +// +// Dasher 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. +// +// Dasher 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 Dasher; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef __Popup_h__ +#define __Popup_h__ + +#define _ATL_APARTMENT_THREADED +#include + +//You may derive a class from CComModule and use it if you want to override something, + +//but do not change the name of _Module + +extern CComModule _Module; + +#include + +#include "../AppSettings.h" +#include "../DasherAction.h" +#include "../../DasherCore/DasherTypes.h" +#include "../../DasherCore/ControlManager.h" +#include + +class CCanvas; +class CFilenameGUI; + +namespace Dasher { + class CDasherInterfaceBase; + class CEvent; +}; + +class CPopup : public ATL::CWindowImpl { + public: + + CPopup(CAppSettings *pAppSettings); + ~CPopup(); + + HWND Create(HWND hParent, bool bNewWithDate); + void setupPopup(); //Call once Dasher has been drawn, so we can determine placement + + // Superclass the built-in EDIT window class + DECLARE_WND_SUPERCLASS(NULL, _T("EDIT")) + + BEGIN_MSG_MAP(CPopup) + + END_MSG_MAP() + + void Move(int x, int y, int Width, int Height); + + void SetFont(std::string Name, long Size); + + void SetInterface(Dasher::CDasherInterfaceBase * DasherInterface); + + // called when a new character falls under the crosshair + void output(const std::string & sText); + + void updateDisplay(const std::string sText); + + //ACL Making these public so can be called directly from CDasher + void HandleParameterChange(int iParameter); + + //Called when the quick enable button is pressed in the toolbar + bool processToolbarButtonPress(); + + protected: + bool m_dirty; + + private: + Dasher::CDasherInterfaceBase *m_pDasherInterface; + CAppSettings *m_pAppSettings; + + bool m_setup; + HWND Parent; + HWND m_popup; + HWND m_hTarget; + HFONT m_Font; + HWND targetwindow; + std::string m_Output; // UTF-8 to go to training file + RECT m_dasherWindwowRect; + RECT m_externalMonitorRect; + RECT m_popupRect; //The current rect being used for the popup + + void InsertText(Tstring InsertText); // add symbol to edit control + RECT getInitialWindow(); + void calculateDisplayProperties(); + void positionPopup(); + void getDasherWidnowInfo(); + void getMonitorInfo(); + bool isExtMonitorDetected(); + +}; + +#endif /* #ifndef __CPopup_h__ */ diff --git a/Src/Win32/Widgets/PopupPage.cpp b/Src/Win32/Widgets/PopupPage.cpp new file mode 100644 index 000000000..4d10239c1 --- /dev/null +++ b/Src/Win32/Widgets/PopupPage.cpp @@ -0,0 +1,198 @@ +// AlphabetBox.cpp +// +///////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge. +// +///////////////////////////////////////////////////////////////////////////// + +#include "WinCommon.h" + +#include "PopupPage.h" +#include "../resource.h" + +#include // for std::pair + +using namespace Dasher; +using namespace std; + +// Track memory leaks on Windows to the line that new'd the memory +#ifdef _WIN32 +#ifdef _DEBUG +#define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ ) +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif +#endif + +CPopupPage::CPopupPage(HWND Parent, CAppSettings *pAppSettings) +:CPrefsPageBase(Parent, pAppSettings) { + + m_CurrentColours = pAppSettings->GetStringParameter(SP_COLOUR_ID); +} + +struct menuentry { + int paramNum; // enum value in Parameters.h for setting store + int idcNum; // #define value in resource.h for dasher.rc +}; + +// List of menu items that will be displayed in the General Preferences +static menuentry menutable[] = { + {BP_DRAW_MOUSE, IDC_DRAWMOUSE}, + {BP_DRAW_MOUSE_LINE, IDC_DRAWMOUSELINE}, +}; + +void CPopupPage::PopulateList() { + // Populate the controls in the dialogue box based on the relevent parameters + // in m_pDasher + //Popup Enabled + if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true) { + SendMessage(GetDlgItem(m_hwnd, IDC_POPUP_ENABLE), BM_SETCHECK, BST_CHECKED, 0); + } + if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN) == true) { + SendMessage(GetDlgItem(m_hwnd, IDC_POPUP_EXTERNAL), BM_SETCHECK, BST_CHECKED, 0); + } + // TODO: Annoying inversion makes this hard + if(m_pAppSettings->GetBoolParameter(BP_PALETTE_CHANGE)) { + SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_SETCHECK, BST_UNCHECKED, 0); + EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), FALSE); + } + else { + SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), TRUE); + } + + for(int ii = 0; iiGetBoolParameter(menutable[ii].paramNum)) { + SendMessage(GetDlgItem(m_hwnd, menutable[ii].idcNum), BM_SETCHECK, BST_CHECKED, 0); + } + else { + SendMessage(GetDlgItem(m_hwnd, menutable[ii].idcNum), BM_SETCHECK, BST_UNCHECKED, 0); + } + } + + + HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS); + m_pAppSettings->GetPermittedValues(SP_COLOUR_ID, ColourList); + + // Add each string to list box and index each one + bool SelectionSet = false; + for(unsigned int i = 0; i < ColourList.size(); i++) { + Tstring Item; + WinUTF8::UTF8string_to_wstring(ColourList[i], Item); + LRESULT Index = SendMessage(ListBox, LB_ADDSTRING, 0, (LPARAM) Item.c_str()); + SendMessage(ListBox, LB_SETITEMDATA, Index, (LPARAM) i); + if(ColourList[i] == m_CurrentColours) { + SendMessage(ListBox, LB_SETCURSEL, Index, 0); + SelectionSet = true; + } + } + if(SelectionSet == false) { + SendMessage(ListBox, LB_SETCURSEL, 0, 0); + LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, 0, 0); + m_CurrentColours = ColourList[CurrentIndex]; + } + // Tell list box that we have set an item for it (so that delete and edit can be grayed if required) + SendMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_COLOURS, LBN_SELCHANGE), 0); + + if(m_pAppSettings->GetLongParameter(LP_LINE_WIDTH) > 1) + SendMessage(GetDlgItem(m_hwnd, IDC_THICKLINE), BM_SETCHECK, BST_CHECKED, 0); + else + SendMessage(GetDlgItem(m_hwnd, IDC_THICKLINE), BM_SETCHECK, BST_UNCHECKED, 0); + + SendMessage(GetDlgItem(m_hwnd, IDC_OUTLINE), BM_SETCHECK, + m_pAppSettings->GetLongParameter(LP_OUTLINE_WIDTH) ? BST_CHECKED : BST_UNCHECKED, 0); + + if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::Normal) { + SendMessage(GetDlgItem(m_hwnd, IDC_FONT_SMALL), BM_SETCHECK, BST_CHECKED, 0); + } + else if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::Big) { + SendMessage(GetDlgItem(m_hwnd, IDC_FONT_LARGE), BM_SETCHECK, BST_CHECKED, 0); + } + else if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::VBig) { + SendMessage(GetDlgItem(m_hwnd, IDC_FONT_VLARGE), BM_SETCHECK, BST_CHECKED, 0); + } +} + + +bool CPopupPage::Apply() { + if(m_CurrentColours != std::string("")) { + m_pAppSettings->SetStringParameter(SP_COLOUR_ID, m_CurrentColours); + } + + m_pAppSettings->SetBoolParameter(BP_PALETTE_CHANGE, + SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_GETCHECK, 0, 0) == BST_UNCHECKED ); + + if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_SMALL), BM_GETCHECK, 0, 0) == BST_CHECKED) + m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::Normal); + else if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_LARGE), BM_GETCHECK, 0, 0) == BST_CHECKED) + m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::Big); + else if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_VLARGE), BM_GETCHECK, 0, 0) == BST_CHECKED) + m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::VBig); + + // Return false (and notify the user) if something is wrong. + return TRUE; +} + +LRESULT CPopupPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) { + // most things we pass on to CPrefsPageBase, but we need to handle slider motion + switch (message) { + case WM_COMMAND: + if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == LBN_SELCHANGE) { + if (LOWORD(wParam) != 0 && m_hPropertySheet != 0 && m_hwnd != 0) { + PropSheet_Changed(m_hPropertySheet, m_hwnd); // enables the 'Apply' button + // Behaviour isn't *perfect* since it activates the Apply button even if you, say, + // click 'new' alphabet then click Cancel when asked for a name. + } + } + switch (LOWORD(wParam)) { + case (IDC_COLOURS): + if (HIWORD(wParam) == LBN_SELCHANGE) { + HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS); + LRESULT CurrentItem = SendMessage(ListBox, LB_GETCURSEL, 0, 0); + LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, CurrentItem, 0); + m_CurrentColours = ColourList[CurrentIndex]; + } + return TRUE; + break; + case IDC_DFONT_BUTTON: // TODO: Put this in a function + { + CHOOSEFONT Data; + LOGFONT lf; + HFONT Font = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + GetObject(Font, sizeof(LOGFONT), &lf); + Tstring tstrFaceName; + WinUTF8::UTF8string_to_wstring(m_pAppSettings->GetStringParameter(SP_DASHER_FONT), tstrFaceName); + _tcscpy(lf.lfFaceName, tstrFaceName.c_str()); + Data.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS; + Data.lStructSize = sizeof(CHOOSEFONT); + // TODO: Give this an owner + Data.hwndOwner = NULL; + Data.lpLogFont = &lf; + if (ChooseFont(&Data)) { + string FontName; + WinUTF8::wstring_to_UTF8string(lf.lfFaceName, FontName); + m_pAppSettings->SetStringParameter(APP_SP_POPUP_FONT, FontName); + m_pAppSettings->SetLongParameter(APP_LP_POPUP_FONT_SIZE, lf.lfHeight); + } + } + break; + case IDC_COLOURSCHEME: + EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_GETCHECK, 0, 0) == BST_CHECKED); + break; + case IDC_POPUP_ENABLE: + m_pAppSettings->SetBoolParameter(APP_BP_POPUP_ENABLE, !(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE))); + break; + case IDC_POPUP_EXTERNAL: + m_pAppSettings->SetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN, !(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN))); + break; + case IDC_POPUP_ALWAYSTOP: + //TODO: Track setting of alwasy on top of windows + break; + default: + break; + } + } + return CPrefsPageBase::WndProc(Window, message, wParam, lParam); +} diff --git a/Src/Win32/Widgets/PopupPage.h b/Src/Win32/Widgets/PopupPage.h new file mode 100644 index 000000000..64621a9c5 --- /dev/null +++ b/Src/Win32/Widgets/PopupPage.h @@ -0,0 +1,38 @@ +// ViewPage.h +// +///////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef __PopupPage_h__ +#define __PopupPage_h__ + +#include "PrefsPageBase.h" + +#include "../resource.h" +#include "../AppSettings.h" + +#include "../Dasher.h" +#include "../../DasherCore/ColourIO.h" + +class CPopupPage:public CPrefsPageBase { +public: + CPopupPage(HWND Parent, CAppSettings *pAppSettings); + LRESULT WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam); + +private: + std::vector < std::string > ColourList; + std::string m_CurrentColours; + Dasher::CColourIO::ColourInfo CurrentInfo; + + // Some status flags: + void PopulateList(); + void InitCustomBox(); + bool UpdateInfo(); + bool Apply(); + +}; + +#endif /* #ifndef */ diff --git a/Src/Win32/Widgets/Prefs.cpp b/Src/Win32/Widgets/Prefs.cpp index 055eae9d2..b2ce57d7c 100644 --- a/Src/Win32/Widgets/Prefs.cpp +++ b/Src/Win32/Widgets/Prefs.cpp @@ -28,10 +28,12 @@ CPrefs::CPrefs(HWND hParent, CDasher *pDasher, CAppSettings *pAppSettings) { m_pControlPage = new CControlPage(hParent, pDasher, pAppSettings); m_pViewPage = new CViewPage(hParent, pAppSettings); m_pAdvancedPage = new CAdvancedPage(hParent, pAppSettings); + m_pPopupPage = new CPopupPage(hParent, pAppSettings); + // Set up the property sheets which go into the preferences // dialogue. - PROPSHEETPAGE psp[4]; + PROPSHEETPAGE psp[5]; memset(psp, 0, sizeof(psp)); psp[0].dwSize = sizeof(PROPSHEETPAGE); psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE | PSP_PREMATURE; @@ -72,6 +74,16 @@ CPrefs::CPrefs(HWND hParent, CDasher *pDasher, CAppSettings *pAppSettings) { psp[3].pszTitle = MAKEINTRESOURCE(IDS_PREFS_LM); psp[3].lParam = (LPARAM) m_pAdvancedPage; psp[3].pfnCallback = NULL; + + psp[4].dwSize = sizeof(PROPSHEETPAGE); + psp[4].dwFlags = PSP_USEICONID | PSP_USETITLE | PSP_PREMATURE; + psp[4].hInstance = WinHelper::hInstApp; + psp[4].pszTemplate = MAKEINTRESOURCE(IDS_PREFS_POPUP); + psp[4].pszIcon = NULL; + psp[4].pfnDlgProc = (DLGPROC)WinWrapMap::PSWndProc; + psp[4].pszTitle = MAKEINTRESOURCE(IDS_PREFS_POPUP); + psp[4].lParam = (LPARAM)m_pPopupPage; + psp[4].pfnCallback = NULL; PROPSHEETHEADER psh; memset(&psh, 0, sizeof(psh)); diff --git a/Src/Win32/Widgets/Prefs.h b/Src/Win32/Widgets/Prefs.h index 6401381dc..f9401d900 100644 --- a/Src/Win32/Widgets/Prefs.h +++ b/Src/Win32/Widgets/Prefs.h @@ -17,6 +17,7 @@ #include "ControlPage.h" #include "ViewPage.h" #include "AdvancedPage.h" +#include "PopupPage.h" #include "../AppSettings.h" namespace Dasher { @@ -36,6 +37,7 @@ class CPrefs:public CWinWrap { CControlPage *m_pControlPage; CViewPage *m_pViewPage; CAdvancedPage *m_pAdvancedPage; + CPopupPage *m_pPopupPage; }; #endif /* #ifndef __PrefsBox_h__ */ diff --git a/Src/Win32/Widgets/Toolbar.cpp b/Src/Win32/Widgets/Toolbar.cpp index 1e6dde145..74238120a 100644 --- a/Src/Win32/Widgets/Toolbar.cpp +++ b/Src/Win32/Widgets/Toolbar.cpp @@ -41,7 +41,10 @@ SToolbarButton sButtons[] = { {-2, 5, IDS_EDIT_COPY_ALL, ID_EDIT_COPY_ALL}, {STD_PASTE, 6, IDS_EDIT_PASTE, ID_EDIT_PASTE}, {-1, -1, 0, 0}, - {STD_PROPERTIES, 7, IDS_OPTIONS_PREFS, ID_OPTIONS_PREFS} + {STD_PROPERTIES, 7, IDS_OPTIONS_PREFS, ID_OPTIONS_PREFS}, + { -1, -1, 0, 0 }, + //External Display + { STD_PRINTPRE, 8, IDC_POPUP_QUICK, ID_QUICK_POPUP }, }; CToolbar::CToolbar(HWND hParent, bool bVisible) { @@ -67,9 +70,7 @@ void CToolbar::ShowToolbar(bool bValue) { void CToolbar::CreateToolbar() { WinHelper::InitCommonControlLib(); - - - + m_hRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, diff --git a/Src/Win32/Widgets/ViewPage.cpp b/Src/Win32/Widgets/ViewPage.cpp index ec3a67753..162b0e3a6 100644 --- a/Src/Win32/Widgets/ViewPage.cpp +++ b/Src/Win32/Widgets/ViewPage.cpp @@ -148,7 +148,6 @@ bool CViewPage::Apply() { } LRESULT CViewPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) { - // most things we pass on to CPrefsPageBase, but we need to handle slider motion switch (message) { diff --git a/Src/Win32/resource.h b/Src/Win32/resource.h index cde219a58..054a2447c 100644 --- a/Src/Win32/resource.h +++ b/Src/Win32/resource.h @@ -36,6 +36,7 @@ #define IDD_APPEARANCEPAGE 178 #define IDD_APPPAGE 179 #define IDD_MODULESETTINGS 180 +#define IDS_PREFS_POPUP 181 #define IDD_STATUSBAR 182 #define IDC_INPUT_LIST 1008 #define IDC_CONTROL_LIST 1009 @@ -91,9 +92,16 @@ #define IDC_CHECK5 1157 #define IDC_CONTROLBOXES 1160 #define IDC_FILE_ENCODING 1161 -#define IDC_SPEED_EDIT 1163 -#define IDC_SPEED_SPIN 1164 -#define IDC_ALPHABET_COMBO 1166 +#define IDC_POPUP_ENABLE 1162 +#define IDC_POPUP_EXTERNAL 1163 +#define IDC_POPUP_ALWAYSTOP 1164 +#define IDC_SPEED_EDIT 1165 +#define IDC_SPEED_SPIN 1166 +#define IDC_ALPHABET_COMBO 1167 + +#define IDC_POPUP_QUICK 1170 +#define ID_QUICK_POPUP 1171 + #define ID_EDIT_SELECTALL 32775 #define ID_HELP_CONTENTS 32776 #define ID_EDIT_COPY_ALL 32798 From 36721123a0ecc115a026295946f226751c126e53 Mon Sep 17 00:00:00 2001 From: Ada Majorek Date: Sun, 2 Apr 2017 09:43:10 -0700 Subject: [PATCH 2/3] Revert "Popup Feature for supporting an Extended Display (Dual Monitor) (#112)" (#113) This reverts commit b9879bc7ee0c20075abcd4e2bbcc6037ecb33859. --- Src/Common/AppSettingsData.h | 7 +- Src/Common/AppSettingsHeader.h | 8 +- Src/Win32/Dasher.cpp | 11 +- Src/Win32/Dasher.h | 9 +- Src/Win32/Dasher.rc | 28 --- Src/Win32/Dasher.vcxproj | 4 - Src/Win32/DasherWindow.cpp | 38 +--- Src/Win32/DasherWindow.h | 7 - Src/Win32/UpgradeLog.htm | Bin 38574 -> 0 bytes Src/Win32/Widgets/AdvancedPage.cpp | 2 +- Src/Win32/Widgets/Edit.cpp | 7 - Src/Win32/Widgets/Edit.h | 4 +- Src/Win32/Widgets/Popup.cpp | 301 ----------------------------- Src/Win32/Widgets/Popup.h | 110 ----------- Src/Win32/Widgets/PopupPage.cpp | 198 ------------------- Src/Win32/Widgets/PopupPage.h | 38 ---- Src/Win32/Widgets/Prefs.cpp | 14 +- Src/Win32/Widgets/Prefs.h | 2 - Src/Win32/Widgets/Toolbar.cpp | 9 +- Src/Win32/Widgets/ViewPage.cpp | 1 + Src/Win32/resource.h | 14 +- 21 files changed, 24 insertions(+), 788 deletions(-) delete mode 100644 Src/Win32/UpgradeLog.htm delete mode 100644 Src/Win32/Widgets/Popup.cpp delete mode 100644 Src/Win32/Widgets/Popup.h delete mode 100644 Src/Win32/Widgets/PopupPage.cpp delete mode 100644 Src/Win32/Widgets/PopupPage.h diff --git a/Src/Common/AppSettingsData.h b/Src/Common/AppSettingsData.h index 3aaed26a9..5beddc2dc 100644 --- a/Src/Common/AppSettingsData.h +++ b/Src/Common/AppSettingsData.h @@ -26,10 +26,7 @@ Dasher::Settings::bp_table app_boolparamtable[] = { { APP_BP_TIME_STAMP, "TimeStampNewFiles", Persistence::PERSISTENT, true, "TimeStampNewFiles" }, { APP_BP_CONFIRM_UNSAVED, "ConfirmUnsavedFiles", Persistence::PERSISTENT, true, "ConfirmUnsavedFiles" }, - { APP_BP_SHOW_TOOLBAR, "ViewToolbar", Persistence::PERSISTENT, true, "ViewToolbar"}, - { APP_BP_POPUP_ENABLE, "PopupEnable", Persistence::PERSISTENT, false, "PopupEnable"}, - { APP_BP_POPUP_EXTERNAL_SCREEN, "PopupFullScreen", Persistence::PERSISTENT, false, "PopupFullScreen"}, - { APP_BP_POPUP_INFRONT, "PopupInfront", Persistence::PERSISTENT, false, "PopupInfront"}, + {APP_BP_SHOW_TOOLBAR, "ViewToolbar", Persistence::PERSISTENT, true, "ViewToolbar"}, #ifdef WITH_MAEMO { APP_BP_SHOW_STATUSBAR, "ViewStatusbar", Persistence::PERSISTENT, false, "ViewStatusbar" }, #else @@ -42,7 +39,6 @@ Dasher::Settings::bp_table app_boolparamtable[] = { Dasher::Settings::lp_table app_longparamtable[] = { {APP_LP_FILE_ENCODING, "FileEncodingFormat", Persistence::PERSISTENT, -1, "FileEncodingFormat"}, {APP_LP_EDIT_FONT_SIZE, "EditFontSize", Persistence::PERSISTENT, 0, "EditFontSize"}, - {APP_LP_POPUP_FONT_SIZE, "PopupFontSize", Persistence::PERSISTENT, 0, "PopupFontSize"}, {APP_LP_EDIT_SIZE, "EditSize", Persistence::PERSISTENT, 75, "The size of the edit window"}, {APP_LP_SCREEN_WIDTH, "ScreenWidth", Persistence::PERSISTENT, 400, "ScreenWidth"}, {APP_LP_SCREEN_HEIGHT, "ScreenHeight", Persistence::PERSISTENT, 500, "ScreenHeight"}, @@ -59,7 +55,6 @@ Dasher::Settings::sp_table app_stringparamtable[] = { {APP_SP_EDIT_FONT, "EditFont", Persistence::PERSISTENT, "Sans 20", "EditFont"}, #else {APP_SP_EDIT_FONT, "EditFont", Persistence::PERSISTENT, "Sans 10", "EditFont"}, - {APP_SP_POPUP_FONT, "PopupFont", Persistence::PERSISTENT, "Sans 10", "PopupFont"}, #endif { APP_SP_TOOLBAR_ID, "ToolbarID", Persistence::PERSISTENT, "", "ToolbarID" }, }; diff --git a/Src/Common/AppSettingsHeader.h b/Src/Common/AppSettingsHeader.h index 20f9d068a..bde7e7e21 100644 --- a/Src/Common/AppSettingsHeader.h +++ b/Src/Common/AppSettingsHeader.h @@ -8,14 +8,11 @@ enum { APP_BP_TIME_STAMP = END_OF_SPS, APP_BP_CONFIRM_UNSAVED, APP_BP_SHOW_TOOLBAR, - APP_BP_SHOW_STATUSBAR, APP_BP_MIRROR_LAYOUT, APP_BP_FULL_SCREEN, - APP_BP_POPUP_ENABLE, APP_BP_POPUP_EXTERNAL_SCREEN, APP_BP_POPUP_INFRONT, - END_OF_APP_BPS + APP_BP_SHOW_STATUSBAR, APP_BP_MIRROR_LAYOUT, APP_BP_FULL_SCREEN, END_OF_APP_BPS }; enum { APP_LP_FILE_ENCODING = END_OF_APP_BPS, APP_LP_EDIT_FONT_SIZE, // TODO Extract font size from APP_SP_EDIT_FONT as linux - APP_LP_POPUP_FONT_SIZE, APP_LP_EDIT_SIZE, APP_LP_SCREEN_WIDTH, APP_LP_SCREEN_HEIGHT, APP_LP_STYLE, APP_LP_X, APP_LP_Y, @@ -26,8 +23,7 @@ enum { }; enum { - APP_SP_EDIT_FONT = END_OF_APP_LPS, - APP_SP_POPUP_FONT, + APP_SP_EDIT_FONT = END_OF_APP_LPS, APP_SP_TOOLBAR_ID, END_OF_APP_SPS }; diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp index 1728f2dcf..f515d3873 100644 --- a/Src/Win32/Dasher.cpp +++ b/Src/Win32/Dasher.cpp @@ -10,7 +10,6 @@ #include "DasherMouseInput.h" #include "DasherWindow.h" #include "Widgets/Edit.h" -#include "Widgets/Popup.h" #include "Sockets/SocketInput.h" #include "BTSocketInput.h" @@ -27,8 +26,8 @@ using namespace WinUTF8; CONST UINT WM_DASHER_FOCUS = RegisterWindowMessage(L"WM_DASHER_FOCUS"); -CDasher::CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, CPopup *pPopup, Dasher::CSettingsStore* settings, CFileUtils* fileUtils) - : CDashIntfScreenMsgs(settings, fileUtils), m_hParent(Parent), m_pWindow(pWindow), m_pEdit(pEdit), m_pPopup(pPopup) { +CDasher::CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, Dasher::CSettingsStore* settings, CFileUtils* fileUtils) + : CDashIntfScreenMsgs(settings, fileUtils), m_hParent(Parent), m_pWindow(pWindow), m_pEdit(pEdit) { // This class will be a wrapper for the Dasher 'control' - think ActiveX // Set up COM for the accessibility stuff @@ -110,7 +109,6 @@ void Dasher::CDasher::HandleEvent(int iParameter) { CDashIntfScreenMsgs::HandleEvent(iParameter); m_pWindow->HandleParameterChange(iParameter); m_pEdit->HandleParameterChange(iParameter); - m_pPopup->HandleParameterChange(iParameter); if (iParameter == SP_DASHER_FONT) m_pCanvas->SetFont(GetStringParameter(SP_DASHER_FONT)); } @@ -352,8 +350,3 @@ int CDasher::GetAllContextLenght(){ std::string CDasher::GetTextAroundCursor(CControlManager::EditDistance iDist) { return m_pEdit->GetTextAroundCursor(iDist); } - -void CDasher::configurePopupTimer(bool enable) { - //Timer is managed by the window object - m_pWindow->configurePopupTimer(enable); -} \ No newline at end of file diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h index 63e1370af..fce443a4f 100644 --- a/Src/Win32/Dasher.h +++ b/Src/Win32/Dasher.h @@ -15,7 +15,6 @@ extern CONST UINT WM_DASHER_FOCUS; class CCanvas; class CEdit; -class CPopup; class CDasherWindow; namespace Dasher { @@ -36,7 +35,7 @@ class CWinFileUtils :public CFileUtils { class CDasher : public CDashIntfScreenMsgs { public: - CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, CPopup *pPopup, Dasher::CSettingsStore* settings, CFileUtils* fileUtils); + CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, Dasher::CSettingsStore* settings, CFileUtils* fileUtils); ~CDasher(void); // The following functions will not be part of the final interface @@ -71,20 +70,18 @@ class CDasher : public CDashIntfScreenMsgs #endif bool SupportsClipboard() override { return true; }; void CopyToClipboard(const std::string &text) override; - bool GetWindowSize(int* pTop, int* pLeft, int* pBottom, int* pRight); - void configurePopupTimer(bool enable); + private: virtual void CreateModules() override; void ScanDirectory(const Tstring &strMask, std::vector &vFileList); - + bool GetWindowSize(int* pTop, int* pLeft, int* pBottom, int* pRight); void Log(); // Does the logging CCanvas *m_pCanvas; HWND m_hParent; CDasherWindow *m_pWindow; CEdit *m_pEdit; - CPopup *m_pPopup; #ifdef WIN32_SPEECH ISpVoice* getVoice(const string& lang); CComPtr m_pDefaultVoice; diff --git a/Src/Win32/Dasher.rc b/Src/Win32/Dasher.rc index ed3fab7d1..80f57e31f 100644 --- a/Src/Win32/Dasher.rc +++ b/Src/Win32/Dasher.rc @@ -251,19 +251,6 @@ BEGIN GROUPBOX "File Encoding:",IDC_STATIC,193,194,180,30 END -IDS_PREFS_POPUP DIALOGEX 0, 0, 381, 238 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Dialog" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - GROUPBOX "Dasher Popup:", IDC_STATIC, 7, 7, 180, 50 - CONTROL "Enable Popup Window", IDC_POPUP_ENABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 18, 110, 10 - CONTROL "Use External Monitor", IDC_POPUP_EXTERNAL, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 30, 110, 10 - CONTROL "Always On Top", IDC_POPUP_ALWAYSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 42, 110, 10 - GROUPBOX "Popup Style:", IDC_STATIC, 7, 60, 180, 40 - PUSHBUTTON "Change Font", IDC_DFONT_BUTTON, 12, 75, 166, 14 -END - IDD_MODULESETTINGS DIALOGEX 0, 0, 309, 177 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" @@ -334,14 +321,6 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 170 END - - IDS_PREFS_POPUP, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 374 - TOPMARGIN, 7 - BOTTOMMARGIN, 231 - END END #endif // APSTUDIO_INVOKED @@ -503,16 +482,9 @@ BEGIN IDS_UNTITLED_FILE "Untitled" IDS_UNSAVED_CHANGES "Unsaved changes" IDS_PREFS_LM "Application" - IDS_PREFS_POPUP "External Display" IDS_ERR_SOCKET_TITLE "Dasher Socket Input error" END -STRINGTABLE -BEGIN - IDC_POPUP_QUICK "Popup" -END - - #endif // English (United Kingdom) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/Src/Win32/Dasher.vcxproj b/Src/Win32/Dasher.vcxproj index a4c8d9bfd..bd984ef66 100644 --- a/Src/Win32/Dasher.vcxproj +++ b/Src/Win32/Dasher.vcxproj @@ -170,8 +170,6 @@ - - @@ -198,8 +196,6 @@ - - diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp index fed35a06c..2273b4422 100644 --- a/Src/Win32/DasherWindow.cpp +++ b/Src/Win32/DasherWindow.cpp @@ -57,7 +57,6 @@ CDasherWindow::CDasherWindow(const wstring& configName) : m_configName(configNam m_pAppSettings = 0; m_pToolbar = 0; m_pEdit = 0; - m_pPopup = 0; m_pSpeedAlphabetBar = 0; m_pSplitter = 0; m_pDasher = 0; @@ -94,6 +93,8 @@ HWND CDasherWindow::Create() { m_pAppSettings = new CAppSettings(0, 0, settings); // Takes ownership of the settings store. int iStyle(m_pAppSettings->GetLongParameter(APP_LP_STYLE)); + HWND hWnd; + if (iStyle == APP_STYLE_DIRECT) { hWnd = CWindowImpl::Create(NULL, NULL, WindowTitle.c_str(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, WS_EX_NOACTIVATE | WS_EX_APPWINDOW | WS_EX_TOPMOST); ::SetMenu(hWnd, NULL); @@ -108,12 +109,7 @@ HWND CDasherWindow::Create() { m_pEdit->Create(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP)); m_pEdit->SetFont(m_pAppSettings->GetStringParameter(APP_SP_EDIT_FONT), m_pAppSettings->GetLongParameter(APP_LP_EDIT_FONT_SIZE)); - // Create Pop-Out Window - for multiple display support - m_pPopup = new CPopup(m_pAppSettings); - m_pPopup->Create(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP)); - m_pPopup->SetFont(m_pAppSettings->GetStringParameter(APP_SP_POPUP_FONT), m_pAppSettings->GetLongParameter(APP_LP_POPUP_FONT_SIZE)); - - m_pDasher = new CDasher(hWnd, this, m_pEdit, m_pPopup, settings, &fileUtils); + m_pDasher = new CDasher(hWnd, this, m_pEdit, settings, &fileUtils); // Create a CAppSettings m_pAppSettings->SetHwnd(hWnd); @@ -125,7 +121,6 @@ HWND CDasherWindow::Create() { // but at the moment it does, for training, blanking the display etc m_pEdit->SetInterface(m_pDasher); - m_pPopup->SetInterface(m_pDasher); m_pSpeedAlphabetBar = new CStatusControl(m_pDasher->GetSettingsUser(), m_pAppSettings); m_pSpeedAlphabetBar->Create(hWnd); @@ -141,7 +136,6 @@ HWND CDasherWindow::Create() { CDasherWindow::~CDasherWindow() { delete m_pToolbar; delete m_pEdit; - delete m_pPopup; delete m_pSplitter; delete m_pDasher; delete m_pSpeedAlphabetBar; @@ -151,6 +145,7 @@ CDasherWindow::~CDasherWindow() { } void CDasherWindow::Show(int nCmdShow) { + RECT r = { m_pAppSettings->GetLongParameter(APP_LP_X), m_pAppSettings->GetLongParameter(APP_LP_Y), @@ -165,15 +160,7 @@ void CDasherWindow::Show(int nCmdShow) { nCmdShow = SW_MAXIMIZE; ShowWindow(nCmdShow); } -//This starts a brute force timer to update the popup window display -void CDasherWindow::configurePopupTimer(bool enable){ - if (enable) { - ::SetTimer(hWnd, 2, 1270, TIMERPROC(NULL)); - } - else { - ::KillTimer(hWnd, 2); - } -} + void CDasherWindow::HandleParameterChange(int iParameter) { switch (iParameter) { case APP_BP_SHOW_TOOLBAR: @@ -236,10 +223,6 @@ LRESULT CDasherWindow::OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOO CPrefs Prefs(m_hWnd, m_pDasher, m_pAppSettings); return 0; } - case ID_QUICK_POPUP: { - m_pPopup->processToolbarButtonPress(); - return 0; - } case ID_HELP_CONTENTS: HtmlHelp(m_hWnd, L"Dasher.chm", HH_DISPLAY_INDEX, NULL); return 0; @@ -392,15 +375,6 @@ LRESULT CDasherWindow::OnOther(UINT message, WPARAM wParam, LPARAM lParam, BOOL& return 0; } -/* Handles Timer Callbacks*/ -LRESULT CDasherWindow::OnTimer(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { - //Brute force timer to update the external display with a copy of the current Dasher edit display - //Timer should only be in use (created) by the Popup (when enabled) - string currentOutput = m_pEdit->getOutput(); - m_pPopup->updateDisplay(currentOutput); - return false; -} - void CDasherWindow::Layout() { if (!m_bFullyCreated) @@ -455,7 +429,6 @@ void CDasherWindow::Layout() { m_pEdit->Move(Width / 2, ToolbarHeight, Width - Width / 2, CanvasHeight); } m_pEdit->ShowWindow(SW_SHOW); - m_pPopup->setupPopup(); //Checks configuration and shows if enabled m_pSplitter->ShowWindow(SW_HIDE); break; @@ -487,7 +460,6 @@ void CDasherWindow::Layout() { m_pSplitter->Move(SplitterY, Width); } m_pEdit->ShowWindow(SW_SHOW); - m_pPopup->setupPopup(); //Checks configuration and shows if enabled m_pSplitter->ShowWindow(SW_SHOW); if (m_bSizeRestored) m_pAppSettings->SetLongParameter(APP_LP_EDIT_SIZE, EditHeight); diff --git a/Src/Win32/DasherWindow.h b/Src/Win32/DasherWindow.h index 89a2defd2..d7ec449a9 100644 --- a/Src/Win32/DasherWindow.h +++ b/Src/Win32/DasherWindow.h @@ -14,7 +14,6 @@ #include "Widgets/Splitter.h" #include "Widgets/StatusControl.h" #include "Widgets/Edit.h" -#include "Widgets/Popup.h" class CToolbar; namespace Dasher { @@ -40,7 +39,6 @@ class CDasherWindow : MESSAGE_HANDLER(WM_INITMENUPOPUP,OnInitMenuPopup) MESSAGE_HANDLER(WM_SETFOCUS,OnSetFocus) MESSAGE_HANDLER(WM_WINDOWPOSCHANGED,OnWindowPosChanged) - MESSAGE_HANDLER(WM_TIMER,OnTimer) MESSAGE_RANGE_HANDLER(0xC000,0xFFFF,OnOther) END_MSG_MAP() @@ -54,7 +52,6 @@ class CDasherWindow : LRESULT OnDestroy(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClose(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - LRESULT OnTimer(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // Create window (and children) @@ -62,7 +59,6 @@ class CDasherWindow : HWND Create(); void Show(int nCmdShow); - void configurePopupTimer(bool enable); void HandleWinEvent(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime); @@ -78,15 +74,12 @@ class CDasherWindow : bool m_bFullyCreated; Dasher::CDasher *m_pDasher; - - HWND hWnd; HACCEL hAccelTable; // Widgets: CToolbar *m_pToolbar; CEdit *m_pEdit; - CPopup *m_pPopup; //CCanvas *m_pCanvas; CSplitter *m_pSplitter; CStatusControl *m_pSpeedAlphabetBar; diff --git a/Src/Win32/UpgradeLog.htm b/Src/Win32/UpgradeLog.htm deleted file mode 100644 index 3c6c78886d909b9f47a9d4d45b2b19a45101287f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 38574 zcmeI5`BNLolE?ek-H81kH0HfAvmS1n!}B~7LI@jkn9E>$aJ;~XTO3B5o_YJH@9yVY zNm1P`(Nc@UOgus%b$19qOIsS+KZ~u zuhD-+{~4)77oS2@i&mr4Xg#WMzY!fp2b3yAC)`z|S5arw%cn1T9{ohQFXWy8=Vi1V z?Q>nH)IPt*)DSd-T>!dotq`5NR`+S=C3iKRYYy@g*Tz1nwP=m<>*TI--^F#C6k$^1 zy8-kro`u)T%i71$6WUTM>(r^Z`#p!pDwwFOVW;0$lwIe!i}q^V8zqjTLsHhGucU6% zf0ZgF>UBj^z}}BGDY44$x~tpMv@KEPoOXMzXz+`}X$vSvU?6I}0_HJ2>w>a_xo}#H zF2FpF%Q5&LL(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dq!Fo5adqHeA&)?U;=F1#P(q_qEeo|9YlkMfkNP}gh9v>eByX+dsHtHkrvRx7$D zUMD`v|4LfMG~xA{LStW&niUyMN2ISC>-9QQZ{SMm!`kHuAL+0-eYGFZP9OO*Oj^H8 zwp2rgvsU{3YND>DcP&QWx&+0&rL+Xa^IDalc%4TH3hO#azGhk7Yzd0f_u)y9qoq2e&>3cYR#iuw>fw9 zaj|sN&tq34Hlk>#j~i+CSh8n!CLn%NO1qenv`F_c2|=anwYtJJP>MJw&(nZ2_{w9|XF zSetDirty(true); } -std::string CEdit::getOutput() { - CString displayText; - GetWindowText(displayText); - std::wstring s(displayText); - return WinUTF8::wstring_to_UTF8string(s.c_str()); -} - void CEdit::TNew(const Tstring &filename) { // TODO: Send a message to the parent to say that the buffer has // changed (as in the Linux version). diff --git a/Src/Win32/Widgets/Edit.h b/Src/Win32/Widgets/Edit.h index 341833d1d..b6cd43fc4 100644 --- a/Src/Win32/Widgets/Edit.h +++ b/Src/Win32/Widgets/Edit.h @@ -74,6 +74,7 @@ class CEdit : public ATL::CWindowImpl { HRESULT OnKeyUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); HRESULT OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + void Move(int x, int y, int Width, int Height); unsigned int OffsetAfterMove(unsigned int offsetBefore, bool bForwards, Dasher::CControlManager::EditDistance iDist); @@ -112,9 +113,6 @@ class CEdit : public ATL::CWindowImpl { //ACL Making these public so can be called directly from CDasher void HandleParameterChange(int iParameter); - //Expose current text- Used by the Popup Window to update external display window - std::string getOutput(); - protected: bool m_dirty; diff --git a/Src/Win32/Widgets/Popup.cpp b/Src/Win32/Widgets/Popup.cpp deleted file mode 100644 index cc3400a85..000000000 --- a/Src/Win32/Widgets/Popup.cpp +++ /dev/null @@ -1,301 +0,0 @@ -// Popup.cpp -// -// Copyright (c) 2016 The Dasher Team -// -// This file is part of Dasher. -// -// Dasher 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. -// -// Dasher 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 Dasher; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -// -// NOTES: Created by Jeremy Cope to facilitate extended (multiple) displays. -// - -#include "WinCommon.h" - -#include "Popup.h" -#include -#include "../../DasherCore/Event.h" -#include "FilenameGUI.h" -#include "../resource.h" -#include "../../DasherCore/DasherInterfaceBase.h" -#include "../Dasher.h" - -/** -* This class manages the external popup window -* to be used to be used on an 2nd monitor (extended display). -* -* Known Issues: -* -> Setting the font- seems to capture size but not name -* -* -* -*/ - - -using namespace Dasher; -using namespace std; -using namespace WinLocalisation; -using namespace WinUTF8; - -BOOL contains(RECT rectA, RECT rectB); -BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); - - -/** -* Constructors, Destructors, Initializers, Setup Functions -*/ -CPopup::CPopup(CAppSettings *pAppSettings) { - m_pAppSettings = pAppSettings; - - UINT CodePage = GetUserCodePage(); - m_Font = GetCodePageFont(CodePage, 14); - - m_setup = false; - m_externalMonitorRect = RECT(); - m_dasherWindwowRect = RECT(); - m_popupRect = RECT(); -} - -HWND CPopup::Create(HWND hParent, bool bNewWithDate) { - RECT r = getInitialWindow(); - m_popup = CWindowImpl::Create(hParent, r, NULL, WS_OVERLAPPEDWINDOW| ES_MULTILINE ); - return *this; -} - -CPopup::~CPopup() { - DeleteObject(m_Font); -} - -void CPopup::setupPopup() { - if (!m_setup) { - m_setup = true; - - //Calculate the size of the windows,displays - calculateDisplayProperties(); - - //Determine the placement of the popup - positionPopup(); - - //If enabled, show and start the auto update timer - if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true) { - //Show the Popup - ShowWindow(SW_SHOW); - //Fire the update timer - CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation - dasher->configurePopupTimer(true); - } - } -} - -void CPopup::SetFont(string Name, long Size) { - Tstring FontName; - UTF8string_to_wstring(Name, FontName); - - if(Size == 0) - Size = 14; - - DeleteObject(m_Font); - if (Name == "") { - UINT CodePage = GetUserCodePage(); - m_Font = GetCodePageFont(CodePage, -Size); - } - else { - m_Font = CreateFont(-Size, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, FontName.c_str()); // DEFAULT_CHARSET => font made just from Size and FontName - } - SendMessage(WM_SETFONT, (WPARAM) m_Font, true); -} - -void CPopup::SetInterface(Dasher::CDasherInterfaceBase *DasherInterface) { - m_pDasherInterface = DasherInterface; -} - - -/** -* Text Display Management- used to update the display with different text -*/ -//Timer callback function -void CPopup::updateDisplay(const std::string sText) { - //If the display output has changed.. update the popup window - if (sText.compare(m_Output) != 0) { - m_Output = sText; - output(m_Output); - } -} -//Exposed Method so outside classes can force an update on the screen -void CPopup::output(const std::string &sText) { - wstring String; - WinUTF8::UTF8string_to_wstring(sText, String); - InsertText(String); -} -//Actually updates the window with the provided text -void CPopup::InsertText(Tstring InsertText) { - //Update entire screen - SendMessage(WM_SETTEXT, TRUE, (LPARAM)InsertText.c_str()); - //Scroll to bottom - SendMessage(EM_LINESCROLL, 0, INT_MAX); //Force to end of buffer with max integer -} - - -/** -* Popup Actionables- called when parameter changes in settings, or toolbar button is pressed -* BUG: Seems to be called twice on parameter changes -*/ -void CPopup::HandleParameterChange(int iParameter) { - switch(iParameter) { - case APP_SP_POPUP_FONT: - case APP_LP_POPUP_FONT_SIZE: - SetFont(m_pAppSettings->GetStringParameter(APP_SP_POPUP_FONT), m_pAppSettings->GetLongParameter(APP_LP_POPUP_FONT_SIZE)); - break; - case APP_BP_POPUP_ENABLE: - if(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true){ - ShowWindow(SW_SHOW); - CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation - dasher->configurePopupTimer(true); - } - else { - ShowWindow(SW_HIDE); - } - break; - case APP_BP_POPUP_EXTERNAL_SCREEN: - positionPopup(); - break; - case APP_BP_POPUP_INFRONT: - break; - default: - break; - } -} -//Toolbar quick action ignores 'use external monitor' setting -//Forces external monitor usages (fi exists) -bool CPopup::processToolbarButtonPress() { - bool popupEnabled = false; - popupEnabled = m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE); - //Action depends on current status - if (popupEnabled == false) { - //Quick button possitions fully on the external monitor, if monitor exists - LPRECT popupDisplayRect; - if (isExtMonitorDetected()) { - popupDisplayRect = &m_externalMonitorRect; - } - else { - popupDisplayRect = &m_popupRect; - } - MoveWindow(popupDisplayRect); - } - - //Update the state flag - popupEnabled = !popupEnabled; - m_pAppSettings->SetBoolParameter(APP_BP_POPUP_ENABLE, popupEnabled); //Setting the parameter triggers action - //Return the current state - return popupEnabled; -} - -/** -* Popup Management and Placement -*/ -void CPopup::Move(int x, int y, int Width, int Height) { - MoveWindow(x, y, Width, Height, TRUE); -} - -RECT CPopup::getInitialWindow() { - RECT rect; - rect = { - 1000,100,1800,500 - }; - return rect; -} - -void CPopup::calculateDisplayProperties() { - getDasherWidnowInfo(); - //Warning, assync call, enumerates all displays - getMonitorInfo(); -} - -void CPopup::positionPopup() { - LPRECT popupDisplayRect; - if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN) == true) { - //May have setting to use external, but does external screen exists? - if (isExtMonitorDetected()) { - popupDisplayRect = &m_externalMonitorRect; - } - else { - popupDisplayRect = &m_popupRect; - } - } - else { - popupDisplayRect = &m_popupRect; - } - - //Redraw in the correct location - MoveWindow(popupDisplayRect, true); -} - -bool CPopup::isExtMonitorDetected() { - bool retVal = false; - if (!IsRectEmpty(&m_externalMonitorRect)){ - retVal = true; - } - return retVal; -} - -void CPopup::getMonitorInfo(){ - RECT* userData[2] = { &m_dasherWindwowRect, &m_externalMonitorRect }; - EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&userData); -} - -void CPopup::getDasherWidnowInfo() { - //Get Dasher Window position and size - CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation - int iTop = 0; - int iLeft = 0; - int iBottom = 0; - int iRight = 0; - - dasher->GetWindowSize(&iTop, &iLeft, &iBottom, &iRight); - - m_dasherWindwowRect.top = iTop; - m_dasherWindwowRect.left = iLeft; - m_dasherWindwowRect.right = iRight; - m_dasherWindwowRect.bottom = iBottom; - - //Initialize our window based on the dasher window - m_popupRect.top = m_dasherWindwowRect.top + 100; - m_popupRect.left = m_dasherWindwowRect.left + 100; - m_popupRect.right = m_dasherWindwowRect.right + 100; - m_popupRect.bottom = m_dasherWindwowRect.top + (m_dasherWindwowRect.bottom - m_dasherWindwowRect.top)/2; -} - -BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { - RECT monitorCoordinates = *lprcMonitor; - RECT** userData = (RECT**)dwData; - RECT* dasherRect = userData[0]; - RECT* externRect = userData[1]; - - //If this monitor contains the dasher Window, it is primary monitor - //Else it is external monitor, and should be used for popup. - //Else window spans multiple monitors.. - if (contains(monitorCoordinates, *dasherRect)) { - - } - else { - //Never called if no extra monitor - *externRect = monitorCoordinates; - } - return TRUE; -} - -BOOL contains(RECT rectA, RECT rectB) { - return (rectA.left < rectB.right && rectA.right > rectB.left && - rectA.top < rectB.bottom && rectA.bottom > rectB.top); -} \ No newline at end of file diff --git a/Src/Win32/Widgets/Popup.h b/Src/Win32/Widgets/Popup.h deleted file mode 100644 index 868edf01f..000000000 --- a/Src/Win32/Widgets/Popup.h +++ /dev/null @@ -1,110 +0,0 @@ -// Popup.cpp -// -// Copyright (c) 2016 The Dasher Team -// -// This file is part of Dasher. -// -// Dasher 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. -// -// Dasher 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 Dasher; if not, write to the Free Software -// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -#ifndef __Popup_h__ -#define __Popup_h__ - -#define _ATL_APARTMENT_THREADED -#include - -//You may derive a class from CComModule and use it if you want to override something, - -//but do not change the name of _Module - -extern CComModule _Module; - -#include - -#include "../AppSettings.h" -#include "../DasherAction.h" -#include "../../DasherCore/DasherTypes.h" -#include "../../DasherCore/ControlManager.h" -#include - -class CCanvas; -class CFilenameGUI; - -namespace Dasher { - class CDasherInterfaceBase; - class CEvent; -}; - -class CPopup : public ATL::CWindowImpl { - public: - - CPopup(CAppSettings *pAppSettings); - ~CPopup(); - - HWND Create(HWND hParent, bool bNewWithDate); - void setupPopup(); //Call once Dasher has been drawn, so we can determine placement - - // Superclass the built-in EDIT window class - DECLARE_WND_SUPERCLASS(NULL, _T("EDIT")) - - BEGIN_MSG_MAP(CPopup) - - END_MSG_MAP() - - void Move(int x, int y, int Width, int Height); - - void SetFont(std::string Name, long Size); - - void SetInterface(Dasher::CDasherInterfaceBase * DasherInterface); - - // called when a new character falls under the crosshair - void output(const std::string & sText); - - void updateDisplay(const std::string sText); - - //ACL Making these public so can be called directly from CDasher - void HandleParameterChange(int iParameter); - - //Called when the quick enable button is pressed in the toolbar - bool processToolbarButtonPress(); - - protected: - bool m_dirty; - - private: - Dasher::CDasherInterfaceBase *m_pDasherInterface; - CAppSettings *m_pAppSettings; - - bool m_setup; - HWND Parent; - HWND m_popup; - HWND m_hTarget; - HFONT m_Font; - HWND targetwindow; - std::string m_Output; // UTF-8 to go to training file - RECT m_dasherWindwowRect; - RECT m_externalMonitorRect; - RECT m_popupRect; //The current rect being used for the popup - - void InsertText(Tstring InsertText); // add symbol to edit control - RECT getInitialWindow(); - void calculateDisplayProperties(); - void positionPopup(); - void getDasherWidnowInfo(); - void getMonitorInfo(); - bool isExtMonitorDetected(); - -}; - -#endif /* #ifndef __CPopup_h__ */ diff --git a/Src/Win32/Widgets/PopupPage.cpp b/Src/Win32/Widgets/PopupPage.cpp deleted file mode 100644 index 4d10239c1..000000000 --- a/Src/Win32/Widgets/PopupPage.cpp +++ /dev/null @@ -1,198 +0,0 @@ -// AlphabetBox.cpp -// -///////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge. -// -///////////////////////////////////////////////////////////////////////////// - -#include "WinCommon.h" - -#include "PopupPage.h" -#include "../resource.h" - -#include // for std::pair - -using namespace Dasher; -using namespace std; - -// Track memory leaks on Windows to the line that new'd the memory -#ifdef _WIN32 -#ifdef _DEBUG -#define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ ) -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif -#endif - -CPopupPage::CPopupPage(HWND Parent, CAppSettings *pAppSettings) -:CPrefsPageBase(Parent, pAppSettings) { - - m_CurrentColours = pAppSettings->GetStringParameter(SP_COLOUR_ID); -} - -struct menuentry { - int paramNum; // enum value in Parameters.h for setting store - int idcNum; // #define value in resource.h for dasher.rc -}; - -// List of menu items that will be displayed in the General Preferences -static menuentry menutable[] = { - {BP_DRAW_MOUSE, IDC_DRAWMOUSE}, - {BP_DRAW_MOUSE_LINE, IDC_DRAWMOUSELINE}, -}; - -void CPopupPage::PopulateList() { - // Populate the controls in the dialogue box based on the relevent parameters - // in m_pDasher - //Popup Enabled - if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true) { - SendMessage(GetDlgItem(m_hwnd, IDC_POPUP_ENABLE), BM_SETCHECK, BST_CHECKED, 0); - } - if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN) == true) { - SendMessage(GetDlgItem(m_hwnd, IDC_POPUP_EXTERNAL), BM_SETCHECK, BST_CHECKED, 0); - } - // TODO: Annoying inversion makes this hard - if(m_pAppSettings->GetBoolParameter(BP_PALETTE_CHANGE)) { - SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_SETCHECK, BST_UNCHECKED, 0); - EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), FALSE); - } - else { - SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_SETCHECK, BST_CHECKED, 0); - EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), TRUE); - } - - for(int ii = 0; iiGetBoolParameter(menutable[ii].paramNum)) { - SendMessage(GetDlgItem(m_hwnd, menutable[ii].idcNum), BM_SETCHECK, BST_CHECKED, 0); - } - else { - SendMessage(GetDlgItem(m_hwnd, menutable[ii].idcNum), BM_SETCHECK, BST_UNCHECKED, 0); - } - } - - - HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS); - m_pAppSettings->GetPermittedValues(SP_COLOUR_ID, ColourList); - - // Add each string to list box and index each one - bool SelectionSet = false; - for(unsigned int i = 0; i < ColourList.size(); i++) { - Tstring Item; - WinUTF8::UTF8string_to_wstring(ColourList[i], Item); - LRESULT Index = SendMessage(ListBox, LB_ADDSTRING, 0, (LPARAM) Item.c_str()); - SendMessage(ListBox, LB_SETITEMDATA, Index, (LPARAM) i); - if(ColourList[i] == m_CurrentColours) { - SendMessage(ListBox, LB_SETCURSEL, Index, 0); - SelectionSet = true; - } - } - if(SelectionSet == false) { - SendMessage(ListBox, LB_SETCURSEL, 0, 0); - LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, 0, 0); - m_CurrentColours = ColourList[CurrentIndex]; - } - // Tell list box that we have set an item for it (so that delete and edit can be grayed if required) - SendMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_COLOURS, LBN_SELCHANGE), 0); - - if(m_pAppSettings->GetLongParameter(LP_LINE_WIDTH) > 1) - SendMessage(GetDlgItem(m_hwnd, IDC_THICKLINE), BM_SETCHECK, BST_CHECKED, 0); - else - SendMessage(GetDlgItem(m_hwnd, IDC_THICKLINE), BM_SETCHECK, BST_UNCHECKED, 0); - - SendMessage(GetDlgItem(m_hwnd, IDC_OUTLINE), BM_SETCHECK, - m_pAppSettings->GetLongParameter(LP_OUTLINE_WIDTH) ? BST_CHECKED : BST_UNCHECKED, 0); - - if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::Normal) { - SendMessage(GetDlgItem(m_hwnd, IDC_FONT_SMALL), BM_SETCHECK, BST_CHECKED, 0); - } - else if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::Big) { - SendMessage(GetDlgItem(m_hwnd, IDC_FONT_LARGE), BM_SETCHECK, BST_CHECKED, 0); - } - else if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::VBig) { - SendMessage(GetDlgItem(m_hwnd, IDC_FONT_VLARGE), BM_SETCHECK, BST_CHECKED, 0); - } -} - - -bool CPopupPage::Apply() { - if(m_CurrentColours != std::string("")) { - m_pAppSettings->SetStringParameter(SP_COLOUR_ID, m_CurrentColours); - } - - m_pAppSettings->SetBoolParameter(BP_PALETTE_CHANGE, - SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_GETCHECK, 0, 0) == BST_UNCHECKED ); - - if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_SMALL), BM_GETCHECK, 0, 0) == BST_CHECKED) - m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::Normal); - else if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_LARGE), BM_GETCHECK, 0, 0) == BST_CHECKED) - m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::Big); - else if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_VLARGE), BM_GETCHECK, 0, 0) == BST_CHECKED) - m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::VBig); - - // Return false (and notify the user) if something is wrong. - return TRUE; -} - -LRESULT CPopupPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) { - // most things we pass on to CPrefsPageBase, but we need to handle slider motion - switch (message) { - case WM_COMMAND: - if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == LBN_SELCHANGE) { - if (LOWORD(wParam) != 0 && m_hPropertySheet != 0 && m_hwnd != 0) { - PropSheet_Changed(m_hPropertySheet, m_hwnd); // enables the 'Apply' button - // Behaviour isn't *perfect* since it activates the Apply button even if you, say, - // click 'new' alphabet then click Cancel when asked for a name. - } - } - switch (LOWORD(wParam)) { - case (IDC_COLOURS): - if (HIWORD(wParam) == LBN_SELCHANGE) { - HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS); - LRESULT CurrentItem = SendMessage(ListBox, LB_GETCURSEL, 0, 0); - LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, CurrentItem, 0); - m_CurrentColours = ColourList[CurrentIndex]; - } - return TRUE; - break; - case IDC_DFONT_BUTTON: // TODO: Put this in a function - { - CHOOSEFONT Data; - LOGFONT lf; - HFONT Font = (HFONT)GetStockObject(DEFAULT_GUI_FONT); - GetObject(Font, sizeof(LOGFONT), &lf); - Tstring tstrFaceName; - WinUTF8::UTF8string_to_wstring(m_pAppSettings->GetStringParameter(SP_DASHER_FONT), tstrFaceName); - _tcscpy(lf.lfFaceName, tstrFaceName.c_str()); - Data.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS; - Data.lStructSize = sizeof(CHOOSEFONT); - // TODO: Give this an owner - Data.hwndOwner = NULL; - Data.lpLogFont = &lf; - if (ChooseFont(&Data)) { - string FontName; - WinUTF8::wstring_to_UTF8string(lf.lfFaceName, FontName); - m_pAppSettings->SetStringParameter(APP_SP_POPUP_FONT, FontName); - m_pAppSettings->SetLongParameter(APP_LP_POPUP_FONT_SIZE, lf.lfHeight); - } - } - break; - case IDC_COLOURSCHEME: - EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_GETCHECK, 0, 0) == BST_CHECKED); - break; - case IDC_POPUP_ENABLE: - m_pAppSettings->SetBoolParameter(APP_BP_POPUP_ENABLE, !(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE))); - break; - case IDC_POPUP_EXTERNAL: - m_pAppSettings->SetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN, !(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN))); - break; - case IDC_POPUP_ALWAYSTOP: - //TODO: Track setting of alwasy on top of windows - break; - default: - break; - } - } - return CPrefsPageBase::WndProc(Window, message, wParam, lParam); -} diff --git a/Src/Win32/Widgets/PopupPage.h b/Src/Win32/Widgets/PopupPage.h deleted file mode 100644 index 64621a9c5..000000000 --- a/Src/Win32/Widgets/PopupPage.h +++ /dev/null @@ -1,38 +0,0 @@ -// ViewPage.h -// -///////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge. -// -///////////////////////////////////////////////////////////////////////////// - -#ifndef __PopupPage_h__ -#define __PopupPage_h__ - -#include "PrefsPageBase.h" - -#include "../resource.h" -#include "../AppSettings.h" - -#include "../Dasher.h" -#include "../../DasherCore/ColourIO.h" - -class CPopupPage:public CPrefsPageBase { -public: - CPopupPage(HWND Parent, CAppSettings *pAppSettings); - LRESULT WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam); - -private: - std::vector < std::string > ColourList; - std::string m_CurrentColours; - Dasher::CColourIO::ColourInfo CurrentInfo; - - // Some status flags: - void PopulateList(); - void InitCustomBox(); - bool UpdateInfo(); - bool Apply(); - -}; - -#endif /* #ifndef */ diff --git a/Src/Win32/Widgets/Prefs.cpp b/Src/Win32/Widgets/Prefs.cpp index b2ce57d7c..055eae9d2 100644 --- a/Src/Win32/Widgets/Prefs.cpp +++ b/Src/Win32/Widgets/Prefs.cpp @@ -28,12 +28,10 @@ CPrefs::CPrefs(HWND hParent, CDasher *pDasher, CAppSettings *pAppSettings) { m_pControlPage = new CControlPage(hParent, pDasher, pAppSettings); m_pViewPage = new CViewPage(hParent, pAppSettings); m_pAdvancedPage = new CAdvancedPage(hParent, pAppSettings); - m_pPopupPage = new CPopupPage(hParent, pAppSettings); - // Set up the property sheets which go into the preferences // dialogue. - PROPSHEETPAGE psp[5]; + PROPSHEETPAGE psp[4]; memset(psp, 0, sizeof(psp)); psp[0].dwSize = sizeof(PROPSHEETPAGE); psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE | PSP_PREMATURE; @@ -74,16 +72,6 @@ CPrefs::CPrefs(HWND hParent, CDasher *pDasher, CAppSettings *pAppSettings) { psp[3].pszTitle = MAKEINTRESOURCE(IDS_PREFS_LM); psp[3].lParam = (LPARAM) m_pAdvancedPage; psp[3].pfnCallback = NULL; - - psp[4].dwSize = sizeof(PROPSHEETPAGE); - psp[4].dwFlags = PSP_USEICONID | PSP_USETITLE | PSP_PREMATURE; - psp[4].hInstance = WinHelper::hInstApp; - psp[4].pszTemplate = MAKEINTRESOURCE(IDS_PREFS_POPUP); - psp[4].pszIcon = NULL; - psp[4].pfnDlgProc = (DLGPROC)WinWrapMap::PSWndProc; - psp[4].pszTitle = MAKEINTRESOURCE(IDS_PREFS_POPUP); - psp[4].lParam = (LPARAM)m_pPopupPage; - psp[4].pfnCallback = NULL; PROPSHEETHEADER psh; memset(&psh, 0, sizeof(psh)); diff --git a/Src/Win32/Widgets/Prefs.h b/Src/Win32/Widgets/Prefs.h index f9401d900..6401381dc 100644 --- a/Src/Win32/Widgets/Prefs.h +++ b/Src/Win32/Widgets/Prefs.h @@ -17,7 +17,6 @@ #include "ControlPage.h" #include "ViewPage.h" #include "AdvancedPage.h" -#include "PopupPage.h" #include "../AppSettings.h" namespace Dasher { @@ -37,7 +36,6 @@ class CPrefs:public CWinWrap { CControlPage *m_pControlPage; CViewPage *m_pViewPage; CAdvancedPage *m_pAdvancedPage; - CPopupPage *m_pPopupPage; }; #endif /* #ifndef __PrefsBox_h__ */ diff --git a/Src/Win32/Widgets/Toolbar.cpp b/Src/Win32/Widgets/Toolbar.cpp index 74238120a..1e6dde145 100644 --- a/Src/Win32/Widgets/Toolbar.cpp +++ b/Src/Win32/Widgets/Toolbar.cpp @@ -41,10 +41,7 @@ SToolbarButton sButtons[] = { {-2, 5, IDS_EDIT_COPY_ALL, ID_EDIT_COPY_ALL}, {STD_PASTE, 6, IDS_EDIT_PASTE, ID_EDIT_PASTE}, {-1, -1, 0, 0}, - {STD_PROPERTIES, 7, IDS_OPTIONS_PREFS, ID_OPTIONS_PREFS}, - { -1, -1, 0, 0 }, - //External Display - { STD_PRINTPRE, 8, IDC_POPUP_QUICK, ID_QUICK_POPUP }, + {STD_PROPERTIES, 7, IDS_OPTIONS_PREFS, ID_OPTIONS_PREFS} }; CToolbar::CToolbar(HWND hParent, bool bVisible) { @@ -70,7 +67,9 @@ void CToolbar::ShowToolbar(bool bValue) { void CToolbar::CreateToolbar() { WinHelper::InitCommonControlLib(); - + + + m_hRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, diff --git a/Src/Win32/Widgets/ViewPage.cpp b/Src/Win32/Widgets/ViewPage.cpp index 162b0e3a6..ec3a67753 100644 --- a/Src/Win32/Widgets/ViewPage.cpp +++ b/Src/Win32/Widgets/ViewPage.cpp @@ -148,6 +148,7 @@ bool CViewPage::Apply() { } LRESULT CViewPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) { + // most things we pass on to CPrefsPageBase, but we need to handle slider motion switch (message) { diff --git a/Src/Win32/resource.h b/Src/Win32/resource.h index 054a2447c..cde219a58 100644 --- a/Src/Win32/resource.h +++ b/Src/Win32/resource.h @@ -36,7 +36,6 @@ #define IDD_APPEARANCEPAGE 178 #define IDD_APPPAGE 179 #define IDD_MODULESETTINGS 180 -#define IDS_PREFS_POPUP 181 #define IDD_STATUSBAR 182 #define IDC_INPUT_LIST 1008 #define IDC_CONTROL_LIST 1009 @@ -92,16 +91,9 @@ #define IDC_CHECK5 1157 #define IDC_CONTROLBOXES 1160 #define IDC_FILE_ENCODING 1161 -#define IDC_POPUP_ENABLE 1162 -#define IDC_POPUP_EXTERNAL 1163 -#define IDC_POPUP_ALWAYSTOP 1164 -#define IDC_SPEED_EDIT 1165 -#define IDC_SPEED_SPIN 1166 -#define IDC_ALPHABET_COMBO 1167 - -#define IDC_POPUP_QUICK 1170 -#define ID_QUICK_POPUP 1171 - +#define IDC_SPEED_EDIT 1163 +#define IDC_SPEED_SPIN 1164 +#define IDC_ALPHABET_COMBO 1166 #define ID_EDIT_SELECTALL 32775 #define ID_HELP_CONTENTS 32776 #define ID_EDIT_COPY_ALL 32798 From f45ce4a519d30af69156846ecd658d0b5ff8ee55 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Fri, 7 Apr 2017 16:37:37 -0400 Subject: [PATCH 3/3] Popup Display Window for Extended Monitor Support (#114) Broke out the edit window into a newly created popup window. A timer in the main dasher grabs the current display text on the edit window and presents it on the popup window. Preference Page also added and a Quick Mode button on the tool bar. Preferences include font size, window placement, and auto detect additional monitors. **Not the most efficient implementation- enhancements will follow. --- Src/Common/AppSettingsData.h | 7 +- Src/Common/AppSettingsHeader.h | 8 +- Src/Win32/Dasher.cpp | 11 +- Src/Win32/Dasher.h | 9 +- Src/Win32/Dasher.rc | 28 +++ Src/Win32/Dasher.vcxproj | 4 + Src/Win32/DasherWindow.cpp | 38 +++- Src/Win32/DasherWindow.h | 7 + Src/Win32/Widgets/AdvancedPage.cpp | 2 +- Src/Win32/Widgets/Edit.cpp | 7 + Src/Win32/Widgets/Edit.h | 4 +- Src/Win32/Widgets/Popup.cpp | 301 +++++++++++++++++++++++++++++ Src/Win32/Widgets/Popup.h | 110 +++++++++++ Src/Win32/Widgets/PopupPage.cpp | 198 +++++++++++++++++++ Src/Win32/Widgets/PopupPage.h | 38 ++++ Src/Win32/Widgets/Prefs.cpp | 14 +- Src/Win32/Widgets/Prefs.h | 2 + Src/Win32/Widgets/Toolbar.cpp | 9 +- Src/Win32/Widgets/ViewPage.cpp | 1 - Src/Win32/resource.h | 14 +- 20 files changed, 788 insertions(+), 24 deletions(-) create mode 100644 Src/Win32/Widgets/Popup.cpp create mode 100644 Src/Win32/Widgets/Popup.h create mode 100644 Src/Win32/Widgets/PopupPage.cpp create mode 100644 Src/Win32/Widgets/PopupPage.h diff --git a/Src/Common/AppSettingsData.h b/Src/Common/AppSettingsData.h index 5beddc2dc..3aaed26a9 100644 --- a/Src/Common/AppSettingsData.h +++ b/Src/Common/AppSettingsData.h @@ -26,7 +26,10 @@ Dasher::Settings::bp_table app_boolparamtable[] = { { APP_BP_TIME_STAMP, "TimeStampNewFiles", Persistence::PERSISTENT, true, "TimeStampNewFiles" }, { APP_BP_CONFIRM_UNSAVED, "ConfirmUnsavedFiles", Persistence::PERSISTENT, true, "ConfirmUnsavedFiles" }, - {APP_BP_SHOW_TOOLBAR, "ViewToolbar", Persistence::PERSISTENT, true, "ViewToolbar"}, + { APP_BP_SHOW_TOOLBAR, "ViewToolbar", Persistence::PERSISTENT, true, "ViewToolbar"}, + { APP_BP_POPUP_ENABLE, "PopupEnable", Persistence::PERSISTENT, false, "PopupEnable"}, + { APP_BP_POPUP_EXTERNAL_SCREEN, "PopupFullScreen", Persistence::PERSISTENT, false, "PopupFullScreen"}, + { APP_BP_POPUP_INFRONT, "PopupInfront", Persistence::PERSISTENT, false, "PopupInfront"}, #ifdef WITH_MAEMO { APP_BP_SHOW_STATUSBAR, "ViewStatusbar", Persistence::PERSISTENT, false, "ViewStatusbar" }, #else @@ -39,6 +42,7 @@ Dasher::Settings::bp_table app_boolparamtable[] = { Dasher::Settings::lp_table app_longparamtable[] = { {APP_LP_FILE_ENCODING, "FileEncodingFormat", Persistence::PERSISTENT, -1, "FileEncodingFormat"}, {APP_LP_EDIT_FONT_SIZE, "EditFontSize", Persistence::PERSISTENT, 0, "EditFontSize"}, + {APP_LP_POPUP_FONT_SIZE, "PopupFontSize", Persistence::PERSISTENT, 0, "PopupFontSize"}, {APP_LP_EDIT_SIZE, "EditSize", Persistence::PERSISTENT, 75, "The size of the edit window"}, {APP_LP_SCREEN_WIDTH, "ScreenWidth", Persistence::PERSISTENT, 400, "ScreenWidth"}, {APP_LP_SCREEN_HEIGHT, "ScreenHeight", Persistence::PERSISTENT, 500, "ScreenHeight"}, @@ -55,6 +59,7 @@ Dasher::Settings::sp_table app_stringparamtable[] = { {APP_SP_EDIT_FONT, "EditFont", Persistence::PERSISTENT, "Sans 20", "EditFont"}, #else {APP_SP_EDIT_FONT, "EditFont", Persistence::PERSISTENT, "Sans 10", "EditFont"}, + {APP_SP_POPUP_FONT, "PopupFont", Persistence::PERSISTENT, "Sans 10", "PopupFont"}, #endif { APP_SP_TOOLBAR_ID, "ToolbarID", Persistence::PERSISTENT, "", "ToolbarID" }, }; diff --git a/Src/Common/AppSettingsHeader.h b/Src/Common/AppSettingsHeader.h index bde7e7e21..20f9d068a 100644 --- a/Src/Common/AppSettingsHeader.h +++ b/Src/Common/AppSettingsHeader.h @@ -8,11 +8,14 @@ enum { APP_BP_TIME_STAMP = END_OF_SPS, APP_BP_CONFIRM_UNSAVED, APP_BP_SHOW_TOOLBAR, - APP_BP_SHOW_STATUSBAR, APP_BP_MIRROR_LAYOUT, APP_BP_FULL_SCREEN, END_OF_APP_BPS + APP_BP_SHOW_STATUSBAR, APP_BP_MIRROR_LAYOUT, APP_BP_FULL_SCREEN, + APP_BP_POPUP_ENABLE, APP_BP_POPUP_EXTERNAL_SCREEN, APP_BP_POPUP_INFRONT, + END_OF_APP_BPS }; enum { APP_LP_FILE_ENCODING = END_OF_APP_BPS, APP_LP_EDIT_FONT_SIZE, // TODO Extract font size from APP_SP_EDIT_FONT as linux + APP_LP_POPUP_FONT_SIZE, APP_LP_EDIT_SIZE, APP_LP_SCREEN_WIDTH, APP_LP_SCREEN_HEIGHT, APP_LP_STYLE, APP_LP_X, APP_LP_Y, @@ -23,7 +26,8 @@ enum { }; enum { - APP_SP_EDIT_FONT = END_OF_APP_LPS, + APP_SP_EDIT_FONT = END_OF_APP_LPS, + APP_SP_POPUP_FONT, APP_SP_TOOLBAR_ID, END_OF_APP_SPS }; diff --git a/Src/Win32/Dasher.cpp b/Src/Win32/Dasher.cpp index f515d3873..1728f2dcf 100644 --- a/Src/Win32/Dasher.cpp +++ b/Src/Win32/Dasher.cpp @@ -10,6 +10,7 @@ #include "DasherMouseInput.h" #include "DasherWindow.h" #include "Widgets/Edit.h" +#include "Widgets/Popup.h" #include "Sockets/SocketInput.h" #include "BTSocketInput.h" @@ -26,8 +27,8 @@ using namespace WinUTF8; CONST UINT WM_DASHER_FOCUS = RegisterWindowMessage(L"WM_DASHER_FOCUS"); -CDasher::CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, Dasher::CSettingsStore* settings, CFileUtils* fileUtils) - : CDashIntfScreenMsgs(settings, fileUtils), m_hParent(Parent), m_pWindow(pWindow), m_pEdit(pEdit) { +CDasher::CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, CPopup *pPopup, Dasher::CSettingsStore* settings, CFileUtils* fileUtils) + : CDashIntfScreenMsgs(settings, fileUtils), m_hParent(Parent), m_pWindow(pWindow), m_pEdit(pEdit), m_pPopup(pPopup) { // This class will be a wrapper for the Dasher 'control' - think ActiveX // Set up COM for the accessibility stuff @@ -109,6 +110,7 @@ void Dasher::CDasher::HandleEvent(int iParameter) { CDashIntfScreenMsgs::HandleEvent(iParameter); m_pWindow->HandleParameterChange(iParameter); m_pEdit->HandleParameterChange(iParameter); + m_pPopup->HandleParameterChange(iParameter); if (iParameter == SP_DASHER_FONT) m_pCanvas->SetFont(GetStringParameter(SP_DASHER_FONT)); } @@ -350,3 +352,8 @@ int CDasher::GetAllContextLenght(){ std::string CDasher::GetTextAroundCursor(CControlManager::EditDistance iDist) { return m_pEdit->GetTextAroundCursor(iDist); } + +void CDasher::configurePopupTimer(bool enable) { + //Timer is managed by the window object + m_pWindow->configurePopupTimer(enable); +} \ No newline at end of file diff --git a/Src/Win32/Dasher.h b/Src/Win32/Dasher.h index fce443a4f..63e1370af 100644 --- a/Src/Win32/Dasher.h +++ b/Src/Win32/Dasher.h @@ -15,6 +15,7 @@ extern CONST UINT WM_DASHER_FOCUS; class CCanvas; class CEdit; +class CPopup; class CDasherWindow; namespace Dasher { @@ -35,7 +36,7 @@ class CWinFileUtils :public CFileUtils { class CDasher : public CDashIntfScreenMsgs { public: - CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, Dasher::CSettingsStore* settings, CFileUtils* fileUtils); + CDasher(HWND Parent, CDasherWindow *pWindow, CEdit *pEdit, CPopup *pPopup, Dasher::CSettingsStore* settings, CFileUtils* fileUtils); ~CDasher(void); // The following functions will not be part of the final interface @@ -70,18 +71,20 @@ class CDasher : public CDashIntfScreenMsgs #endif bool SupportsClipboard() override { return true; }; void CopyToClipboard(const std::string &text) override; - + bool GetWindowSize(int* pTop, int* pLeft, int* pBottom, int* pRight); + void configurePopupTimer(bool enable); private: virtual void CreateModules() override; void ScanDirectory(const Tstring &strMask, std::vector &vFileList); - bool GetWindowSize(int* pTop, int* pLeft, int* pBottom, int* pRight); + void Log(); // Does the logging CCanvas *m_pCanvas; HWND m_hParent; CDasherWindow *m_pWindow; CEdit *m_pEdit; + CPopup *m_pPopup; #ifdef WIN32_SPEECH ISpVoice* getVoice(const string& lang); CComPtr m_pDefaultVoice; diff --git a/Src/Win32/Dasher.rc b/Src/Win32/Dasher.rc index 80f57e31f..ed3fab7d1 100644 --- a/Src/Win32/Dasher.rc +++ b/Src/Win32/Dasher.rc @@ -251,6 +251,19 @@ BEGIN GROUPBOX "File Encoding:",IDC_STATIC,193,194,180,30 END +IDS_PREFS_POPUP DIALOGEX 0, 0, 381, 238 +STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU +CAPTION "Dialog" +FONT 8, "MS Shell Dlg", 400, 0, 0x1 +BEGIN + GROUPBOX "Dasher Popup:", IDC_STATIC, 7, 7, 180, 50 + CONTROL "Enable Popup Window", IDC_POPUP_ENABLE, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 18, 110, 10 + CONTROL "Use External Monitor", IDC_POPUP_EXTERNAL, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 30, 110, 10 + CONTROL "Always On Top", IDC_POPUP_ALWAYSTOP, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 12, 42, 110, 10 + GROUPBOX "Popup Style:", IDC_STATIC, 7, 60, 180, 40 + PUSHBUTTON "Change Font", IDC_DFONT_BUTTON, 12, 75, 166, 14 +END + IDD_MODULESETTINGS DIALOGEX 0, 0, 309, 177 STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Dialog" @@ -321,6 +334,14 @@ BEGIN TOPMARGIN, 7 BOTTOMMARGIN, 170 END + + IDS_PREFS_POPUP, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 374 + TOPMARGIN, 7 + BOTTOMMARGIN, 231 + END END #endif // APSTUDIO_INVOKED @@ -482,9 +503,16 @@ BEGIN IDS_UNTITLED_FILE "Untitled" IDS_UNSAVED_CHANGES "Unsaved changes" IDS_PREFS_LM "Application" + IDS_PREFS_POPUP "External Display" IDS_ERR_SOCKET_TITLE "Dasher Socket Input error" END +STRINGTABLE +BEGIN + IDC_POPUP_QUICK "Popup" +END + + #endif // English (United Kingdom) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/Src/Win32/Dasher.vcxproj b/Src/Win32/Dasher.vcxproj index bd984ef66..a4c8d9bfd 100644 --- a/Src/Win32/Dasher.vcxproj +++ b/Src/Win32/Dasher.vcxproj @@ -170,6 +170,8 @@ + + @@ -196,6 +198,8 @@ + + diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp index 2273b4422..fed35a06c 100644 --- a/Src/Win32/DasherWindow.cpp +++ b/Src/Win32/DasherWindow.cpp @@ -57,6 +57,7 @@ CDasherWindow::CDasherWindow(const wstring& configName) : m_configName(configNam m_pAppSettings = 0; m_pToolbar = 0; m_pEdit = 0; + m_pPopup = 0; m_pSpeedAlphabetBar = 0; m_pSplitter = 0; m_pDasher = 0; @@ -93,8 +94,6 @@ HWND CDasherWindow::Create() { m_pAppSettings = new CAppSettings(0, 0, settings); // Takes ownership of the settings store. int iStyle(m_pAppSettings->GetLongParameter(APP_LP_STYLE)); - HWND hWnd; - if (iStyle == APP_STYLE_DIRECT) { hWnd = CWindowImpl::Create(NULL, NULL, WindowTitle.c_str(), WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, WS_EX_NOACTIVATE | WS_EX_APPWINDOW | WS_EX_TOPMOST); ::SetMenu(hWnd, NULL); @@ -109,7 +108,12 @@ HWND CDasherWindow::Create() { m_pEdit->Create(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP)); m_pEdit->SetFont(m_pAppSettings->GetStringParameter(APP_SP_EDIT_FONT), m_pAppSettings->GetLongParameter(APP_LP_EDIT_FONT_SIZE)); - m_pDasher = new CDasher(hWnd, this, m_pEdit, settings, &fileUtils); + // Create Pop-Out Window - for multiple display support + m_pPopup = new CPopup(m_pAppSettings); + m_pPopup->Create(hWnd, m_pAppSettings->GetBoolParameter(APP_BP_TIME_STAMP)); + m_pPopup->SetFont(m_pAppSettings->GetStringParameter(APP_SP_POPUP_FONT), m_pAppSettings->GetLongParameter(APP_LP_POPUP_FONT_SIZE)); + + m_pDasher = new CDasher(hWnd, this, m_pEdit, m_pPopup, settings, &fileUtils); // Create a CAppSettings m_pAppSettings->SetHwnd(hWnd); @@ -121,6 +125,7 @@ HWND CDasherWindow::Create() { // but at the moment it does, for training, blanking the display etc m_pEdit->SetInterface(m_pDasher); + m_pPopup->SetInterface(m_pDasher); m_pSpeedAlphabetBar = new CStatusControl(m_pDasher->GetSettingsUser(), m_pAppSettings); m_pSpeedAlphabetBar->Create(hWnd); @@ -136,6 +141,7 @@ HWND CDasherWindow::Create() { CDasherWindow::~CDasherWindow() { delete m_pToolbar; delete m_pEdit; + delete m_pPopup; delete m_pSplitter; delete m_pDasher; delete m_pSpeedAlphabetBar; @@ -145,7 +151,6 @@ CDasherWindow::~CDasherWindow() { } void CDasherWindow::Show(int nCmdShow) { - RECT r = { m_pAppSettings->GetLongParameter(APP_LP_X), m_pAppSettings->GetLongParameter(APP_LP_Y), @@ -160,7 +165,15 @@ void CDasherWindow::Show(int nCmdShow) { nCmdShow = SW_MAXIMIZE; ShowWindow(nCmdShow); } - +//This starts a brute force timer to update the popup window display +void CDasherWindow::configurePopupTimer(bool enable){ + if (enable) { + ::SetTimer(hWnd, 2, 1270, TIMERPROC(NULL)); + } + else { + ::KillTimer(hWnd, 2); + } +} void CDasherWindow::HandleParameterChange(int iParameter) { switch (iParameter) { case APP_BP_SHOW_TOOLBAR: @@ -223,6 +236,10 @@ LRESULT CDasherWindow::OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOO CPrefs Prefs(m_hWnd, m_pDasher, m_pAppSettings); return 0; } + case ID_QUICK_POPUP: { + m_pPopup->processToolbarButtonPress(); + return 0; + } case ID_HELP_CONTENTS: HtmlHelp(m_hWnd, L"Dasher.chm", HH_DISPLAY_INDEX, NULL); return 0; @@ -375,6 +392,15 @@ LRESULT CDasherWindow::OnOther(UINT message, WPARAM wParam, LPARAM lParam, BOOL& return 0; } +/* Handles Timer Callbacks*/ +LRESULT CDasherWindow::OnTimer(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + //Brute force timer to update the external display with a copy of the current Dasher edit display + //Timer should only be in use (created) by the Popup (when enabled) + string currentOutput = m_pEdit->getOutput(); + m_pPopup->updateDisplay(currentOutput); + return false; +} + void CDasherWindow::Layout() { if (!m_bFullyCreated) @@ -429,6 +455,7 @@ void CDasherWindow::Layout() { m_pEdit->Move(Width / 2, ToolbarHeight, Width - Width / 2, CanvasHeight); } m_pEdit->ShowWindow(SW_SHOW); + m_pPopup->setupPopup(); //Checks configuration and shows if enabled m_pSplitter->ShowWindow(SW_HIDE); break; @@ -460,6 +487,7 @@ void CDasherWindow::Layout() { m_pSplitter->Move(SplitterY, Width); } m_pEdit->ShowWindow(SW_SHOW); + m_pPopup->setupPopup(); //Checks configuration and shows if enabled m_pSplitter->ShowWindow(SW_SHOW); if (m_bSizeRestored) m_pAppSettings->SetLongParameter(APP_LP_EDIT_SIZE, EditHeight); diff --git a/Src/Win32/DasherWindow.h b/Src/Win32/DasherWindow.h index d7ec449a9..89a2defd2 100644 --- a/Src/Win32/DasherWindow.h +++ b/Src/Win32/DasherWindow.h @@ -14,6 +14,7 @@ #include "Widgets/Splitter.h" #include "Widgets/StatusControl.h" #include "Widgets/Edit.h" +#include "Widgets/Popup.h" class CToolbar; namespace Dasher { @@ -39,6 +40,7 @@ class CDasherWindow : MESSAGE_HANDLER(WM_INITMENUPOPUP,OnInitMenuPopup) MESSAGE_HANDLER(WM_SETFOCUS,OnSetFocus) MESSAGE_HANDLER(WM_WINDOWPOSCHANGED,OnWindowPosChanged) + MESSAGE_HANDLER(WM_TIMER,OnTimer) MESSAGE_RANGE_HANDLER(0xC000,0xFFFF,OnOther) END_MSG_MAP() @@ -52,6 +54,7 @@ class CDasherWindow : LRESULT OnDestroy(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnClose(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); + LRESULT OnTimer(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); // Create window (and children) @@ -59,6 +62,7 @@ class CDasherWindow : HWND Create(); void Show(int nCmdShow); + void configurePopupTimer(bool enable); void HandleWinEvent(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD dwEventThread, DWORD dwmsEventTime); @@ -74,12 +78,15 @@ class CDasherWindow : bool m_bFullyCreated; Dasher::CDasher *m_pDasher; + + HWND hWnd; HACCEL hAccelTable; // Widgets: CToolbar *m_pToolbar; CEdit *m_pEdit; + CPopup *m_pPopup; //CCanvas *m_pCanvas; CSplitter *m_pSplitter; CStatusControl *m_pSpeedAlphabetBar; diff --git a/Src/Win32/Widgets/AdvancedPage.cpp b/Src/Win32/Widgets/AdvancedPage.cpp index a68f042ce..61102c0ef 100644 --- a/Src/Win32/Widgets/AdvancedPage.cpp +++ b/Src/Win32/Widgets/AdvancedPage.cpp @@ -178,7 +178,7 @@ LRESULT CAdvancedPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM switch (LOWORD(wParam)) { case IDC_EFONT_BUTTON: - // TODO: Put this in a function + // TODO: Put this in a function { CHOOSEFONT Data; LOGFONT lf; diff --git a/Src/Win32/Widgets/Edit.cpp b/Src/Win32/Widgets/Edit.cpp index b7d0c0776..6f57360f9 100644 --- a/Src/Win32/Widgets/Edit.cpp +++ b/Src/Win32/Widgets/Edit.cpp @@ -161,6 +161,13 @@ void CEdit::SetDirty() { m_FilenameGUI->SetDirty(true); } +std::string CEdit::getOutput() { + CString displayText; + GetWindowText(displayText); + std::wstring s(displayText); + return WinUTF8::wstring_to_UTF8string(s.c_str()); +} + void CEdit::TNew(const Tstring &filename) { // TODO: Send a message to the parent to say that the buffer has // changed (as in the Linux version). diff --git a/Src/Win32/Widgets/Edit.h b/Src/Win32/Widgets/Edit.h index b6cd43fc4..341833d1d 100644 --- a/Src/Win32/Widgets/Edit.h +++ b/Src/Win32/Widgets/Edit.h @@ -74,7 +74,6 @@ class CEdit : public ATL::CWindowImpl { HRESULT OnKeyUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); HRESULT OnCommand(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled); - void Move(int x, int y, int Width, int Height); unsigned int OffsetAfterMove(unsigned int offsetBefore, bool bForwards, Dasher::CControlManager::EditDistance iDist); @@ -113,6 +112,9 @@ class CEdit : public ATL::CWindowImpl { //ACL Making these public so can be called directly from CDasher void HandleParameterChange(int iParameter); + //Expose current text- Used by the Popup Window to update external display window + std::string getOutput(); + protected: bool m_dirty; diff --git a/Src/Win32/Widgets/Popup.cpp b/Src/Win32/Widgets/Popup.cpp new file mode 100644 index 000000000..cc3400a85 --- /dev/null +++ b/Src/Win32/Widgets/Popup.cpp @@ -0,0 +1,301 @@ +// Popup.cpp +// +// Copyright (c) 2016 The Dasher Team +// +// This file is part of Dasher. +// +// Dasher 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. +// +// Dasher 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 Dasher; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +// +// NOTES: Created by Jeremy Cope to facilitate extended (multiple) displays. +// + +#include "WinCommon.h" + +#include "Popup.h" +#include +#include "../../DasherCore/Event.h" +#include "FilenameGUI.h" +#include "../resource.h" +#include "../../DasherCore/DasherInterfaceBase.h" +#include "../Dasher.h" + +/** +* This class manages the external popup window +* to be used to be used on an 2nd monitor (extended display). +* +* Known Issues: +* -> Setting the font- seems to capture size but not name +* +* +* +*/ + + +using namespace Dasher; +using namespace std; +using namespace WinLocalisation; +using namespace WinUTF8; + +BOOL contains(RECT rectA, RECT rectB); +BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); + + +/** +* Constructors, Destructors, Initializers, Setup Functions +*/ +CPopup::CPopup(CAppSettings *pAppSettings) { + m_pAppSettings = pAppSettings; + + UINT CodePage = GetUserCodePage(); + m_Font = GetCodePageFont(CodePage, 14); + + m_setup = false; + m_externalMonitorRect = RECT(); + m_dasherWindwowRect = RECT(); + m_popupRect = RECT(); +} + +HWND CPopup::Create(HWND hParent, bool bNewWithDate) { + RECT r = getInitialWindow(); + m_popup = CWindowImpl::Create(hParent, r, NULL, WS_OVERLAPPEDWINDOW| ES_MULTILINE ); + return *this; +} + +CPopup::~CPopup() { + DeleteObject(m_Font); +} + +void CPopup::setupPopup() { + if (!m_setup) { + m_setup = true; + + //Calculate the size of the windows,displays + calculateDisplayProperties(); + + //Determine the placement of the popup + positionPopup(); + + //If enabled, show and start the auto update timer + if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true) { + //Show the Popup + ShowWindow(SW_SHOW); + //Fire the update timer + CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation + dasher->configurePopupTimer(true); + } + } +} + +void CPopup::SetFont(string Name, long Size) { + Tstring FontName; + UTF8string_to_wstring(Name, FontName); + + if(Size == 0) + Size = 14; + + DeleteObject(m_Font); + if (Name == "") { + UINT CodePage = GetUserCodePage(); + m_Font = GetCodePageFont(CodePage, -Size); + } + else { + m_Font = CreateFont(-Size, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, FontName.c_str()); // DEFAULT_CHARSET => font made just from Size and FontName + } + SendMessage(WM_SETFONT, (WPARAM) m_Font, true); +} + +void CPopup::SetInterface(Dasher::CDasherInterfaceBase *DasherInterface) { + m_pDasherInterface = DasherInterface; +} + + +/** +* Text Display Management- used to update the display with different text +*/ +//Timer callback function +void CPopup::updateDisplay(const std::string sText) { + //If the display output has changed.. update the popup window + if (sText.compare(m_Output) != 0) { + m_Output = sText; + output(m_Output); + } +} +//Exposed Method so outside classes can force an update on the screen +void CPopup::output(const std::string &sText) { + wstring String; + WinUTF8::UTF8string_to_wstring(sText, String); + InsertText(String); +} +//Actually updates the window with the provided text +void CPopup::InsertText(Tstring InsertText) { + //Update entire screen + SendMessage(WM_SETTEXT, TRUE, (LPARAM)InsertText.c_str()); + //Scroll to bottom + SendMessage(EM_LINESCROLL, 0, INT_MAX); //Force to end of buffer with max integer +} + + +/** +* Popup Actionables- called when parameter changes in settings, or toolbar button is pressed +* BUG: Seems to be called twice on parameter changes +*/ +void CPopup::HandleParameterChange(int iParameter) { + switch(iParameter) { + case APP_SP_POPUP_FONT: + case APP_LP_POPUP_FONT_SIZE: + SetFont(m_pAppSettings->GetStringParameter(APP_SP_POPUP_FONT), m_pAppSettings->GetLongParameter(APP_LP_POPUP_FONT_SIZE)); + break; + case APP_BP_POPUP_ENABLE: + if(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true){ + ShowWindow(SW_SHOW); + CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation + dasher->configurePopupTimer(true); + } + else { + ShowWindow(SW_HIDE); + } + break; + case APP_BP_POPUP_EXTERNAL_SCREEN: + positionPopup(); + break; + case APP_BP_POPUP_INFRONT: + break; + default: + break; + } +} +//Toolbar quick action ignores 'use external monitor' setting +//Forces external monitor usages (fi exists) +bool CPopup::processToolbarButtonPress() { + bool popupEnabled = false; + popupEnabled = m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE); + //Action depends on current status + if (popupEnabled == false) { + //Quick button possitions fully on the external monitor, if monitor exists + LPRECT popupDisplayRect; + if (isExtMonitorDetected()) { + popupDisplayRect = &m_externalMonitorRect; + } + else { + popupDisplayRect = &m_popupRect; + } + MoveWindow(popupDisplayRect); + } + + //Update the state flag + popupEnabled = !popupEnabled; + m_pAppSettings->SetBoolParameter(APP_BP_POPUP_ENABLE, popupEnabled); //Setting the parameter triggers action + //Return the current state + return popupEnabled; +} + +/** +* Popup Management and Placement +*/ +void CPopup::Move(int x, int y, int Width, int Height) { + MoveWindow(x, y, Width, Height, TRUE); +} + +RECT CPopup::getInitialWindow() { + RECT rect; + rect = { + 1000,100,1800,500 + }; + return rect; +} + +void CPopup::calculateDisplayProperties() { + getDasherWidnowInfo(); + //Warning, assync call, enumerates all displays + getMonitorInfo(); +} + +void CPopup::positionPopup() { + LPRECT popupDisplayRect; + if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN) == true) { + //May have setting to use external, but does external screen exists? + if (isExtMonitorDetected()) { + popupDisplayRect = &m_externalMonitorRect; + } + else { + popupDisplayRect = &m_popupRect; + } + } + else { + popupDisplayRect = &m_popupRect; + } + + //Redraw in the correct location + MoveWindow(popupDisplayRect, true); +} + +bool CPopup::isExtMonitorDetected() { + bool retVal = false; + if (!IsRectEmpty(&m_externalMonitorRect)){ + retVal = true; + } + return retVal; +} + +void CPopup::getMonitorInfo(){ + RECT* userData[2] = { &m_dasherWindwowRect, &m_externalMonitorRect }; + EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&userData); +} + +void CPopup::getDasherWidnowInfo() { + //Get Dasher Window position and size + CDasher* dasher = (CDasher*)m_pDasherInterface; //Cast for concrete implementation + int iTop = 0; + int iLeft = 0; + int iBottom = 0; + int iRight = 0; + + dasher->GetWindowSize(&iTop, &iLeft, &iBottom, &iRight); + + m_dasherWindwowRect.top = iTop; + m_dasherWindwowRect.left = iLeft; + m_dasherWindwowRect.right = iRight; + m_dasherWindwowRect.bottom = iBottom; + + //Initialize our window based on the dasher window + m_popupRect.top = m_dasherWindwowRect.top + 100; + m_popupRect.left = m_dasherWindwowRect.left + 100; + m_popupRect.right = m_dasherWindwowRect.right + 100; + m_popupRect.bottom = m_dasherWindwowRect.top + (m_dasherWindwowRect.bottom - m_dasherWindwowRect.top)/2; +} + +BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { + RECT monitorCoordinates = *lprcMonitor; + RECT** userData = (RECT**)dwData; + RECT* dasherRect = userData[0]; + RECT* externRect = userData[1]; + + //If this monitor contains the dasher Window, it is primary monitor + //Else it is external monitor, and should be used for popup. + //Else window spans multiple monitors.. + if (contains(monitorCoordinates, *dasherRect)) { + + } + else { + //Never called if no extra monitor + *externRect = monitorCoordinates; + } + return TRUE; +} + +BOOL contains(RECT rectA, RECT rectB) { + return (rectA.left < rectB.right && rectA.right > rectB.left && + rectA.top < rectB.bottom && rectA.bottom > rectB.top); +} \ No newline at end of file diff --git a/Src/Win32/Widgets/Popup.h b/Src/Win32/Widgets/Popup.h new file mode 100644 index 000000000..868edf01f --- /dev/null +++ b/Src/Win32/Widgets/Popup.h @@ -0,0 +1,110 @@ +// Popup.cpp +// +// Copyright (c) 2016 The Dasher Team +// +// This file is part of Dasher. +// +// Dasher 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. +// +// Dasher 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 Dasher; if not, write to the Free Software +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +#ifndef __Popup_h__ +#define __Popup_h__ + +#define _ATL_APARTMENT_THREADED +#include + +//You may derive a class from CComModule and use it if you want to override something, + +//but do not change the name of _Module + +extern CComModule _Module; + +#include + +#include "../AppSettings.h" +#include "../DasherAction.h" +#include "../../DasherCore/DasherTypes.h" +#include "../../DasherCore/ControlManager.h" +#include + +class CCanvas; +class CFilenameGUI; + +namespace Dasher { + class CDasherInterfaceBase; + class CEvent; +}; + +class CPopup : public ATL::CWindowImpl { + public: + + CPopup(CAppSettings *pAppSettings); + ~CPopup(); + + HWND Create(HWND hParent, bool bNewWithDate); + void setupPopup(); //Call once Dasher has been drawn, so we can determine placement + + // Superclass the built-in EDIT window class + DECLARE_WND_SUPERCLASS(NULL, _T("EDIT")) + + BEGIN_MSG_MAP(CPopup) + + END_MSG_MAP() + + void Move(int x, int y, int Width, int Height); + + void SetFont(std::string Name, long Size); + + void SetInterface(Dasher::CDasherInterfaceBase * DasherInterface); + + // called when a new character falls under the crosshair + void output(const std::string & sText); + + void updateDisplay(const std::string sText); + + //ACL Making these public so can be called directly from CDasher + void HandleParameterChange(int iParameter); + + //Called when the quick enable button is pressed in the toolbar + bool processToolbarButtonPress(); + + protected: + bool m_dirty; + + private: + Dasher::CDasherInterfaceBase *m_pDasherInterface; + CAppSettings *m_pAppSettings; + + bool m_setup; + HWND Parent; + HWND m_popup; + HWND m_hTarget; + HFONT m_Font; + HWND targetwindow; + std::string m_Output; // UTF-8 to go to training file + RECT m_dasherWindwowRect; + RECT m_externalMonitorRect; + RECT m_popupRect; //The current rect being used for the popup + + void InsertText(Tstring InsertText); // add symbol to edit control + RECT getInitialWindow(); + void calculateDisplayProperties(); + void positionPopup(); + void getDasherWidnowInfo(); + void getMonitorInfo(); + bool isExtMonitorDetected(); + +}; + +#endif /* #ifndef __CPopup_h__ */ diff --git a/Src/Win32/Widgets/PopupPage.cpp b/Src/Win32/Widgets/PopupPage.cpp new file mode 100644 index 000000000..4d10239c1 --- /dev/null +++ b/Src/Win32/Widgets/PopupPage.cpp @@ -0,0 +1,198 @@ +// AlphabetBox.cpp +// +///////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge. +// +///////////////////////////////////////////////////////////////////////////// + +#include "WinCommon.h" + +#include "PopupPage.h" +#include "../resource.h" + +#include // for std::pair + +using namespace Dasher; +using namespace std; + +// Track memory leaks on Windows to the line that new'd the memory +#ifdef _WIN32 +#ifdef _DEBUG +#define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ ) +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif +#endif + +CPopupPage::CPopupPage(HWND Parent, CAppSettings *pAppSettings) +:CPrefsPageBase(Parent, pAppSettings) { + + m_CurrentColours = pAppSettings->GetStringParameter(SP_COLOUR_ID); +} + +struct menuentry { + int paramNum; // enum value in Parameters.h for setting store + int idcNum; // #define value in resource.h for dasher.rc +}; + +// List of menu items that will be displayed in the General Preferences +static menuentry menutable[] = { + {BP_DRAW_MOUSE, IDC_DRAWMOUSE}, + {BP_DRAW_MOUSE_LINE, IDC_DRAWMOUSELINE}, +}; + +void CPopupPage::PopulateList() { + // Populate the controls in the dialogue box based on the relevent parameters + // in m_pDasher + //Popup Enabled + if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE) == true) { + SendMessage(GetDlgItem(m_hwnd, IDC_POPUP_ENABLE), BM_SETCHECK, BST_CHECKED, 0); + } + if (m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN) == true) { + SendMessage(GetDlgItem(m_hwnd, IDC_POPUP_EXTERNAL), BM_SETCHECK, BST_CHECKED, 0); + } + // TODO: Annoying inversion makes this hard + if(m_pAppSettings->GetBoolParameter(BP_PALETTE_CHANGE)) { + SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_SETCHECK, BST_UNCHECKED, 0); + EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), FALSE); + } + else { + SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_SETCHECK, BST_CHECKED, 0); + EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), TRUE); + } + + for(int ii = 0; iiGetBoolParameter(menutable[ii].paramNum)) { + SendMessage(GetDlgItem(m_hwnd, menutable[ii].idcNum), BM_SETCHECK, BST_CHECKED, 0); + } + else { + SendMessage(GetDlgItem(m_hwnd, menutable[ii].idcNum), BM_SETCHECK, BST_UNCHECKED, 0); + } + } + + + HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS); + m_pAppSettings->GetPermittedValues(SP_COLOUR_ID, ColourList); + + // Add each string to list box and index each one + bool SelectionSet = false; + for(unsigned int i = 0; i < ColourList.size(); i++) { + Tstring Item; + WinUTF8::UTF8string_to_wstring(ColourList[i], Item); + LRESULT Index = SendMessage(ListBox, LB_ADDSTRING, 0, (LPARAM) Item.c_str()); + SendMessage(ListBox, LB_SETITEMDATA, Index, (LPARAM) i); + if(ColourList[i] == m_CurrentColours) { + SendMessage(ListBox, LB_SETCURSEL, Index, 0); + SelectionSet = true; + } + } + if(SelectionSet == false) { + SendMessage(ListBox, LB_SETCURSEL, 0, 0); + LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, 0, 0); + m_CurrentColours = ColourList[CurrentIndex]; + } + // Tell list box that we have set an item for it (so that delete and edit can be grayed if required) + SendMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_COLOURS, LBN_SELCHANGE), 0); + + if(m_pAppSettings->GetLongParameter(LP_LINE_WIDTH) > 1) + SendMessage(GetDlgItem(m_hwnd, IDC_THICKLINE), BM_SETCHECK, BST_CHECKED, 0); + else + SendMessage(GetDlgItem(m_hwnd, IDC_THICKLINE), BM_SETCHECK, BST_UNCHECKED, 0); + + SendMessage(GetDlgItem(m_hwnd, IDC_OUTLINE), BM_SETCHECK, + m_pAppSettings->GetLongParameter(LP_OUTLINE_WIDTH) ? BST_CHECKED : BST_UNCHECKED, 0); + + if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::Normal) { + SendMessage(GetDlgItem(m_hwnd, IDC_FONT_SMALL), BM_SETCHECK, BST_CHECKED, 0); + } + else if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::Big) { + SendMessage(GetDlgItem(m_hwnd, IDC_FONT_LARGE), BM_SETCHECK, BST_CHECKED, 0); + } + else if(m_pAppSettings->GetLongParameter(LP_DASHER_FONTSIZE) == Dasher::Opts::VBig) { + SendMessage(GetDlgItem(m_hwnd, IDC_FONT_VLARGE), BM_SETCHECK, BST_CHECKED, 0); + } +} + + +bool CPopupPage::Apply() { + if(m_CurrentColours != std::string("")) { + m_pAppSettings->SetStringParameter(SP_COLOUR_ID, m_CurrentColours); + } + + m_pAppSettings->SetBoolParameter(BP_PALETTE_CHANGE, + SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_GETCHECK, 0, 0) == BST_UNCHECKED ); + + if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_SMALL), BM_GETCHECK, 0, 0) == BST_CHECKED) + m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::Normal); + else if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_LARGE), BM_GETCHECK, 0, 0) == BST_CHECKED) + m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::Big); + else if(SendMessage(GetDlgItem(m_hwnd, IDC_FONT_VLARGE), BM_GETCHECK, 0, 0) == BST_CHECKED) + m_pAppSettings->SetLongParameter(LP_DASHER_FONTSIZE, Dasher::Opts::VBig); + + // Return false (and notify the user) if something is wrong. + return TRUE; +} + +LRESULT CPopupPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) { + // most things we pass on to CPrefsPageBase, but we need to handle slider motion + switch (message) { + case WM_COMMAND: + if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == LBN_SELCHANGE) { + if (LOWORD(wParam) != 0 && m_hPropertySheet != 0 && m_hwnd != 0) { + PropSheet_Changed(m_hPropertySheet, m_hwnd); // enables the 'Apply' button + // Behaviour isn't *perfect* since it activates the Apply button even if you, say, + // click 'new' alphabet then click Cancel when asked for a name. + } + } + switch (LOWORD(wParam)) { + case (IDC_COLOURS): + if (HIWORD(wParam) == LBN_SELCHANGE) { + HWND ListBox = GetDlgItem(m_hwnd, IDC_COLOURS); + LRESULT CurrentItem = SendMessage(ListBox, LB_GETCURSEL, 0, 0); + LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, CurrentItem, 0); + m_CurrentColours = ColourList[CurrentIndex]; + } + return TRUE; + break; + case IDC_DFONT_BUTTON: // TODO: Put this in a function + { + CHOOSEFONT Data; + LOGFONT lf; + HFONT Font = (HFONT)GetStockObject(DEFAULT_GUI_FONT); + GetObject(Font, sizeof(LOGFONT), &lf); + Tstring tstrFaceName; + WinUTF8::UTF8string_to_wstring(m_pAppSettings->GetStringParameter(SP_DASHER_FONT), tstrFaceName); + _tcscpy(lf.lfFaceName, tstrFaceName.c_str()); + Data.Flags = CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS; + Data.lStructSize = sizeof(CHOOSEFONT); + // TODO: Give this an owner + Data.hwndOwner = NULL; + Data.lpLogFont = &lf; + if (ChooseFont(&Data)) { + string FontName; + WinUTF8::wstring_to_UTF8string(lf.lfFaceName, FontName); + m_pAppSettings->SetStringParameter(APP_SP_POPUP_FONT, FontName); + m_pAppSettings->SetLongParameter(APP_LP_POPUP_FONT_SIZE, lf.lfHeight); + } + } + break; + case IDC_COLOURSCHEME: + EnableWindow(GetDlgItem(m_hwnd, IDC_COLOURS), SendMessage(GetDlgItem(m_hwnd, IDC_COLOURSCHEME), BM_GETCHECK, 0, 0) == BST_CHECKED); + break; + case IDC_POPUP_ENABLE: + m_pAppSettings->SetBoolParameter(APP_BP_POPUP_ENABLE, !(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_ENABLE))); + break; + case IDC_POPUP_EXTERNAL: + m_pAppSettings->SetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN, !(m_pAppSettings->GetBoolParameter(APP_BP_POPUP_EXTERNAL_SCREEN))); + break; + case IDC_POPUP_ALWAYSTOP: + //TODO: Track setting of alwasy on top of windows + break; + default: + break; + } + } + return CPrefsPageBase::WndProc(Window, message, wParam, lParam); +} diff --git a/Src/Win32/Widgets/PopupPage.h b/Src/Win32/Widgets/PopupPage.h new file mode 100644 index 000000000..64621a9c5 --- /dev/null +++ b/Src/Win32/Widgets/PopupPage.h @@ -0,0 +1,38 @@ +// ViewPage.h +// +///////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge. +// +///////////////////////////////////////////////////////////////////////////// + +#ifndef __PopupPage_h__ +#define __PopupPage_h__ + +#include "PrefsPageBase.h" + +#include "../resource.h" +#include "../AppSettings.h" + +#include "../Dasher.h" +#include "../../DasherCore/ColourIO.h" + +class CPopupPage:public CPrefsPageBase { +public: + CPopupPage(HWND Parent, CAppSettings *pAppSettings); + LRESULT WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam); + +private: + std::vector < std::string > ColourList; + std::string m_CurrentColours; + Dasher::CColourIO::ColourInfo CurrentInfo; + + // Some status flags: + void PopulateList(); + void InitCustomBox(); + bool UpdateInfo(); + bool Apply(); + +}; + +#endif /* #ifndef */ diff --git a/Src/Win32/Widgets/Prefs.cpp b/Src/Win32/Widgets/Prefs.cpp index 055eae9d2..b2ce57d7c 100644 --- a/Src/Win32/Widgets/Prefs.cpp +++ b/Src/Win32/Widgets/Prefs.cpp @@ -28,10 +28,12 @@ CPrefs::CPrefs(HWND hParent, CDasher *pDasher, CAppSettings *pAppSettings) { m_pControlPage = new CControlPage(hParent, pDasher, pAppSettings); m_pViewPage = new CViewPage(hParent, pAppSettings); m_pAdvancedPage = new CAdvancedPage(hParent, pAppSettings); + m_pPopupPage = new CPopupPage(hParent, pAppSettings); + // Set up the property sheets which go into the preferences // dialogue. - PROPSHEETPAGE psp[4]; + PROPSHEETPAGE psp[5]; memset(psp, 0, sizeof(psp)); psp[0].dwSize = sizeof(PROPSHEETPAGE); psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE | PSP_PREMATURE; @@ -72,6 +74,16 @@ CPrefs::CPrefs(HWND hParent, CDasher *pDasher, CAppSettings *pAppSettings) { psp[3].pszTitle = MAKEINTRESOURCE(IDS_PREFS_LM); psp[3].lParam = (LPARAM) m_pAdvancedPage; psp[3].pfnCallback = NULL; + + psp[4].dwSize = sizeof(PROPSHEETPAGE); + psp[4].dwFlags = PSP_USEICONID | PSP_USETITLE | PSP_PREMATURE; + psp[4].hInstance = WinHelper::hInstApp; + psp[4].pszTemplate = MAKEINTRESOURCE(IDS_PREFS_POPUP); + psp[4].pszIcon = NULL; + psp[4].pfnDlgProc = (DLGPROC)WinWrapMap::PSWndProc; + psp[4].pszTitle = MAKEINTRESOURCE(IDS_PREFS_POPUP); + psp[4].lParam = (LPARAM)m_pPopupPage; + psp[4].pfnCallback = NULL; PROPSHEETHEADER psh; memset(&psh, 0, sizeof(psh)); diff --git a/Src/Win32/Widgets/Prefs.h b/Src/Win32/Widgets/Prefs.h index 6401381dc..f9401d900 100644 --- a/Src/Win32/Widgets/Prefs.h +++ b/Src/Win32/Widgets/Prefs.h @@ -17,6 +17,7 @@ #include "ControlPage.h" #include "ViewPage.h" #include "AdvancedPage.h" +#include "PopupPage.h" #include "../AppSettings.h" namespace Dasher { @@ -36,6 +37,7 @@ class CPrefs:public CWinWrap { CControlPage *m_pControlPage; CViewPage *m_pViewPage; CAdvancedPage *m_pAdvancedPage; + CPopupPage *m_pPopupPage; }; #endif /* #ifndef __PrefsBox_h__ */ diff --git a/Src/Win32/Widgets/Toolbar.cpp b/Src/Win32/Widgets/Toolbar.cpp index 1e6dde145..74238120a 100644 --- a/Src/Win32/Widgets/Toolbar.cpp +++ b/Src/Win32/Widgets/Toolbar.cpp @@ -41,7 +41,10 @@ SToolbarButton sButtons[] = { {-2, 5, IDS_EDIT_COPY_ALL, ID_EDIT_COPY_ALL}, {STD_PASTE, 6, IDS_EDIT_PASTE, ID_EDIT_PASTE}, {-1, -1, 0, 0}, - {STD_PROPERTIES, 7, IDS_OPTIONS_PREFS, ID_OPTIONS_PREFS} + {STD_PROPERTIES, 7, IDS_OPTIONS_PREFS, ID_OPTIONS_PREFS}, + { -1, -1, 0, 0 }, + //External Display + { STD_PRINTPRE, 8, IDC_POPUP_QUICK, ID_QUICK_POPUP }, }; CToolbar::CToolbar(HWND hParent, bool bVisible) { @@ -67,9 +70,7 @@ void CToolbar::ShowToolbar(bool bValue) { void CToolbar::CreateToolbar() { WinHelper::InitCommonControlLib(); - - - + m_hRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, diff --git a/Src/Win32/Widgets/ViewPage.cpp b/Src/Win32/Widgets/ViewPage.cpp index ec3a67753..162b0e3a6 100644 --- a/Src/Win32/Widgets/ViewPage.cpp +++ b/Src/Win32/Widgets/ViewPage.cpp @@ -148,7 +148,6 @@ bool CViewPage::Apply() { } LRESULT CViewPage::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) { - // most things we pass on to CPrefsPageBase, but we need to handle slider motion switch (message) { diff --git a/Src/Win32/resource.h b/Src/Win32/resource.h index cde219a58..054a2447c 100644 --- a/Src/Win32/resource.h +++ b/Src/Win32/resource.h @@ -36,6 +36,7 @@ #define IDD_APPEARANCEPAGE 178 #define IDD_APPPAGE 179 #define IDD_MODULESETTINGS 180 +#define IDS_PREFS_POPUP 181 #define IDD_STATUSBAR 182 #define IDC_INPUT_LIST 1008 #define IDC_CONTROL_LIST 1009 @@ -91,9 +92,16 @@ #define IDC_CHECK5 1157 #define IDC_CONTROLBOXES 1160 #define IDC_FILE_ENCODING 1161 -#define IDC_SPEED_EDIT 1163 -#define IDC_SPEED_SPIN 1164 -#define IDC_ALPHABET_COMBO 1166 +#define IDC_POPUP_ENABLE 1162 +#define IDC_POPUP_EXTERNAL 1163 +#define IDC_POPUP_ALWAYSTOP 1164 +#define IDC_SPEED_EDIT 1165 +#define IDC_SPEED_SPIN 1166 +#define IDC_ALPHABET_COMBO 1167 + +#define IDC_POPUP_QUICK 1170 +#define ID_QUICK_POPUP 1171 + #define ID_EDIT_SELECTALL 32775 #define ID_HELP_CONTENTS 32776 #define ID_EDIT_COPY_ALL 32798