[dasher: 176/217] Added Mirror layout config option.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 176/217] Added Mirror layout config option.
- Date: Sat, 27 Feb 2016 12:15:07 +0000 (UTC)
commit 9b0d2a697a8305526dd5f9e070979dcabde70197
Author: Ada Majorek <amajorek google com>
Date: Mon Jan 18 10:20:19 2016 -0800
Added Mirror layout config option.
To allow people have evedit box, also at the bottom or to the left.
Src/Common/AppSettingsData.h | 5 ++-
Src/Common/AppSettingsHeader.h | 3 +-
Src/Win32/AppSettings.cpp | 15 ++++------
Src/Win32/AppSettings.h | 6 +--
Src/Win32/Dasher.rc | 9 ++++--
Src/Win32/DasherWindow.cpp | 56 +++++++++++++++++++++++++++---------
Src/Win32/DasherWindow.h | 2 +
Src/Win32/Widgets/AdvancedPage.cpp | 3 +-
Src/Win32/Widgets/Splitter.cpp | 52 ++++++++++++++++-----------------
Src/Win32/Widgets/Splitter.h | 30 +------------------
Src/Win32/resource.h | 1 +
11 files changed, 93 insertions(+), 89 deletions(-)
---
diff --git a/Src/Common/AppSettingsData.h b/Src/Common/AppSettingsData.h
index 45467e4..caeb311 100644
--- a/Src/Common/AppSettingsData.h
+++ b/Src/Common/AppSettingsData.h
@@ -32,7 +32,7 @@ Dasher::Settings::bp_table app_boolparamtable[] = {
#else
{ APP_BP_SHOW_STATUSBAR, "ViewStatusbar", Persistence::PERSISTENT, true, "ViewStatusbar" },
#endif
-
+{ APP_BP_MIRROR_LAYOUT, "MirrorLayout", Persistence::PERSISTENT, false, "MirrorLayout" },
};
Dasher::Settings::lp_table app_longparamtable[] = {
@@ -57,5 +57,6 @@ Dasher::Settings::sp_table app_stringparamtable[] = {
#else
{APP_SP_EDIT_FONT, "EditFont", Persistence::PERSISTENT, "Sans 10", "EditFont"},
#endif
- {APP_SP_WINDOW_STATE, "WindowState", Persistence::PERSISTENT, "", "WindowState"},
+{ APP_SP_TOOLBAR_ID, "ToolbarID", Persistence::PERSISTENT, "", "ToolbarID" },
+{APP_SP_WINDOW_STATE, "WindowState", Persistence::PERSISTENT, "", "WindowState"},
};
diff --git a/Src/Common/AppSettingsHeader.h b/Src/Common/AppSettingsHeader.h
index 8bdd43b..efcda71 100644
--- a/Src/Common/AppSettingsHeader.h
+++ b/Src/Common/AppSettingsHeader.h
@@ -8,7 +8,7 @@
enum {
APP_BP_TIME_STAMP = END_OF_SPS, APP_BP_CONFIRM_UNSAVED, APP_BP_SHOW_TOOLBAR,
- APP_BP_SHOW_STATUSBAR, END_OF_APP_BPS
+ APP_BP_SHOW_STATUSBAR, APP_BP_MIRROR_LAYOUT, END_OF_APP_BPS
};
enum {
@@ -25,6 +25,7 @@ enum {
enum {
APP_SP_EDIT_FONT = END_OF_APP_LPS,
+ APP_SP_TOOLBAR_ID,
APP_SP_WINDOW_STATE, // TODO Use the same settings as linux.
END_OF_APP_SPS
};
diff --git a/Src/Win32/AppSettings.cpp b/Src/Win32/AppSettings.cpp
index a8f01b4..2c1fdbd 100644
--- a/Src/Win32/AppSettings.cpp
+++ b/Src/Win32/AppSettings.cpp
@@ -62,22 +62,21 @@ void CAppSettings::GetPermittedValues(int iParameter, vector<string> &vList) {
m_pDasher->GetPermittedValues(iParameter,vList);
}
-static const char FormatWindowPlacement[] = "%u,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d";
+static const char FormatWindowPlacement[] = "%u,%u,%d,%d,%d,%d,%d,%d,%d,%d";
/////////////////////////////////////////////////////////////////////////////
-#ifndef _WIN32_WCE
-void CAppSettings::SaveWindowPlacement(int iParameter, const LPWINDOWPLACEMENT pwp, int sp) {
+void CAppSettings::SaveWindowPlacement(int iParameter, const LPWINDOWPLACEMENT pwp) {
DASHER_ASSERT(pwp != NULL);
char t[200];
- sprintf_s(t, sizeof(t), FormatWindowPlacement, pwp->flags, pwp->showCmd, pwp->ptMinPosition.x,
pwp->ptMinPosition.y, pwp->ptMaxPosition.x, pwp->ptMaxPosition.y, pwp->rcNormalPosition.left,
pwp->rcNormalPosition.top, pwp->rcNormalPosition.right, pwp->rcNormalPosition.bottom,sp);
+ sprintf_s(t, sizeof(t), FormatWindowPlacement, pwp->flags, pwp->showCmd, pwp->ptMinPosition.x,
pwp->ptMinPosition.y, pwp->ptMaxPosition.x, pwp->ptMaxPosition.y, pwp->rcNormalPosition.left,
pwp->rcNormalPosition.top, pwp->rcNormalPosition.right, pwp->rcNormalPosition.bottom);
SetStringParameter(iParameter, t);
}
/////////////////////////////////////////////////////////////////////////////
-bool CAppSettings::LoadWindowPlacement(int iParameter, LPWINDOWPLACEMENT pwp, int* psp) {
+bool CAppSettings::LoadWindowPlacement(int iParameter, LPWINDOWPLACEMENT pwp) {
DASHER_ASSERT(pwp != NULL);
auto str = GetStringParameter(iParameter);
@@ -90,13 +89,11 @@ bool CAppSettings::LoadWindowPlacement(int iParameter, LPWINDOWPLACEMENT pwp, in
&wp.ptMinPosition.x, &wp.ptMinPosition.y,
&wp.ptMaxPosition.x, &wp.ptMaxPosition.y,
&wp.rcNormalPosition.left, &wp.rcNormalPosition.top,
- &wp.rcNormalPosition.right, &wp.rcNormalPosition.bottom, psp);
+ &wp.rcNormalPosition.right, &wp.rcNormalPosition.bottom);
- if(nRead != 11)
+ if(nRead < 10)
return false;
wp.length = sizeof(wp);
*pwp = wp;
return true;
}
-
-#endif
diff --git a/Src/Win32/AppSettings.h b/Src/Win32/AppSettings.h
index 1d9f203..d35c9a5 100644
--- a/Src/Win32/AppSettings.h
+++ b/Src/Win32/AppSettings.h
@@ -49,10 +49,8 @@ public:
void ResetParamater(int iParameter);
void GetPermittedValues(int iParameter, std::vector<std::string> &vList);
- #ifndef _WIN32_WCE
- bool LoadWindowPlacement(int iParameter, LPWINDOWPLACEMENT pwp, int* psp);
- void SaveWindowPlacement(int iParameter, const LPWINDOWPLACEMENT pwp, int sp);
- #endif
+ bool LoadWindowPlacement(int iParameter, LPWINDOWPLACEMENT pwp);
+ void SaveWindowPlacement(int iParameter, const LPWINDOWPLACEMENT pwp);
void SetHwnd(HWND hWnd) {
m_hWnd = hWnd;
diff --git a/Src/Win32/Dasher.rc b/Src/Win32/Dasher.rc
index bbd41c3..26c887f 100644
--- a/Src/Win32/Dasher.rc
+++ b/Src/Win32/Dasher.rc
@@ -7,7 +7,8 @@
//
// Generated from the TEXTINCLUDE 2 resource.
//
-#include "afxres.h"
+#include "winres.h"
+#include "windows.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
@@ -45,7 +46,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
2 TEXTINCLUDE
BEGIN
- "#include ""afxres.h""\r\n"
+"#include ""winres.h""\r\n"
+"#include ""windows.h""\r\n"
"\0"
END
@@ -184,7 +186,7 @@ BEGIN
CONTROL "Show toolbar",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,42,58,10
CONTROL "Show statusbar",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,54,66,10
CONTROL "Control mode",IDC_CONTROLMODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,82,59,10
- LISTBOX IDC_CONTROLBOXES, 14, 92, 166, 132, LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL |
WS_TABSTOP
+ LISTBOX IDC_CONTROLBOXES,14,92,166,132,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
CONTROL "Stand-alone",IDC_STYLE_STANDALONE,"Button",BS_AUTORADIOBUTTON | WS_GROUP |
WS_TABSTOP,204,96,55,10
CONTROL "Composition",IDC_STYLE_COMPOSITION,"Button",BS_AUTORADIOBUTTON |
WS_TABSTOP,204,120,55,10
CONTROL "Direct entry",IDC_STYLE_DIRECT,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,204,108,54,10
@@ -198,6 +200,7 @@ BEGIN
CONTROL "Speak on word breaks",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,30,90,10
GROUPBOX "Clipboard:",IDC_STATIC,198,48,180,30
CONTROL "Copy all on stop",IDC_COPYONSTOP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,204,60,90,10
+ CONTROL "Flip Edit Position",IDC_MIRROR_LAYOUT,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,290,97,90,10
END
IDD_MODULESETTINGS DIALOGEX 0, 0, 309, 177
diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp
index c12236b..8a42796 100644
--- a/Src/Win32/DasherWindow.cpp
+++ b/Src/Win32/DasherWindow.cpp
@@ -60,6 +60,7 @@ CDasherWindow::CDasherWindow(const wstring& configName) : m_configName(configNam
m_pSpeedAlphabetBar = 0;
m_pSplitter = 0;
m_pDasher = 0;
+ m_bSizeRestored = false;
m_hIconSm = (HICON)LoadImage(WinHelper::hInstApp, (LPCTSTR)IDI_DASHER, IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
@@ -153,17 +154,14 @@ void CDasherWindow::SaveWindowState() const {
wp.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(&wp)) {//function call succeeds
- m_pAppSettings->SaveWindowPlacement(APP_SP_WINDOW_STATE, &wp, m_pSplitter->GetPos());
+ m_pAppSettings->SaveWindowPlacement(APP_SP_WINDOW_STATE, &wp);
}
}
bool CDasherWindow::LoadWindowState() {
WINDOWPLACEMENT wp;
- int splitterPos = -1;
- if (m_pAppSettings->LoadWindowPlacement(APP_SP_WINDOW_STATE, &wp, &splitterPos)) {
- if (splitterPos != -1) {
- m_pSplitter->SetPos(splitterPos);
- }
+ m_bSizeRestored = true;
+ if (m_pAppSettings->LoadWindowPlacement(APP_SP_WINDOW_STATE, &wp)) {
if (SetWindowPlacement(&wp))
return true;
}
@@ -174,8 +172,11 @@ void CDasherWindow::HandleParameterChange(int iParameter) {
switch (iParameter) {
case APP_BP_SHOW_TOOLBAR:
m_pToolbar->ShowToolbar(m_pAppSettings->GetBoolParameter(APP_BP_SHOW_TOOLBAR));
+ Layout();
break;
+
case APP_BP_SHOW_STATUSBAR:
+ case APP_BP_MIRROR_LAYOUT:
case APP_LP_STYLE:
Layout();
break;
@@ -413,6 +414,8 @@ void CDasherWindow::Layout() {
m_pSpeedAlphabetBar->MoveWindow(0, Height - SpeedAlphabetHeight, Width, SpeedAlphabetHeight);
m_pSpeedAlphabetBar->ShowWindow(SpeedAlphabetHeight ? SW_SHOW : SW_HIDE);
+ bool mirrorLayout = m_pAppSettings->GetBoolParameter(APP_BP_MIRROR_LAYOUT);
+
int CanvasY = ToolbarHeight;
int CanvasHeight = Height - SpeedAlphabetHeight - CanvasY;
@@ -425,24 +428,49 @@ void CDasherWindow::Layout() {
break;
case APP_STYLE_COMPOSE:
- m_pDasher->Move(0, CanvasY, Width / 2, CanvasHeight);
- m_pEdit->Move(Width / 2, CanvasY, Width - Width / 2, CanvasHeight);
+ if (mirrorLayout)
+ {
+ m_pDasher->Move(Width / 2, CanvasY, Width - Width / 2, CanvasHeight);
+ m_pEdit->Move(0, CanvasY, Width / 2, CanvasHeight);
+ }
+ else {
+ m_pDasher->Move(0, CanvasY, Width / 2, CanvasHeight);
+ m_pEdit->Move(Width / 2, CanvasY, Width - Width / 2, CanvasHeight);
+ }
m_pEdit->ShowWindow(SW_SHOW);
m_pSplitter->ShowWindow(SW_HIDE);
break;
default:
int SplitterHeight = m_pSplitter->GetHeight();
- int SplitterY = max(CanvasY + GetMinEditHeight(), m_pSplitter->GetPos());
+ int EditHeight = m_pAppSettings->GetLongParameter(APP_LP_EDIT_HEIGHT);
+
+ if (mirrorLayout)
+ {
+ if (m_pSplitter->IsSizing())
+ EditHeight = CanvasY + CanvasHeight - SplitterHeight - m_pSplitter->GetPos();
+ int SplitterY = CanvasY + CanvasHeight - SplitterHeight - EditHeight;
+ SplitterY = min(SplitterY, CanvasY + CanvasHeight - GetMinEditHeight() - SplitterHeight);
+ SplitterY = max(CanvasY + GetMinCanvasHeight(), SplitterY);
+ EditHeight = CanvasY + CanvasHeight - SplitterY - SplitterHeight;
+ m_pDasher->Move(0, CanvasY, Width, SplitterY - CanvasY);
+ m_pSplitter->Move(SplitterY, Width);
+ m_pEdit->Move(0,SplitterY + SplitterHeight, Width, EditHeight);
+ } else {
+ if (m_pSplitter->IsSizing())
+ EditHeight = m_pSplitter->GetPos() - CanvasY;
+ int SplitterY = CanvasY + EditHeight;
SplitterY = min(SplitterY, CanvasY + CanvasHeight - GetMinCanvasHeight() - SplitterHeight);
- int EditHeight = SplitterY - CanvasY;
- int DasherY = SplitterY + SplitterHeight;
-
+ SplitterY = max(CanvasY + GetMinEditHeight(), SplitterY);
+ EditHeight = SplitterY - CanvasY;
+ m_pDasher->Move(0, SplitterY + SplitterHeight, Width, CanvasHeight - SplitterY - SplitterHeight);
m_pEdit->Move(0, CanvasY, Width, EditHeight);
m_pSplitter->Move(SplitterY, Width);
- m_pDasher->Move(0, DasherY, Width, CanvasHeight - EditHeight - SplitterHeight);
- m_pEdit->ShowWindow(SW_SHOW);
+ }
+ m_pEdit->ShowWindow(SW_SHOW);
m_pSplitter->ShowWindow(SW_SHOW);
+ if (m_bSizeRestored)
+ m_pAppSettings->SetLongParameter(APP_LP_EDIT_HEIGHT, EditHeight);
}
}
diff --git a/Src/Win32/DasherWindow.h b/Src/Win32/DasherWindow.h
index 99c7b65..d6411a8 100644
--- a/Src/Win32/DasherWindow.h
+++ b/Src/Win32/DasherWindow.h
@@ -90,6 +90,8 @@ private:
HICON m_hIconSm;
HMENU m_hMenu;
+ mutable bool m_bSizeRestored;
+
std::wstring m_configName;
std::unique_ptr<Dasher::CSettingsStore> setting_store_;
// Misc window handling
diff --git a/Src/Win32/Widgets/AdvancedPage.cpp b/Src/Win32/Widgets/AdvancedPage.cpp
index 6e00a0c..aa6c085 100644
--- a/Src/Win32/Widgets/AdvancedPage.cpp
+++ b/Src/Win32/Widgets/AdvancedPage.cpp
@@ -46,7 +46,8 @@ static menuentry menutable[] = {
{BP_CONTROL_MODE, IDC_CONTROLMODE}, // Not global setting - specific to editbox/widget
{BP_SPEAK_WORDS, IDC_CHECK4},
{BP_SPEAK_ALL_ON_STOP, IDC_CHECK3},
- {BP_COPY_ALL_ON_STOP, IDC_COPYONSTOP}
+ { BP_COPY_ALL_ON_STOP, IDC_COPYONSTOP },
+ { APP_BP_MIRROR_LAYOUT, IDC_MIRROR_LAYOUT},
};
void CAdvancedPage::PopulateList() {
diff --git a/Src/Win32/Widgets/Splitter.cpp b/Src/Win32/Widgets/Splitter.cpp
index 1b7f223..fbf729b 100644
--- a/Src/Win32/Widgets/Splitter.cpp
+++ b/Src/Win32/Widgets/Splitter.cpp
@@ -11,6 +11,7 @@
#include <iostream>
#include <cstring>
+#include <algorithm>
// For WinCE
#ifndef MAKEPOINTS
@@ -24,6 +25,15 @@ CSplitter::CSplitter(CSplitterOwner* pOwner, int iPos)
{
}
+int CSplitter::GetHeight()
+{
+ // (from MSDN) SM_CYSIZEFRAME:
+ // The thickness of the sizing border around the perimeter of a
+ // window that can be resized, in pixels.
+ // SM_CXSIZEFRAME is the width of the horizontal border, and
+ // SM_CYSIZEFRAME is the height of the vertical border.
+ return std::max(6, GetSystemMetrics(SM_CYSIZEFRAME));
+}
/////////////////////////////////////////////////////////////////////////////
@@ -37,7 +47,7 @@ HWND CSplitter::Create(HWND hParent)
void CSplitter::Move(int iPos, int Width)
{
m_iPos = iPos;
- MoveWindow(0, m_iPos, Width, GetHeight(), TRUE);
+ MoveWindow(0, m_iPos, Width, GetHeight(), TRUE);
}
/////////////////////////////////////////////////////////////////////////////
@@ -46,7 +56,7 @@ LRESULT CSplitter::OnLButtonDown(UINT message, WPARAM wParam, LPARAM lParam, BOO
{
bHandled = TRUE;
m_SplitStatus = Sizing;
- SetCapture();
+ SetCapture();
return 0;
}
@@ -59,7 +69,7 @@ LRESULT CSplitter::OnLButtonUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL&
{
m_SplitStatus = None;
ReleaseCapture();
- }
+ }
return 0;
}
@@ -68,30 +78,18 @@ LRESULT CSplitter::OnLButtonUp(UINT message, WPARAM wParam, LPARAM lParam, BOOL&
LRESULT CSplitter::OnMouseMove(UINT message, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
bHandled = TRUE;
- POINTS Tmp = MAKEPOINTS(lParam);
- POINT MousePos;
- MousePos.x = Tmp.x;
- MousePos.y = Tmp.y;
- MapWindowPoints( GetParent(), &MousePos, 1);
-
- if( m_SplitStatus == Sizing)
- {
- RECT ParentRect, MyRect;
- ::GetWindowRect( GetParent(), &ParentRect);
- GetWindowRect(&MyRect);
-#ifndef _WIN32_WCE
- m_iPos = MousePos.y - GetSystemMetrics(SM_CYSIZEFRAME) / 2;
-#else
- // TODO: Fix this on Windows CE
- m_iPos = MousePos.y - 4;
-#endif
-
-// WCHAR wszDebugText[128];
-// _snwprintf(wszDebugText, 128, L"Setting size: %d\n", m_iPos);
-// OutputDebugStringW(wszDebugText);
- m_pOwner->Layout();
- }
- return 0;
+ if (m_SplitStatus == Sizing)
+ {
+ POINTS Tmp = MAKEPOINTS(lParam);
+ POINT MousePos;
+ MousePos.x = Tmp.x;
+ MousePos.y = Tmp.y;
+ MapWindowPoints(GetParent(), &MousePos, 1);
+ m_iPos = MousePos.y - GetHeight() / 2;
+
+ m_pOwner->Layout();
+ }
+ return 0;
}
/////////////////////////////////////////////////////////////////////////////
diff --git a/Src/Win32/Widgets/Splitter.h b/Src/Win32/Widgets/Splitter.h
index 14883b2..79108bc 100644
--- a/Src/Win32/Widgets/Splitter.h
+++ b/Src/Win32/Widgets/Splitter.h
@@ -32,49 +32,23 @@ public:
void Move(int Pos, int Width);
- int GetHeight()
- {
-#ifndef _WIN32_WCE
- // (from MSDN) SM_CYSIZEFRAME:
- // The thickness of the sizing border around the perimeter of a
- // window that can be resized, in pixels.
- // SM_CXSIZEFRAME is the width of the horizontal border, and
- // SM_CYSIZEFRAME is the height of the vertical border.
- return GetSystemMetrics(SM_CYSIZEFRAME);
-#else
- // TODO: Fix this for Windows CE
- return 8;
-#endif
- }
+ int GetHeight();
int GetPos()
{
return m_iPos;
}
- void SetPos(int Pos)
- {
- m_iPos = Pos;
- }
-
+ bool IsSizing() const { return m_SplitStatus == Sizing; }
static ATL::CWndClassInfo& GetWndClassInfo()
{
-#ifndef _WIN32_WCE
static ATL::CWndClassInfo wc =
{
{ sizeof(WNDCLASSEX), CS_HREDRAW | CS_VREDRAW , StartWindowProc,
0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW), NULL, _T("HSplitter"), NULL },
NULL, NULL, MAKEINTRESOURCE(IDC_SIZENS), TRUE, 0, _T("")
};
-#else
- static ATL::CWndClassInfo wc = \
- { \
- { CS_HREDRAW | CS_VREDRAW , StartWindowProc, \
- 0, 0, NULL, NULL, NULL, (HBRUSH)(COLOR_WINDOW), NULL, _T("HSplitter")}, \
- NULL, NULL, MAKEINTRESOURCE(IDC_SIZENS), TRUE, 0, _T("") \
- };
-#endif
return wc;
}
diff --git a/Src/Win32/dasher.log b/Src/Win32/dasher.log
new file mode 100644
index 0000000..e69de29
diff --git a/Src/Win32/resource.h b/Src/Win32/resource.h
index 704b3c2..0a3f483 100644
--- a/Src/Win32/resource.h
+++ b/Src/Win32/resource.h
@@ -45,6 +45,7 @@
#define IDC_BUTTON_PREFS2 1019
#define IDC_THICKLINE 1020
#define IDC_COPYONSTOP 1020
+#define IDC_MIRROR_LAYOUT 1021
#define IDC_SPACE 1036
#define IDC_UNIFORMVAL 1040
#define IDC_CHECK3 1071
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]