Skip to content

Commit

Permalink
Added setting color on input mode window
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancorvussolis committed Aug 15, 2017
1 parent 3a903bc commit 7cef83c
Show file tree
Hide file tree
Showing 31 changed files with 570 additions and 198 deletions.
3 changes: 2 additions & 1 deletion common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ extern LPCWSTR fnuserbak; //ユーザー辞書バックアッププレフィッ
extern LPCWSTR fnskkdic; //取込SKK辞書
extern LPCWSTR fninitlua; //init.lua

#define DISPLAY_COLOR_NUM 8
#define DISPLAY_LIST_COLOR_NUM 8
#define DISPLAY_MODE_COLOR_NUM 8
#define DISPLAYATTRIBUTE_INFO_NUM 7

extern const TF_DISPLAYATTRIBUTE c_daDisplayAttributeInputMark;
Expand Down
13 changes: 11 additions & 2 deletions common/configxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,20 @@ LPCWSTR ValueDispCandNo = L"dispcandno";
LPCWSTR ValueVerticalCand = L"verticalcand";
LPCWSTR ValueAnnotation = L"annotation";
LPCWSTR ValueAnnotatLst = L"annotatlst";
LPCWSTR ValueShowModeInl = L"showmodeinl";
LPCWSTR ValueShowModeSec = L"showmodesec";
LPCWSTR ValueShowModeMark = L"showmodemark";
LPCWSTR ValueShowRoman = L"showroman";

LPCWSTR ValueShowModeInl = L"showmodeinl";
LPCWSTR ValueShowModeSec = L"showmodesec";
LPCWSTR ValueColorMC = L"colormc";
LPCWSTR ValueColorMF = L"colormf";
LPCWSTR ValueColorHR = L"colorhr";
LPCWSTR ValueColorKT = L"colorkt";
LPCWSTR ValueColorKA = L"colorka";
LPCWSTR ValueColorJL = L"colorjl";
LPCWSTR ValueColorAC = L"colorac";
LPCWSTR ValueColorDR = L"colordr";

//displayattr section

LPCWSTR SectionDisplayAttr = L"displayattr";
Expand Down
13 changes: 11 additions & 2 deletions common/configxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,20 @@ extern LPCWSTR ValueDispCandNo;
extern LPCWSTR ValueVerticalCand;
extern LPCWSTR ValueAnnotation;
extern LPCWSTR ValueAnnotatLst;
extern LPCWSTR ValueShowModeInl;
extern LPCWSTR ValueShowModeSec;
extern LPCWSTR ValueShowModeMark;
extern LPCWSTR ValueShowRoman;

extern LPCWSTR ValueShowModeInl;
extern LPCWSTR ValueShowModeSec;
extern LPCWSTR ValueColorMC;
extern LPCWSTR ValueColorMF;
extern LPCWSTR ValueColorHR;
extern LPCWSTR ValueColorKT;
extern LPCWSTR ValueColorKA;
extern LPCWSTR ValueColorJL;
extern LPCWSTR ValueColorAC;
extern LPCWSTR ValueColorDR;

//displayattr section

extern LPCWSTR SectionDisplayAttr;
Expand Down
68 changes: 29 additions & 39 deletions imcrvcnf/DlgProcDisplay.cpp → imcrvcnf/DlgProcDisplay1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ static struct {
int id;
LPCWSTR value;
COLORREF color;
} displayColor[DISPLAY_COLOR_NUM] =
} displayListColor[DISPLAY_LIST_COLOR_NUM] =
{
{IDC_COL_BG, ValueColorBG, RGB(0xFF,0xFF,0xFF)},
{IDC_COL_FR, ValueColorFR, RGB(0x00,0x00,0x00)},
{IDC_COL_SE, ValueColorSE, RGB(0x00,0x00,0xFF)},
{IDC_COL_CO, ValueColorCO, RGB(0x80,0x80,0x80)},
{IDC_COL_CA, ValueColorCA, RGB(0x00,0x00,0x00)},
{IDC_COL_SC, ValueColorSC, RGB(0x80,0x80,0x80)},
{IDC_COL_AN, ValueColorAN, RGB(0x80,0x80,0x80)},
{IDC_COL_NO, ValueColorNO, RGB(0x00,0x00,0x00)}
{IDC_COL_BG, ValueColorBG, RGB(0xFF, 0xFF, 0xFF)},
{IDC_COL_FR, ValueColorFR, RGB(0x00, 0x00, 0x00)},
{IDC_COL_SE, ValueColorSE, RGB(0x00, 0x00, 0xFF)},
{IDC_COL_CO, ValueColorCO, RGB(0x80, 0x80, 0x80)},
{IDC_COL_CA, ValueColorCA, RGB(0x00, 0x00, 0x00)},
{IDC_COL_SC, ValueColorSC, RGB(0x80, 0x80, 0x80)},
{IDC_COL_AN, ValueColorAN, RGB(0x80, 0x80, 0x80)},
{IDC_COL_NO, ValueColorNO, RGB(0x00, 0x00, 0x00)}
};

INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
INT_PTR CALLBACK DlgProcDisplay1(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hwnd;
HDC hdc;
PAINTSTRUCT ps;
WCHAR num[16];
WCHAR fontname[LF_FACESIZE];
INT fontpoint, fontweight, x, y, count;
INT fontpoint, fontweight, count;
BOOL fontitalic;
CHOOSEFONTW cf;
LOGFONTW lf;
Expand Down Expand Up @@ -93,12 +93,12 @@ INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
customColor[i] = RGB(0xFF, 0xFF, 0xFF);
}

for(int i = 0; i < _countof(displayColor); i++)
for(int i = 0; i < _countof(displayListColor); i++)
{
ReadValue(pathconfigxml, SectionDisplay, displayColor[i].value, strxmlval);
ReadValue(pathconfigxml, SectionDisplay, displayListColor[i].value, strxmlval);
if(!strxmlval.empty())
{
displayColor[i].color = wcstoul(strxmlval.c_str(), nullptr, 0);
displayListColor[i].color = wcstoul(strxmlval.c_str(), nullptr, 0);
}
}

Expand Down Expand Up @@ -248,12 +248,12 @@ INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
break;

case WM_LBUTTONDOWN:
for(int i = 0; i < _countof(displayColor); i++)
for(int i = 0; i < _countof(displayListColor); i++)
{
hwnd = GetDlgItem(hDlg, displayColor[i].id);
hwnd = GetDlgItem(hDlg, displayListColor[i].id);
GetWindowRect(hwnd, &rect);
pt.x = x = GET_X_LPARAM(lParam);
pt.y = y = GET_Y_LPARAM(lParam);
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
ClientToScreen(hDlg, &pt);

if(rect.left <= pt.x && pt.x <= rect.right &&
Expand All @@ -262,16 +262,16 @@ INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
cc.lStructSize = sizeof(cc);
cc.hwndOwner = hDlg;
cc.hInstance = nullptr;
cc.rgbResult = displayColor[i].color;
cc.rgbResult = displayListColor[i].color;
cc.lpCustColors = customColor;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_ENABLEHOOK;
cc.lCustData = 0;
cc.lpfnHook = nullptr;
cc.lpTemplateName = nullptr;
if(ChooseColorW(&cc))
{
DrawSelectColor(hDlg, displayColor[i].id, cc.rgbResult);
displayColor[i].color = cc.rgbResult;
DrawSelectColor(hDlg, displayListColor[i].id, cc.rgbResult);
displayListColor[i].color = cc.rgbResult;
PropSheet_Changed(GetParent(hDlg), hDlg);
return TRUE;
}
Expand All @@ -282,9 +282,9 @@ INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM l

case WM_PAINT:
hdc = BeginPaint(hDlg, &ps);
for(int i = 0; i < _countof(displayColor); i++)
for(int i = 0; i < _countof(displayListColor); i++)
{
DrawSelectColor(hDlg, displayColor[i].id, displayColor[i].color);
DrawSelectColor(hDlg, displayListColor[i].id, displayListColor[i].color);
}
EndPaint(hDlg, &ps);

Expand Down Expand Up @@ -322,10 +322,10 @@ INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
SetDlgItemTextW(hDlg, IDC_EDIT_MAXWIDTH, num);
WriterKey(pXmlWriter, ValueMaxWidth, num);

for(int i = 0; i < _countof(displayColor); i++)
for(int i = 0; i < _countof(displayListColor); i++)
{
_snwprintf_s(num, _TRUNCATE, L"0x%06X", displayColor[i].color);
WriterKey(pXmlWriter, displayColor[i].value, num);
_snwprintf_s(num, _TRUNCATE, L"0x%06X", displayListColor[i].color);
WriterKey(pXmlWriter, displayListColor[i].value, num);
}

SaveCheckButton(hDlg, IDC_RADIO_API_D2D, ValueDrawAPI);
Expand All @@ -346,21 +346,11 @@ INT_PTR CALLBACK DlgProcDisplay(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
SaveCheckButton(hDlg, IDC_CHECKBOX_ANNOTATION, ValueAnnotation);
SaveCheckButton(hDlg, IDC_RADIO_ANNOTATLST, ValueAnnotatLst);

SaveCheckButton(hDlg, IDC_CHECKBOX_SHOWMODEINL, ValueShowModeInl);
GetDlgItemTextW(hDlg, IDC_EDIT_SHOWMODESEC, num, _countof(num));
count = _wtoi(num);
if(count <= 0 || count > 60)
{
count = 3;
}
_snwprintf_s(num, _TRUNCATE, L"%d", count);
SetDlgItemTextW(hDlg, IDC_EDIT_SHOWMODESEC, num);
WriterKey(pXmlWriter, ValueShowModeSec, num);

SaveCheckButton(hDlg, IDC_CHECKBOX_SHOWMODEMARK, ValueShowModeMark);
SaveCheckButton(hDlg, IDC_CHECKBOX_SHOWROMAN, ValueShowRoman);

WriterEndSection(pXmlWriter); //End of SectionDisplay
//at DlgProcDisplay2
//WriterEndSection(pXmlWriter); //End of SectionDisplay

return TRUE;

Expand Down
169 changes: 169 additions & 0 deletions imcrvcnf/DlgProcDisplay2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@

#include "configxml.h"
#include "imcrvcnf.h"
#include "resource.h"

static struct {
int id;
LPCWSTR value;
COLORREF color;
} displayModeColor[DISPLAY_MODE_COLOR_NUM] =
{
{IDC_COL_MODE_MC, ValueColorMC, RGB(0xFF, 0xFF, 0xFF)},
{IDC_COL_MODE_MF, ValueColorMF, RGB(0x00, 0x00, 0x00)},
{IDC_COL_MODE_HR, ValueColorHR, RGB(0xC0, 0x00, 0x00)},
{IDC_COL_MODE_KT, ValueColorKT, RGB(0x00, 0xC0, 0x00)},
{IDC_COL_MODE_KA, ValueColorKA, RGB(0x00, 0xC0, 0x80)},
{IDC_COL_MODE_JL, ValueColorJL, RGB(0x00, 0x00, 0xC0)},
{IDC_COL_MODE_AC, ValueColorAC, RGB(0x00, 0x80, 0xC0)},
{IDC_COL_MODE_DR, ValueColorDR, RGB(0x80, 0x80, 0x80)}
};

INT_PTR CALLBACK DlgProcDisplay2(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hwnd;
HDC hdc;
PAINTSTRUCT ps;
WCHAR num[16];
INT count;
RECT rect;
POINT pt;
std::wstring strxmlval;
CHOOSECOLORW cc;
static COLORREF customColor[16];

switch(message)
{
case WM_INITDIALOG:
LoadCheckButton(hDlg, IDC_CHECKBOX_SHOWMODEINL, SectionDisplay, ValueShowModeInl, L"1");
ReadValue(pathconfigxml, SectionDisplay, ValueShowModeSec, strxmlval);
count = strxmlval.empty() ? -1 : _wtoi(strxmlval.c_str());
if(count > 60 || count <= 0)
{
count = 3;
}
_snwprintf_s(num, _TRUNCATE, L"%d", count);
SetDlgItemTextW(hDlg, IDC_EDIT_SHOWMODESEC, num);

for(int i = 0; i < _countof(customColor); i++)
{
customColor[i] = RGB(0xFF, 0xFF, 0xFF);
}

for(int i = 0; i < _countof(displayModeColor); i++)
{
ReadValue(pathconfigxml, SectionDisplay, displayModeColor[i].value, strxmlval);
if(!strxmlval.empty())
{
displayModeColor[i].color = wcstoul(strxmlval.c_str(), nullptr, 0);
}
}

return TRUE;

case WM_DPICHANGED_AFTERPARENT:

return TRUE;

case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_EDIT_SHOWMODESEC:
switch(HIWORD(wParam))
{
case EN_CHANGE:
PropSheet_Changed(GetParent(hDlg), hDlg);
return TRUE;
default:
break;
}
break;

default:
break;
}
break;

case WM_LBUTTONDOWN:
for(int i = 0; i < _countof(displayModeColor); i++)
{
hwnd = GetDlgItem(hDlg, displayModeColor[i].id);
GetWindowRect(hwnd, &rect);
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
ClientToScreen(hDlg, &pt);

if(rect.left <= pt.x && pt.x <= rect.right &&
rect.top <= pt.y && pt.y <= rect.bottom)
{
cc.lStructSize = sizeof(cc);
cc.hwndOwner = hDlg;
cc.hInstance = nullptr;
cc.rgbResult = displayModeColor[i].color;
cc.lpCustColors = customColor;
cc.Flags = CC_FULLOPEN | CC_RGBINIT;
cc.lCustData = 0;
cc.lpfnHook = nullptr;
cc.lpTemplateName = nullptr;
if(ChooseColorW(&cc))
{
DrawSelectColor(hDlg, displayModeColor[i].id, cc.rgbResult);
displayModeColor[i].color = cc.rgbResult;
PropSheet_Changed(GetParent(hDlg), hDlg);
return TRUE;
}
break;
}
}
break;

case WM_PAINT:
hdc = BeginPaint(hDlg, &ps);
for(int i = 0; i < _countof(displayModeColor); i++)
{
DrawSelectColor(hDlg, displayModeColor[i].id, displayModeColor[i].color);
}
EndPaint(hDlg, &ps);

return TRUE;

case WM_NOTIFY:
switch(((LPNMHDR)lParam)->code)
{
case PSN_APPLY:
SaveCheckButton(hDlg, IDC_CHECKBOX_SHOWMODEINL, ValueShowModeInl);
GetDlgItemTextW(hDlg, IDC_EDIT_SHOWMODESEC, num, _countof(num));
count = _wtoi(num);
if(count <= 0 || count > 60)
{
count = 3;
}
_snwprintf_s(num, _TRUNCATE, L"%d", count);
SetDlgItemTextW(hDlg, IDC_EDIT_SHOWMODESEC, num);
WriterKey(pXmlWriter, ValueShowModeSec, num);

for(int i = 0; i < _countof(displayModeColor); i++)
{
_snwprintf_s(num, _TRUNCATE, L"0x%06X", displayModeColor[i].color);
WriterKey(pXmlWriter, displayModeColor[i].value, num);
}

WriterEndSection(pXmlWriter); //End of SectionDisplay

return TRUE;

default:
break;
}
break;

case WM_DESTROY:
PostQuitMessage(0);
return TRUE;

default:
break;
}

return FALSE;
}
3 changes: 2 additions & 1 deletion imcrvcnf/imcrvcnf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ void CreateProperty()
{IDD_DIALOG_DICTIONARY, DlgProcDictionary},
{IDD_DIALOG_BEHAVIOR1, DlgProcBehavior1},
{IDD_DIALOG_BEHAVIOR2, DlgProcBehavior2},
{IDD_DIALOG_DISPLAY, DlgProcDisplay},
{IDD_DIALOG_DISPLAY1, DlgProcDisplay1},
{IDD_DIALOG_DISPLAY2, DlgProcDisplay2},
{IDD_DIALOG_DISPLAYATTR1, DlgProcDisplayAttrInput},
{IDD_DIALOG_DISPLAYATTR2, DlgProcDisplayAttrConv},
{IDD_DIALOG_SELKEY, DlgProcSelKey},
Expand Down
3 changes: 2 additions & 1 deletion imcrvcnf/imcrvcnf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ void SaveKanaTxt(HWND hwnd, LPCWSTR path);
INT_PTR CALLBACK DlgProcDictionary(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProcBehavior1(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProcBehavior2(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProcDisplay(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProcDisplay1(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProcDisplay2(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProcDisplayAttrInput(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProcDisplayAttrConv(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK DlgProcSelKey(HWND, UINT, WPARAM, LPARAM);
Expand Down
Loading

0 comments on commit 7cef83c

Please sign in to comment.