added: accelerator: ctrl+0 for (...) command
added: accelerator: ctrl+R for 'copy both' command added: accelerator: ctrl+a for the pad window (select all) added: on menu 'edit': cut, copy, paste, delete, copy both, paste formula cut, copy, paste, delete work with a window which has the focus 'copy both' copy the input and output edits changed: 'paste formula' is the old 'paste' command (pasting to the input edit) changed: the input edit can have 20480 characters now (previous was 2048) git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@233 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
f3ee187413
commit
d3b0262244
|
@ -1,4 +1,4 @@
|
|||
Version 0.9.0 prerelease (2009.11.01):
|
||||
Version 0.9.0 prerelease (2009.11.03):
|
||||
* fixed: when 'C' button was pressed, the cursor was not put in the edit window
|
||||
* added: Pad window - a multiline edit window
|
||||
* added: Checking for update dialog box
|
||||
|
|
|
@ -449,9 +449,9 @@ void Languages::InitGuiMessagesTab()
|
|||
InsertGuiPair(menu_view_lang_russian, "&Russian");
|
||||
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
|
||||
InsertGuiPair(menu_view_close_program, "&Close");
|
||||
InsertGuiPair(menu_edit_undo, "&Undo");
|
||||
InsertGuiPair(menu_edit_paste, "&Paste");
|
||||
InsertGuiPair(menu_edit_copy_result, "&Copy the result");
|
||||
InsertGuiPair(menu_edit_undo, "&Undo \tCtrl+Z");
|
||||
InsertGuiPair(menu_edit_paste_formula, "&Paste formula\tCtrl+V");
|
||||
InsertGuiPair(menu_edit_copy_result, "&Copy result \tCtrl+C");
|
||||
InsertGuiPair(menu_help_help, "&Help");
|
||||
InsertGuiPair(menu_help_project_page, "&Project page");
|
||||
InsertGuiPair(menu_help_about, "&About");
|
||||
|
@ -586,7 +586,7 @@ void Languages::InitGuiMessagesTab()
|
|||
InsertGuiPair(menu_view_lang_swedish, "&Szwedzki");
|
||||
InsertGuiPair(menu_view_close_program, "&Zamknij");
|
||||
InsertGuiPair(menu_edit_undo, "&Cofnij");
|
||||
InsertGuiPair(menu_edit_paste, "&Wklej");
|
||||
InsertGuiPair(menu_edit_paste_formula, "&Wklej");
|
||||
InsertGuiPair(menu_edit_copy_result, "&Kopiuj wynik");
|
||||
InsertGuiPair(menu_help_help, "&Pomoc");
|
||||
InsertGuiPair(menu_help_project_page, "&Strona projektu");
|
||||
|
@ -725,7 +725,7 @@ void Languages::InitGuiMessagesTab()
|
|||
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
|
||||
InsertGuiPair(menu_view_close_program, "&Close");
|
||||
InsertGuiPair(menu_edit_undo, "&Deshacer");
|
||||
InsertGuiPair(menu_edit_paste, "&Pegar");
|
||||
InsertGuiPair(menu_edit_paste_formula, "&Pegar");
|
||||
InsertGuiPair(menu_edit_copy_result, "&Copiar resultado");
|
||||
InsertGuiPair(menu_help_help, "&Ayuda");
|
||||
InsertGuiPair(menu_help_project_page, "&Pagina del proyecto");
|
||||
|
@ -861,7 +861,7 @@ void Languages::InitGuiMessagesTab()
|
|||
InsertGuiPair(menu_view_lang_swedish, "S&wedish");
|
||||
InsertGuiPair(menu_view_close_program, "&Afslut");
|
||||
InsertGuiPair(menu_edit_undo, "&Fortryd");
|
||||
InsertGuiPair(menu_edit_paste, "&Sæt ind");
|
||||
InsertGuiPair(menu_edit_paste_formula, "&Sæt ind");
|
||||
InsertGuiPair(menu_edit_copy_result, "&Kopier resultatet");
|
||||
InsertGuiPair(menu_help_help, "&Hjælp");
|
||||
InsertGuiPair(menu_help_project_page, "&Projekt side");
|
||||
|
@ -996,7 +996,7 @@ void Languages::InitGuiMessagesTab()
|
|||
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
|
||||
InsertGuiPair(menu_view_close_program, "&¹Ø±Õ");
|
||||
InsertGuiPair(menu_edit_undo, "&È¡Ïû");
|
||||
InsertGuiPair(menu_edit_paste, "&Õ³Ìù");
|
||||
InsertGuiPair(menu_edit_paste_formula, "&Õ³Ìù");
|
||||
InsertGuiPair(menu_edit_copy_result, "&¸´Öƽá¹û");
|
||||
InsertGuiPair(menu_help_help, "&°ïÖú");
|
||||
InsertGuiPair(menu_help_project_page, "&Èí¼þÖ÷Ò³");
|
||||
|
@ -1129,7 +1129,7 @@ void Languages::InitGuiMessagesTab()
|
|||
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
|
||||
InsertGuiPair(menu_view_close_program, "&Çàêðûòü");
|
||||
InsertGuiPair(menu_edit_undo, "&Îòìåíèòü äåéñòâèå");
|
||||
InsertGuiPair(menu_edit_paste, "&Âñòàâèòü");
|
||||
InsertGuiPair(menu_edit_paste_formula, "&Âñòàâèòü");
|
||||
InsertGuiPair(menu_edit_copy_result, "&Êîïèðîâàòü ðåçóëüòàò");
|
||||
InsertGuiPair(menu_help_help, "&Ïîìîùü");
|
||||
InsertGuiPair(menu_help_project_page, "&Ñàéò ïðîåêòà");
|
||||
|
@ -1265,7 +1265,7 @@ void Languages::InitGuiMessagesTab()
|
|||
InsertGuiPair(menu_view_lang_swedish, "S&venska");
|
||||
InsertGuiPair(menu_view_close_program, "&Avsluta");
|
||||
InsertGuiPair(menu_edit_undo, "&Ångra");
|
||||
InsertGuiPair(menu_edit_paste, "&Klistra in");
|
||||
InsertGuiPair(menu_edit_paste_formula, "&Klistra in");
|
||||
InsertGuiPair(menu_edit_copy_result, "&Kopiera result");
|
||||
InsertGuiPair(menu_help_help, "&Hjälp");
|
||||
InsertGuiPair(menu_help_project_page, "&Projektsida");
|
||||
|
|
|
@ -125,7 +125,7 @@ public:
|
|||
menu_view_lang_swedish,
|
||||
menu_view_close_program,
|
||||
menu_edit_undo,
|
||||
menu_edit_paste,
|
||||
menu_edit_paste_formula,
|
||||
menu_edit_copy_result,
|
||||
menu_help_help,
|
||||
menu_help_project_page,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
#include "compileconfig.h"
|
||||
#include "winmain.h"
|
||||
#include "update.h"
|
||||
|
@ -45,6 +46,45 @@ namespace MainWindowFunctions
|
|||
{
|
||||
|
||||
|
||||
int ToLower(int c)
|
||||
{
|
||||
if( c>='A' && c<='Z' )
|
||||
return c - 'A' + 'a';
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
this function compares two strings
|
||||
(case insensitive)
|
||||
*/
|
||||
bool EqualStrings(const char * str1, const char * str2)
|
||||
{
|
||||
for( ; ToLower(*str1) == ToLower(*str2) ; ++str1, ++str2 )
|
||||
if( *str1 == 0 )
|
||||
return true; // *str2 will be 0 too
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
returning true if hWnd is a handle of an edit control
|
||||
*/
|
||||
bool IsEditControl(HWND hWnd)
|
||||
{
|
||||
char buffer[30];
|
||||
|
||||
GetClassName( hWnd, buffer, sizeof(buffer)/sizeof(char) );
|
||||
|
||||
if( EqualStrings(buffer, "edit") )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
Loop through all the controls and remove the
|
||||
|
@ -238,60 +278,11 @@ return false;
|
|||
}
|
||||
|
||||
|
||||
int ToLower(int c)
|
||||
{
|
||||
if( c>='A' && c<='Z' )
|
||||
return c - 'A' + 'a';
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
this function compares two strings
|
||||
(case insensitive)
|
||||
*/
|
||||
bool EqualStrings(const char * str1, const char * str2)
|
||||
{
|
||||
for( ; ToLower(*str1) == ToLower(*str2) ; ++str1, ++str2 )
|
||||
if( *str1 == 0 )
|
||||
return true; // *str2 will be 0 too
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
this function is called when CTRL+C has been pressed
|
||||
|
||||
we're testing what type of control has a focus
|
||||
if it is not an edit control we will copy the result from the output edit
|
||||
and if is is an edit control we're checking whether the edit has a selecion or not,
|
||||
if it has not a selection we will copy the result otherwise we return 'false'
|
||||
and the CTRL+C will be passed into the standard procedure
|
||||
*/
|
||||
bool CopyResult()
|
||||
{
|
||||
char buffer[30];
|
||||
DWORD sel_start, sel_end;
|
||||
HWND focus = GetFocus();
|
||||
bool copy = true;
|
||||
|
||||
GetClassName( focus, buffer, sizeof(buffer)/sizeof(char) );
|
||||
|
||||
if( EqualStrings(buffer, "edit") )
|
||||
{
|
||||
SendMessage(focus, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||
|
||||
if( sel_start != sel_end )
|
||||
// the control has a selection
|
||||
copy = false;
|
||||
}
|
||||
|
||||
|
||||
if( copy )
|
||||
{
|
||||
// the control has no selection
|
||||
HWND main_window = GetPrgRes()->GetMainWindow();
|
||||
HWND output_edit = GetDlgItem(main_window, IDC_OUTPUT_EDIT);
|
||||
DWORD out_sel_start, out_sel_end;
|
||||
|
@ -299,42 +290,27 @@ bool copy = true;
|
|||
// we're getting the selection on the output edit
|
||||
// there may be no selection
|
||||
SendMessage(output_edit, EM_GETSEL, (WPARAM)&out_sel_start, (LPARAM)&out_sel_end);
|
||||
|
||||
// setting the selection for the whole control
|
||||
SendMessage(output_edit, EM_SETSEL, 0, -1);
|
||||
|
||||
// copying the result
|
||||
SendMessage(output_edit, WM_COPY, 0, 0);
|
||||
|
||||
// and restoring the selection to the previous state
|
||||
SendMessage(output_edit, EM_SETSEL, out_sel_start, out_sel_end);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
this function is called when CTRL+V has been pressed
|
||||
|
||||
if a focus is not on an edit control (or it can be on an edit
|
||||
but the edit must be read only) we're sending WM_PASTE into the
|
||||
input edit and setting a focus on it
|
||||
this is not Paste but PasteFormula (everything is copied to the input edit, even
|
||||
if the focus is on an another edit)
|
||||
*/
|
||||
bool Paste()
|
||||
bool PasteFormula()
|
||||
{
|
||||
char buffer[30];
|
||||
HWND focus = GetFocus();
|
||||
|
||||
GetClassName( focus, buffer, sizeof(buffer)/sizeof(char) );
|
||||
|
||||
if( EqualStrings(buffer, "edit") )
|
||||
{
|
||||
if( (GetWindowLong(focus, GWL_STYLE) & ES_READONLY) == 0 )
|
||||
return false;
|
||||
|
||||
// it's an edit but it has ES_READONLY style set
|
||||
}
|
||||
|
||||
HWND main_window = GetPrgRes()->GetMainWindow();
|
||||
HWND input_edit = GetDlgItem(main_window, IDC_INPUT_EDIT);
|
||||
|
||||
|
@ -412,7 +388,7 @@ HMENU menu = GetMenu(hWnd);
|
|||
SetMenuLanguageItem(menu, IDM_LANGUAGE_SWEDISH, Languages::menu_view_lang_swedish);
|
||||
SetMenuLanguageItem(menu, IDM_CLOSE_PROGRAM, Languages::menu_view_close_program);
|
||||
SetMenuLanguageItem(menu, IDM_EDIT_UNDO, Languages::menu_edit_undo);
|
||||
SetMenuLanguageItem(menu, IDM_EDIT_PASTE, Languages::menu_edit_paste);
|
||||
SetMenuLanguageItem(menu, IDM_EDIT_PASTE_FORMULA, Languages::menu_edit_paste_formula);
|
||||
SetMenuLanguageItem(menu, IDM_EDIT_COPY_RESULT, Languages::menu_edit_copy_result);
|
||||
SetMenuLanguageItem(menu, IDM_HELP_HELP, Languages::menu_help_help);
|
||||
SetMenuLanguageItem(menu, IDM_HELP_PROJECT_PAGE, Languages::menu_help_project_page);
|
||||
|
@ -814,28 +790,79 @@ void WmInitMenuPopUpView(HMENU menu)
|
|||
|
||||
void WmInitMenuPopUpEdit(HWND hWnd, HMENU menu)
|
||||
{
|
||||
char buffer[5];
|
||||
bool edit = false; // an edit control has the focus
|
||||
bool edit_sel = false; // there is something selected on the edit
|
||||
bool edit_readonly = false; // the edit is read only
|
||||
bool can_undo = false;
|
||||
|
||||
bool can_undo = SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_CANUNDO, 0 ,0);
|
||||
HWND focus = GetFocus();
|
||||
edit = IsEditControl(focus);
|
||||
|
||||
if( can_undo )
|
||||
if( edit )
|
||||
{
|
||||
DWORD sel_start, sel_end;
|
||||
SendMessage(focus, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end);
|
||||
|
||||
if( sel_start != sel_end )
|
||||
edit_sel = true;
|
||||
|
||||
if( (GetWindowLong(focus, GWL_STYLE) & ES_READONLY) != 0 )
|
||||
edit_readonly = true;
|
||||
}
|
||||
|
||||
|
||||
// undo
|
||||
if( edit && !edit_readonly && SendMessage(focus, EM_CANUNDO, 0 ,0) )
|
||||
EnableMenuItem(menu,IDM_EDIT_UNDO,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(menu,IDM_EDIT_UNDO,MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
// cut
|
||||
if( edit && edit_sel && !edit_readonly )
|
||||
EnableMenuItem(menu,IDM_EDIT_CUT,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(menu,IDM_EDIT_CUT,MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
if( IsClipboardFormatAvailable(CF_TEXT) )
|
||||
// paste
|
||||
if( edit && !edit_readonly )
|
||||
EnableMenuItem(menu,IDM_EDIT_PASTE,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(menu,IDM_EDIT_PASTE,MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
|
||||
GetDlgItemText(hWnd,IDC_OUTPUT_EDIT,buffer,sizeof(buffer));
|
||||
|
||||
if( buffer[0] == 0 )
|
||||
EnableMenuItem(menu,IDM_EDIT_COPY_RESULT,MF_BYCOMMAND | MF_GRAYED);
|
||||
// del
|
||||
if( edit && edit_sel && !edit_readonly )
|
||||
EnableMenuItem(menu,IDM_EDIT_DEL,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(menu,IDM_EDIT_DEL,MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
// copy
|
||||
if( edit && edit_sel )
|
||||
EnableMenuItem(menu,IDM_EDIT_COPY,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(menu,IDM_EDIT_COPY,MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
// copy result
|
||||
int input_size = SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||
int output_size = SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||
|
||||
if( output_size != 0 )
|
||||
EnableMenuItem(menu,IDM_EDIT_COPY_RESULT,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(menu,IDM_EDIT_COPY_RESULT,MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
// copy both
|
||||
if( input_size!=0 || output_size!=0 )
|
||||
EnableMenuItem(menu,IDM_EDIT_COPY_BOTH,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(menu,IDM_EDIT_COPY_BOTH,MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
// paste formula
|
||||
if( IsClipboardFormatAvailable(CF_TEXT) )
|
||||
EnableMenuItem(menu,IDM_EDIT_PASTE_FORMULA,MF_BYCOMMAND | MF_ENABLED);
|
||||
else
|
||||
EnableMenuItem(menu,IDM_EDIT_PASTE_FORMULA,MF_BYCOMMAND | MF_GRAYED);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -976,14 +1003,54 @@ return true;
|
|||
|
||||
BOOL WmCommand_EditUndo(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_UNDO, 0, 0);
|
||||
HWND focus = GetFocus();
|
||||
SendMessage(focus, EM_UNDO, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL WmCommand_EditPasteFormula(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND input_edit = GetDlgItem(hWnd, IDC_INPUT_EDIT);
|
||||
SendMessage(input_edit, WM_PASTE, 0, 0);
|
||||
SetFocus(input_edit);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL WmCommand_EditCopy(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND focus = GetFocus();
|
||||
SendMessage(focus, WM_COPY, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmCommand_EditCut(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND focus = GetFocus();
|
||||
SendMessage(focus, WM_CUT, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmCommand_EditPaste(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, WM_PASTE, 0, 0);
|
||||
HWND focus = GetFocus();
|
||||
SendMessage(focus, WM_PASTE, 0, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BOOL WmCommand_EditDel(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND focus = GetFocus();
|
||||
|
||||
if( IsEditControl(focus) )
|
||||
SendMessage(focus, EM_REPLACESEL, 1, (LPARAM)"");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -991,9 +1058,44 @@ return true;
|
|||
|
||||
BOOL WmCommand_EditCopyResult(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_SETSEL, 0, LPARAM(-1));
|
||||
SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, WM_COPY, 0, 0);
|
||||
SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_SETSEL, WPARAM(-1), 0);
|
||||
CopyResult();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL WmCommand_EditCopyBoth(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if( !OpenClipboard(hWnd) )
|
||||
return true;
|
||||
|
||||
unsigned int in_len = SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||
unsigned int out_len = SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_LINELENGTH, 0, 0);
|
||||
|
||||
HGLOBAL global = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, in_len+out_len + 20);
|
||||
|
||||
if( global )
|
||||
{
|
||||
char * text = (char*)GlobalLock(global);
|
||||
|
||||
if( text )
|
||||
{
|
||||
char * buf = GetPrgRes()->GetBufferTemp();
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_INPUT_EDIT, EM_GETLINE, 0, (LPARAM)buf);
|
||||
sprintf(text, "%s = ", buf);
|
||||
|
||||
SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, EM_GETLINE, 0, (LPARAM)buf);
|
||||
std::strcat(text, buf);
|
||||
|
||||
GlobalUnlock(global);
|
||||
SetClipboardData(CF_TEXT, global);
|
||||
}
|
||||
}
|
||||
|
||||
CloseClipboard();
|
||||
|
||||
if( global )
|
||||
GlobalFree(global);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1197,8 +1299,13 @@ void CreateCommandMessagesTable(Messages<BOOL> & cmessages)
|
|||
cmessages.Associate(IDM_CLOSE_PROGRAM, WmCommand_CloseProgram);
|
||||
cmessages.Associate(IDC_INPUT_EDIT, WmCommand_InputEditNotify);
|
||||
cmessages.Associate(IDM_EDIT_UNDO, WmCommand_EditUndo);
|
||||
cmessages.Associate(IDM_EDIT_PASTE, WmCommand_EditPaste);
|
||||
cmessages.Associate(IDM_EDIT_PASTE_FORMULA, WmCommand_EditPasteFormula);
|
||||
cmessages.Associate(IDM_EDIT_COPY_RESULT, WmCommand_EditCopyResult);
|
||||
cmessages.Associate(IDM_EDIT_COPY_BOTH, WmCommand_EditCopyBoth);
|
||||
cmessages.Associate(IDM_EDIT_COPY, WmCommand_EditCopy);
|
||||
cmessages.Associate(IDM_EDIT_CUT, WmCommand_EditCut);
|
||||
cmessages.Associate(IDM_EDIT_PASTE, WmCommand_EditPaste);
|
||||
cmessages.Associate(IDM_EDIT_DEL, WmCommand_EditDel);
|
||||
cmessages.Associate(IDCANCEL, WmCommand_IDCANCEL);
|
||||
cmessages.Associate(IDM_LANGUAGE_ENGLISH, WmCommand_LanguageEnglish);
|
||||
cmessages.Associate(IDM_LANGUAGE_POLISH, WmCommand_LanguagePolish);
|
||||
|
|
|
@ -339,6 +339,8 @@ LRESULT PadCreate(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
if( !edit )
|
||||
return 0;
|
||||
|
||||
GetPrgRes()->SetPadEdit(edit);
|
||||
|
||||
old_edit_proc = (WNDPROC)SetWindowLong(edit, GWL_WNDPROC, (LONG)EditSubclass);
|
||||
|
||||
// 65535 - 64KB
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
|
||||
|
||||
ParserManager::ParserManager() : buffer_len(2048)
|
||||
ParserManager::ParserManager() : buffer_len(20480)
|
||||
{
|
||||
buffer = 0;
|
||||
base_input = base_output = 10;
|
||||
|
|
|
@ -461,6 +461,16 @@ HWND ProgramResources::GetPadWindow()
|
|||
return pad_window;
|
||||
}
|
||||
|
||||
void ProgramResources::SetPadEdit(HWND h)
|
||||
{
|
||||
pad_edit = h;
|
||||
}
|
||||
|
||||
HWND ProgramResources::GetPadEdit()
|
||||
{
|
||||
return pad_edit;
|
||||
}
|
||||
|
||||
void ProgramResources::SetTabWindow(unsigned int id, HWND h)
|
||||
{
|
||||
if( id >= sizeof(tab_window) / sizeof(HWND) )
|
||||
|
@ -487,6 +497,11 @@ char * ProgramResources::GetBuffer()
|
|||
return buffer;
|
||||
}
|
||||
|
||||
char * ProgramResources::GetBufferTemp()
|
||||
{
|
||||
return buffer_temp;
|
||||
}
|
||||
|
||||
unsigned int ProgramResources::GetBufferSize()
|
||||
{
|
||||
return buffer_size;
|
||||
|
@ -559,16 +574,17 @@ int ProgramResources::GetParamSep()
|
|||
}
|
||||
|
||||
|
||||
|
||||
ProgramResources::ProgramResources()
|
||||
{
|
||||
// if you want to change the input buffer you have also to change
|
||||
// ParserManager::ParserManager() : buffer_len(2048) in parsermanager.cpp
|
||||
buffer_size = 2048;
|
||||
buffer_size = 20480;
|
||||
|
||||
buffer = new char[buffer_size];
|
||||
buffer[0] = 0;
|
||||
|
||||
buffer_temp = new char[buffer_size];
|
||||
buffer_temp[0] = 0;
|
||||
|
||||
always_on_top = false;
|
||||
view = view_normal;
|
||||
|
@ -579,6 +595,8 @@ ProgramResources::ProgramResources()
|
|||
|
||||
hInstance = 0;
|
||||
main_window = 0;
|
||||
pad_window = 0;
|
||||
pad_edit = 0;
|
||||
|
||||
base_input = 10;
|
||||
base_output = 10;
|
||||
|
@ -628,6 +646,7 @@ ProgramResources::ProgramResources()
|
|||
ProgramResources::~ProgramResources()
|
||||
{
|
||||
delete [] buffer;
|
||||
delete [] buffer_temp;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -221,6 +221,9 @@ public:
|
|||
void SetPadWindow(HWND h);
|
||||
HWND GetPadWindow();
|
||||
|
||||
void SetPadEdit(HWND h);
|
||||
HWND GetPadEdit();
|
||||
|
||||
/*!
|
||||
handles to the dialogs which are placed on the tab control
|
||||
*/
|
||||
|
@ -284,6 +287,7 @@ public:
|
|||
Languages * GetLanguages();
|
||||
Convert * GetConvert();
|
||||
char * GetBuffer();
|
||||
char * GetBufferTemp(); // this buffer can be used for temporary tasks
|
||||
unsigned int GetBufferSize();
|
||||
|
||||
|
||||
|
@ -439,10 +443,12 @@ private:
|
|||
|
||||
unsigned int buffer_size;
|
||||
char * buffer;
|
||||
char * buffer_temp;
|
||||
|
||||
HINSTANCE hInstance;
|
||||
HWND main_window;
|
||||
HWND pad_window;
|
||||
HWND pad_edit; // edit control on the pad window
|
||||
HWND tab_window[6];
|
||||
|
||||
int precision;
|
||||
|
|
|
@ -221,9 +221,14 @@
|
|||
#define IDM_LANGUAGE_SWEDISH 40016
|
||||
#define IDM_CLOSE_PROGRAM 40020
|
||||
#define IDM_EDIT_UNDO 40030
|
||||
#define IDM_EDIT_PASTE 40031
|
||||
#define IDM_EDIT_PASTE_FORMULA 40031
|
||||
#define IDM_EDIT_COPY_RESULT 40032
|
||||
#define IDM_EDIT_COPY_BOTH 40033
|
||||
#define IDM_EDIT_COPY 40034
|
||||
#define IDM_EDIT_CUT 40035
|
||||
#define IDM_HELP_HELP 40040
|
||||
#define IDM_EDIT_PASTE 40036
|
||||
#define IDM_EDIT_DEL 40037
|
||||
#define IDM_HELP_PROJECT_PAGE 40041
|
||||
#define IDM_HELP_CHECK_UPDATE 40042
|
||||
#define IDM_HELP_ABOUT 40049
|
||||
|
|
|
@ -40,9 +40,16 @@ BEGIN
|
|||
END
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "&Undo", 40030
|
||||
MENUITEM "&Paste", 40031
|
||||
MENUITEM "&Copy the result", 40032
|
||||
MENUITEM "&Undo \tCtrl+Z", 40030
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Cut \tCtrl+X", 40035
|
||||
MENUITEM "&Copy", 40034
|
||||
MENUITEM "&Paste", 40036
|
||||
MENUITEM "&Delete \tDel", 40037
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Copy the result\tCtrl+C", 40032
|
||||
MENUITEM "&Copy both\tCtrl+R", 40033
|
||||
MENUITEM "&Paste formula\tCtrl+V", 40031
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
|
@ -68,14 +75,14 @@ BEGIN
|
|||
END
|
||||
POPUP "Edit"
|
||||
BEGIN
|
||||
MENUITEM "Undo", MENUPAD_EDIT_UNDO
|
||||
MENUITEM "Undo \tCtrl+Z", MENUPAD_EDIT_UNDO
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cut", MENUPAD_EDIT_CUT
|
||||
MENUITEM "Copy", MENUPAD_EDIT_COPY
|
||||
MENUITEM "Paste", MENUPAD_EDIT_PASTE
|
||||
MENUITEM "Delete", MENUPAD_EDIT_DEL
|
||||
MENUITEM "Cut \tCtrl+X", MENUPAD_EDIT_CUT
|
||||
MENUITEM "Copy \tCtrl+C", MENUPAD_EDIT_COPY
|
||||
MENUITEM "Paste \tCtrl+V", MENUPAD_EDIT_PASTE
|
||||
MENUITEM "Delete \tDel", MENUPAD_EDIT_DEL
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select all", MENUPAD_EDIT_SELECTALL
|
||||
MENUITEM "Select all \tCtrl+A", MENUPAD_EDIT_SELECTALL
|
||||
END
|
||||
END
|
||||
|
||||
|
|
|
@ -126,29 +126,66 @@ return static_cast<int>( error_code );
|
|||
}
|
||||
|
||||
|
||||
bool AcceleratorForMainWindow(MSG & msg)
|
||||
{
|
||||
bool sent = true;
|
||||
|
||||
switch( msg.wParam )
|
||||
{
|
||||
case 'C':
|
||||
sent = MainWindowFunctions::CopyResult();
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
sent = MainWindowFunctions::PasteFormula();
|
||||
break;
|
||||
|
||||
case 'R':
|
||||
sent = SendMessage(GetPrgRes()->GetMainWindow(), WM_COMMAND, IDM_EDIT_COPY_BOTH, 0);
|
||||
break;
|
||||
|
||||
case '0':
|
||||
SendMessage(GetPrgRes()->GetMainWindow(), WM_COMMAND, IDC_BUTTON_BRACKETS_ALL, 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
sent = false;
|
||||
}
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
|
||||
bool AcceleratorForPadEdit(MSG & msg)
|
||||
{
|
||||
if( msg.wParam == 'A' )
|
||||
{
|
||||
SendMessage(GetPrgRes()->GetPadWindow(), WM_COMMAND, MENUPAD_EDIT_SELECTALL, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CheckAcceleratorKeys(MSG & msg)
|
||||
{
|
||||
if( msg.message != WM_KEYDOWN )
|
||||
return false;
|
||||
|
||||
if( (GetKeyState(VK_CONTROL) & 0xff00) == 0 )
|
||||
return false;
|
||||
|
||||
if( msg.hwnd == GetPrgRes()->GetPadEdit() )
|
||||
return AcceleratorForPadEdit(msg);
|
||||
|
||||
return AcceleratorForMainWindow(msg);
|
||||
}
|
||||
|
||||
|
||||
void SendMessage(MSG & msg)
|
||||
{
|
||||
bool sent = false;
|
||||
|
||||
// if there's CTRL+C or CTRL+V pressed we're trying to copy
|
||||
// a result from the output edit or trying to paste something from the clipboard
|
||||
if( msg.message==WM_KEYDOWN && (GetKeyState(VK_CONTROL) & 0xff00)!=0 )
|
||||
{
|
||||
if( msg.wParam == 'C' )
|
||||
{
|
||||
if( MainWindowFunctions::CopyResult() )
|
||||
sent = true;
|
||||
}
|
||||
else
|
||||
if( msg.wParam == 'V' )
|
||||
{
|
||||
if( MainWindowFunctions::Paste() )
|
||||
sent = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool sent = CheckAcceleratorKeys(msg);
|
||||
|
||||
// we give our own special function for navigating from the keyboard
|
||||
// if our function returns false then we use a standard navigation
|
||||
|
|
|
@ -66,7 +66,8 @@ namespace MainWindowFunctions
|
|||
{
|
||||
bool SetNextFocus(WPARAM wParam);
|
||||
bool CopyResult();
|
||||
bool Paste();
|
||||
bool PasteFormula();
|
||||
BOOL WmCommand_EditCopyBoth(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void CreateMainMessagesTable(Messages<BOOL> & messages);
|
||||
BOOL CALLBACK AboutProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue