[dasher: 179/217] UI for setting file encoding.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher: 179/217] UI for setting file encoding.
- Date: Sat, 27 Feb 2016 12:15:22 +0000 (UTC)
commit d151fe972ad7a606f228c5262aca73bf70e491b5
Author: Ada Majorek <amajorek google com>
Date: Thu Jan 21 15:34:03 2016 -0800
UI for setting file encoding.
fixes https://github.com/ipomoena/dasher/issues/14
Src/Win32/Dasher.rc | 8 ++++--
Src/Win32/Widgets/AdvancedPage.cpp | 40 ++++++++++++++++++++++++++++++++++-
Src/Win32/resource.h | 3 +-
3 files changed, 45 insertions(+), 6 deletions(-)
---
diff --git a/Src/Win32/Dasher.rc b/Src/Win32/Dasher.rc
index 26c887f..c417f99 100644
--- a/Src/Win32/Dasher.rc
+++ b/Src/Win32/Dasher.rc
@@ -46,8 +46,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
2 TEXTINCLUDE
BEGIN
-"#include ""winres.h""\r\n"
-"#include ""windows.h""\r\n"
+ "#include ""winres.h""\r\n"
+ "#include ""windows.h""\r\n"
"\0"
END
@@ -200,7 +200,9 @@ 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
+ CONTROL "Flip Edit Position",IDC_MIRROR_LAYOUT,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,295,91,76,21
+ COMBOBOX IDC_FILE_ENCODING,198,208,153,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
+ GROUPBOX "File Encoding:",IDC_STATIC,193,194,180,30
END
IDD_MODULESETTINGS DIALOGEX 0, 0, 309, 177
diff --git a/Src/Win32/Widgets/AdvancedPage.cpp b/Src/Win32/Widgets/AdvancedPage.cpp
index aa6c085..0b33dcf 100644
--- a/Src/Win32/Widgets/AdvancedPage.cpp
+++ b/Src/Win32/Widgets/AdvancedPage.cpp
@@ -11,8 +11,7 @@
#include "AdvancedPage.h"
#include "../resource.h"
#include "../Common/StringUtils.h"
-
-#include <utility> // for std::pair
+#include "../../DasherCore/DasherTypes.h"
using namespace Dasher;
using namespace std;
@@ -98,6 +97,27 @@ void CAdvancedPage::PopulateList() {
SendMessage(ListBox, LB_SETCURSEL, 0, 0);
LRESULT CurrentIndex = SendMessage(ListBox, LB_GETITEMDATA, 0, 0);
}
+
+ CWindow fileEncodingCb = GetDlgItem(m_hwnd, IDC_FILE_ENCODING);
+ fileEncodingCb.SendMessage(CB_ADDSTRING, 0, (LPARAM)L"Windows Locale Encoding");
+ fileEncodingCb.SendMessage(CB_ADDSTRING, 0, (LPARAM)L"UTF-8");
+ fileEncodingCb.SendMessage(CB_ADDSTRING, 0, (LPARAM)L"Unicode little endian / UTF-16 LE");
+ fileEncodingCb.SendMessage(CB_ADDSTRING, 0, (LPARAM)L"Unicode big endian / UTF-16 BE");
+
+ switch (m_pAppSettings->GetLongParameter(APP_LP_FILE_ENCODING)) {
+ case Opts::UTF8:
+ fileEncodingCb.SendMessage(CB_SETCURSEL, 1, 0);
+ break;
+ case Opts::UTF16LE:
+ fileEncodingCb.SendMessage(CB_SETCURSEL, 2, 0);
+ break;
+ case Opts::UTF16BE:
+ fileEncodingCb.SendMessage(CB_SETCURSEL, 3, 0);
+ break;
+ default:
+ fileEncodingCb.SendMessage(CB_SETCURSEL, 0, 0);
+ break;
+ }
}
bool CAdvancedPage::Apply() {
@@ -116,6 +136,22 @@ bool CAdvancedPage::Apply() {
auto CurrentControlBox = m_ControlBoxItems[CurrentIndex];
m_pAppSettings->SetStringParameter(SP_CONTROL_BOX_ID, CurrentControlBox);
+ int fileEncodingIdx = SendMessage(GetDlgItem(m_hwnd, IDC_FILE_ENCODING), CB_GETCURSEL, 0, 0);
+ switch (fileEncodingIdx) {
+ case 1:
+ m_pAppSettings->SetLongParameter(APP_LP_FILE_ENCODING, Opts::UTF8);
+ break;
+ case 2:
+ m_pAppSettings->SetLongParameter(APP_LP_FILE_ENCODING, Opts::UTF16LE);
+ break;
+ case 3:
+ m_pAppSettings->SetLongParameter(APP_LP_FILE_ENCODING, Opts::UTF16BE);
+ break;
+ default:
+ m_pAppSettings->SetLongParameter(APP_LP_FILE_ENCODING, Opts::UserDefault);
+ break;
+ }
+
for(int ii = 0; ii<sizeof(menutable)/sizeof(menuentry); ii++) {
m_pAppSettings->SetBoolParameter(menutable[ii].paramNum, SendMessage(GetDlgItem(m_hwnd,
menutable[ii].idcNum), BM_GETCHECK, 0, 0) == BST_CHECKED );
}
diff --git a/Src/Win32/resource.h b/Src/Win32/resource.h
index 0a3f483..f4a802e 100644
--- a/Src/Win32/resource.h
+++ b/Src/Win32/resource.h
@@ -89,6 +89,7 @@
#define IDC_CHECK4 1156
#define IDC_CHECK5 1157
#define IDC_CONTROLBOXES 1160
+#define IDC_FILE_ENCODING 1161
#define ID_EDIT_SELECTALL 32775
#define ID_HELP_CONTENTS 32776
#define ID_EDIT_COPY_ALL 32798
@@ -108,7 +109,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 182
#define _APS_NEXT_COMMAND_VALUE 32820
-#define _APS_NEXT_CONTROL_VALUE 1161
+#define _APS_NEXT_CONTROL_VALUE 1162
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]