GUI Enhancement: Column Editor

- fix override warnings
- replace SendMessage check with isCheckedOrNot
- make translation consistent

Fix #13667, close #13668
pull/13584/head^2
ozone10 2023-05-08 11:57:59 +02:00 committed by Don Ho
parent 8250a81d6e
commit 41af936855
5 changed files with 62 additions and 63 deletions

View File

@ -1282,15 +1282,15 @@ You can define several column markers by using white space to separate the diffe
<ColumnEditor title="Column Editor">
<Item id="2023" name="&amp;Text to Insert"/>
<Item id="2033" name="&amp;Number to Insert"/>
<Item id="2030" name="&amp;Initial number :"/>
<Item id="2031" name="Increase b&amp;y :"/>
<Item id="2038" name="&amp;Leading :"/>
<Item id="2030" name="&amp;Initial number:"/>
<Item id="2031" name="Increase b&amp;y:"/>
<Item id="2038" name="&amp;Leading:"/>
<ComboBox id="2039">
<Element name="None"/>
<Element name="Zeros"/>
<Element name="Spaces"/>
</ComboBox>
<Item id="2036" name="&amp;Repeat :"/>
<Item id="2036" name="&amp;Repeat:"/>
<Item id="2032" name="Format"/>
<Item id="2024" name="&amp;Dec"/>
<Item id="2025" name="&amp;Oct"/>

View File

@ -1282,15 +1282,15 @@ You can define several column markers by using white space to separate the diffe
<ColumnEditor title="Column Editor">
<Item id="2023" name="&amp;Text to Insert"/>
<Item id="2033" name="&amp;Number to Insert"/>
<Item id="2030" name="&amp;Initial number :"/>
<Item id="2031" name="Increase b&amp;y :"/>
<Item id="2038" name="&amp;Leading :"/>
<Item id="2030" name="&amp;Initial number:"/>
<Item id="2031" name="Increase b&amp;y:"/>
<Item id="2038" name="&amp;Leading:"/>
<ComboBox id="2039">
<Element name="None"/>
<Element name="Zeros"/>
<Element name="Spaces"/>
</ComboBox>
<Item id="2036" name="&amp;Repeat :"/>
<Item id="2036" name="&amp;Repeat:"/>
<Item id="2032" name="Format"/>
<Item id="2024" name="&amp;Dec"/>
<Item id="2025" name="&amp;Oct"/>

View File

@ -15,13 +15,13 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <vector>
#include <algorithm>
//#include <vector>
//#include <algorithm>
#include "columnEditor.h"
#include "ScintillaEditView.h"
void ColumnEditorDlg::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView)
void ColumnEditorDlg::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView)
{
Window::init(hInst, hPere);
if (!ppEditView)
@ -29,7 +29,7 @@ void ColumnEditorDlg::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEd
_ppEditView = ppEditView;
}
void ColumnEditorDlg::display(bool toShow) const
void ColumnEditorDlg::display(bool toShow) const
{
Window::display(toShow);
if (toShow)
@ -38,7 +38,7 @@ void ColumnEditorDlg::display(bool toShow) const
intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
switch (message)
{
case WM_INITDIALOG :
{
@ -78,7 +78,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
::SendDlgItemMessage(_hSelf, format, BM_SETCHECK, TRUE, 0);
switchTo(colEditParam._mainChoice);
goToCenter();
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
return TRUE;
}
@ -148,7 +148,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
return TRUE;
}
case WM_COMMAND :
case WM_COMMAND:
{
switch (wParam)
{
@ -187,7 +187,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
auto endPos = (*_ppEditView)->execute(SCI_GETLENGTH);
auto endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos);
int lineAllocatedLen = 1024;
constexpr int lineAllocatedLen = 1024;
TCHAR *line = new TCHAR[lineAllocatedLen];
for (size_t i = cursorLine ; i <= static_cast<size_t>(endLine); ++i)
@ -237,7 +237,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
}
UCHAR format = getFormat();
display(false);
if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE) || (*_ppEditView)->execute(SCI_GETSELECTIONS) > 1)
{
ColumnModeInfos colInfos = (*_ppEditView)->getColumnModeSelectInfo();
@ -280,11 +280,11 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
}
assert(numbers.size() > 0);
int lineAllocatedLen = 1024;
constexpr int lineAllocatedLen = 1024;
TCHAR *line = new TCHAR[lineAllocatedLen];
UCHAR f = format & MASK_FORMAT;
int base = 10;
if (f == BASE_16)
base = 16;
@ -382,7 +382,7 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
TCHAR str[stringSize]{};
switch (LOWORD(wParam))
{
{
case IDC_COL_TEXT_EDIT:
{
::GetDlgItemText(_hSelf, LOWORD(wParam), str, stringSize);
@ -494,11 +494,11 @@ void ColumnEditorDlg::switchTo(bool toText)
UCHAR ColumnEditorDlg::getFormat()
{
UCHAR f = 0; // Dec by default
if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_HEX_RADIO, BM_GETCHECK, 0, 0))
if (isCheckedOrNot(IDC_COL_HEX_RADIO))
f = 1;
else if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_OCT_RADIO, BM_GETCHECK, 0, 0))
else if (isCheckedOrNot(IDC_COL_OCT_RADIO))
f = 2;
else if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_BIN_RADIO, BM_GETCHECK, 0, 0))
else if (isCheckedOrNot(IDC_COL_BIN_RADIO))
f = 3;
return f;
}
@ -511,18 +511,18 @@ ColumnEditorParam::leadingChoice ColumnEditorDlg::getLeading()
{
case 0:
default:
{
leading = ColumnEditorParam::noneLeading;
break;
}
case 1:
{
leading = ColumnEditorParam::zeroLeading;
break;
}
case 2:
{
leading = ColumnEditorParam::spaceLeading;
leading = ColumnEditorParam::noneLeading;
break;
}
case 1:
{
leading = ColumnEditorParam::zeroLeading;
break;
}
case 2:
{
leading = ColumnEditorParam::spaceLeading;
break;
}
}

View File

@ -29,27 +29,26 @@ public :
ColumnEditorDlg() = default;
void init(HINSTANCE hInst, HWND hPere, ScintillaEditView **ppEditView);
virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true) {
void create(int dialogID, bool isRTL = false, bool msgDestParent = true) override {
StaticDialog::create(dialogID, isRTL, msgDestParent);
};
void doDialog(bool isRTL = false) {
if (!isCreated())
create(IDD_COLUMNEDIT, isRTL);
bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0));
const bool isTextMode = isCheckedOrNot(IDC_COL_TEXT_RADIO);
display();
::SetFocus(::GetDlgItem(_hSelf, isTextMode?IDC_COL_TEXT_EDIT:IDC_COL_INITNUM_EDIT));
};
virtual void display(bool toShow = true) const;
void display(bool toShow = true) const override;
void switchTo(bool toText);
UCHAR getFormat();
ColumnEditorParam::leadingChoice getLeading();
protected :
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private :
ScintillaEditView **_ppEditView = nullptr;
ScintillaEditView **_ppEditView = nullptr;
};

View File

@ -19,34 +19,34 @@
#include "columnEditor_rc.h"
IDD_COLUMNEDIT DIALOGEX 26, 41, 223, 221
IDD_COLUMNEDIT DIALOGEX 0, 0, 220, 214
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Column / Multi-Selection Editor"
CAPTION "Column / Multi-Selection Editor"
FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0
BEGIN
GROUPBOX "",IDC_COL_TEXT_GRP_STATIC,12,14,124,50
GROUPBOX "",IDC_COL_NUM_GRP_STATIC,12,79,204,135
CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,7,5,124,9
CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP, 7,70,204,9
EDITTEXT IDC_COL_TEXT_EDIT,25,32,97,14,ES_AUTOHSCROLL
RTEXT "&Initial number :",IDC_COL_INITNUM_STATIC,15,91,76,8
EDITTEXT IDC_COL_INITNUM_EDIT,95,89,38,12,ES_NUMBER
RTEXT "Increase b&y :",IDC_COL_INCRNUM_STATIC,16,108,75,8
EDITTEXT IDC_COL_INCREASENUM_EDIT,95,106,38,12,ES_NUMBER
CONTROL "&Text to Insert",IDC_COL_TEXT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,13,6,124,10
CONTROL "&Number to Insert",IDC_COL_NUM_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP | WS_GROUP,13,68,204,10
RTEXT "&Repeat :",IDC_COL_REPEATNUM_STATIC,16,125,75,8
EDITTEXT IDC_COL_REPEATNUM_EDIT,95,123,38,12,ES_NUMBER
GROUPBOX "",IDC_COL_TEXT_GRP_STATIC,8,14,124,46
EDITTEXT IDC_COL_TEXT_EDIT,20,32,97,12,ES_AUTOHSCROLL
RTEXT "&Leading :",IDC_COL_LEADING_STATIC,16,142,75,8
COMBOBOX IDC_COL_LEADING_COMBO,95,140,100,30,CBS_DROPDOWNLIST | WS_TABSTOP
GROUPBOX "",IDC_COL_NUM_GRP_STATIC,8,77,204,130
RTEXT "&Initial number:",IDC_COL_INITNUM_STATIC,10,89,76,8
EDITTEXT IDC_COL_INITNUM_EDIT,90,87,38,12,ES_NUMBER
RTEXT "Increase b&y:",IDC_COL_INCRNUM_STATIC,10,106,75,8
EDITTEXT IDC_COL_INCREASENUM_EDIT,90,104,38,12,ES_NUMBER
RTEXT "&Repeat:",IDC_COL_REPEATNUM_STATIC,10,123,75,8
EDITTEXT IDC_COL_REPEATNUM_EDIT,90,121,38,12,ES_NUMBER
RTEXT "&Leading:",IDC_COL_LEADING_STATIC,10,140,75,8
COMBOBOX IDC_COL_LEADING_COMBO,90,138,100,30,CBS_DROPDOWNLIST | WS_TABSTOP
CONTROL "&Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,30,175,70,10
CONTROL "&Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,124,175,70,10
CONTROL "&Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,30,189,70,10
CONTROL "&Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,124,189,70,10
GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,20,163,188,44,BS_CENTER
DEFPUSHBUTTON "OK",IDOK,145,13,70,14,BS_NOTIFY
PUSHBUTTON "Cancel",IDCANCEL,145,36,70,14,BS_NOTIFY
GROUPBOX "Format",IDC_COL_FORMAT_GRP_STATIC,16,155,188,44,BS_CENTER
CONTROL "&Dec",IDC_COL_DEC_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,168,70,10
CONTROL "&Hex",IDC_COL_HEX_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,122,168,70,10
CONTROL "&Oct",IDC_COL_OCT_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,27,183,70,10
CONTROL "&Bin",IDC_COL_BIN_RADIO,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,122,183,70,10
DEFPUSHBUTTON "OK",IDOK,142,18,70,14
PUSHBUTTON "Cancel",IDCANCEL,142,36,70,14
END