added: Pad window - a multiline edit window

files: pad.h pad.cpp


git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@208 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2009-10-13 22:41:00 +00:00
parent 637f82e5e2
commit ad3625deab
15 changed files with 144 additions and 30 deletions

View File

@ -1,6 +1,10 @@
Version 0.9.0 prerelease (2009.09.15):
* added: Pad window - a multiline edit window
Version 0.8.7 prerelease (2009.09.16):
* added: new language: Swedish
translation made by: Lars 'Bäfvert' Gäfvert <lars.gafvert at gmail dot com>
translation made by: Lars 'Bafvert' Gafvert <lars.gafvert at gmail dot com>
* changed: version of the TTMath library: 0.9.0 prerelease now
Changes from TTMath 0.9.0 prerelease relating to TTCalc:

View File

@ -1,17 +1,17 @@
o = resource.o calculation.o convert.o functions.o iniparser.o languages.o mainwindow.o parsermanager.o programresources.o tabs.o variables.o winmain.o
o = resource.o calculation.o convert.o functions.o iniparser.o languages.o mainwindow.o pad.o parsermanager.o programresources.o tabs.o variables.o winmain.o
calculation.o: calculation.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h
convert.o: convert.cpp convert.h compileconfig.h bigtypes.h
functions.o: functions.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
iniparser.o: iniparser.cpp compileconfig.h iniparser.h
languages.o: languages.cpp compileconfig.h languages.h bigtypes.h
mainwindow.o: mainwindow.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h
mainwindow.o: mainwindow.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h pad.h
pad.o: pad.cpp programresources.h compileconfig.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h
parsermanager.o: parsermanager.cpp compileconfig.h parsermanager.h resource.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h tabs.h messages.h
programresources.o: programresources.cpp compileconfig.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
tabs.o: tabs.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
variables.o: variables.cpp compileconfig.h tabs.h resource.h messages.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h
winmain.o: winmain.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h
winmain.o: winmain.cpp compileconfig.h winmain.h programresources.h iniparser.h languages.h bigtypes.h threadcontroller.h stopcalculating.h convert.h resource.h messages.h tabs.h pad.h
.SUFFIXES: .cpp .o

View File

@ -61,11 +61,17 @@
/*!
this disables a Visual C++ warning about converting int to bool
"warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)"
this disables a Visual C++ warning
*/
#ifdef _MSC_VER
//"warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)"
#pragma warning (disable : 4800)
// warning C4996: 'sprintf': This function or variable may be unsafe.
#pragma warning (disable : 4996)
#endif
#ifndef _WIN32_IE

View File

@ -443,6 +443,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_normal_view, "No&rmal view");
InsertGuiPair(menu_view_compact_view, "C&ompact view");
InsertGuiPair(menu_view_always_on_top, "&Always on top");
InsertGuiPair(menu_view_pad, "&Pad");
InsertGuiPair(menu_view_lang_english, "&English");
InsertGuiPair(menu_view_lang_polish, "&Polish");
InsertGuiPair(menu_view_lang_spanish, "&Spanish");
@ -460,6 +461,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(cant_init_calculations, "I could not initialize the module for calculations");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "I could not create the second thread for calculating");
InsertGuiPair(cant_create_pad, "I could not create the pad window");
InsertGuiPair(cant_create_main_window, "I could not create the main window of the application");
InsertGuiPair(cant_init_common_controls,"I could not initialize the common controls (InitCommonControlsEx)");
InsertGuiPair(about_text,
@ -577,6 +579,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_normal_view, "Widok no&rmalny");
InsertGuiPair(menu_view_compact_view, "Widok &kompaktowy");
InsertGuiPair(menu_view_always_on_top, "Zawsze na &wierzchu");
InsertGuiPair(menu_view_pad, "&Pad");
InsertGuiPair(menu_view_lang_english, "&Angielski");
InsertGuiPair(menu_view_lang_polish, "&Polski");
InsertGuiPair(menu_view_lang_spanish, "&Hiszpañski");
@ -594,6 +597,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(cant_init_calculations, "Nie uda³o siê zainicjalizowaæ modu³u obs³ugi obliczeñ");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "Nie uda³o siê utworzyæ drugiego w¹tku do obliczeñ");
InsertGuiPair(cant_create_pad, "I could not create the pad window");
InsertGuiPair(cant_create_main_window, "Nie uda³o siê utworzyæ g³ównego okna aplikacji");
InsertGuiPair(cant_init_common_controls,"Nie uda³o siê zainicjalizowaæ obs³ugi Common Controls (InitCommonControlsEx)");
InsertGuiPair(about_text,
@ -715,6 +719,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_normal_view, "Vista No&rmal");
InsertGuiPair(menu_view_compact_view, "Vista C&ompacta");
InsertGuiPair(menu_view_always_on_top, "&Siempre arriba");
InsertGuiPair(menu_view_pad, "&Pad");
InsertGuiPair(menu_view_lang_english, "&Ingles");
InsertGuiPair(menu_view_lang_polish, "&Polaco");
InsertGuiPair(menu_view_lang_spanish, "&Español");
@ -732,6 +737,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(cant_init_calculations, "No se puede inicializar el modulo de calculo");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "No se puede crear la segunda hebra para calcular");
InsertGuiPair(cant_create_pad, "I could not create the pad window");
InsertGuiPair(cant_create_main_window, "No se puede crear la ventana principal par ala aplicacion");
InsertGuiPair(cant_init_common_controls,"No se pueden inicializar los controles comunes (InitCommonControlsEx)");
InsertGuiPair(about_text,
@ -849,6 +855,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_normal_view, "No&rmal visning");
InsertGuiPair(menu_view_compact_view, "K&ompakt visning");
InsertGuiPair(menu_view_always_on_top, "&Altid øverst");
InsertGuiPair(menu_view_pad, "&Pad");
InsertGuiPair(menu_view_lang_english, "&Engelsk");
InsertGuiPair(menu_view_lang_polish, "&Polsk");
InsertGuiPair(menu_view_lang_spanish, "&Spansk");
@ -866,6 +873,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(cant_init_calculations, "Moduelt for uregninger kunne ikke sættes i gang");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "Den anden tråd for udregning kunne ikke laves");
InsertGuiPair(cant_create_pad, "I could not create the pad window");
InsertGuiPair(cant_create_main_window, "Applikationens hovedvindue kunne ikke laves");
InsertGuiPair(cant_init_common_controls,"De fælles kontrol indstillinger kunne ikke sættes i gang (InitCommonControlsEx)");
InsertGuiPair(about_text,
@ -982,6 +990,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_normal_view, "&ÆÕͨÊÓͼ");
InsertGuiPair(menu_view_compact_view, "&ÃÔÄãÊÓͼ");
InsertGuiPair(menu_view_always_on_top, "&×ÜÔÚ×îÇ°");
InsertGuiPair(menu_view_pad, "&Pad");
InsertGuiPair(menu_view_lang_english, "&Ó¢Óï");
InsertGuiPair(menu_view_lang_polish, "&²¨À¼Óï");
InsertGuiPair(menu_view_lang_spanish, "&Î÷°àÑÀÓï");
@ -999,6 +1008,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(cant_init_calculations, "²»Äܳõʼ»¯¼ÆËãÆ÷Ä£ÐÍ");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "²»ÄÜ´´½¨Á½¸öÏß³ÌÀ´ÔËËã");
InsertGuiPair(cant_create_pad, "I could not create the pad window");
InsertGuiPair(cant_create_main_window, "²»ÄÜ´´½¨Ó¦ÓóÌÐòÖ÷´°¿Ú");
InsertGuiPair(cant_init_common_controls,"²»Äܳõʼ»¯Í¨Óÿؼþ(InitCommonControlsEx)");
InsertGuiPair(about_text,
@ -1113,6 +1123,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_normal_view, "&Îáû÷íûé âèä");
InsertGuiPair(menu_view_compact_view, "&Êîìïàêòíûé âèä");
InsertGuiPair(menu_view_always_on_top, "&Âñåãäà ïîâåðõ äðóãèõ îêîí");
InsertGuiPair(menu_view_pad, "&Pad");
InsertGuiPair(menu_view_lang_english, "&Àíãëèéñêèé");
InsertGuiPair(menu_view_lang_polish, "&Ïîëüñêèé");
InsertGuiPair(menu_view_lang_spanish, "&Èñïàíñêèé");
@ -1130,6 +1141,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(cant_init_calculations, "Íå ìîãó èíèöèàëèçèðîâàòü ìîäóëü äëÿ ðàñ÷åòîâ");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "Íå ìîãó ñîçäàòü âòîðîé ïîòîê äëÿ ðàñ÷åòîâ");
InsertGuiPair(cant_create_pad, "I could not create the pad window");
InsertGuiPair(cant_create_main_window, "Íå ìîãó îòêðûòü ãëàâíîå îêíî ïðîãðàììû");
InsertGuiPair(cant_init_common_controls,"Íå ìîãó èíèöèàëèçèðîâàòü óïðàâëåíèå (InitCommonControlsEx)");
InsertGuiPair(about_text,
@ -1247,6 +1259,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_normal_view, "No&rmal visning");
InsertGuiPair(menu_view_compact_view, "K&ompakt visning");
InsertGuiPair(menu_view_always_on_top, "&Alltid överst");
InsertGuiPair(menu_view_pad, "&Pad");
InsertGuiPair(menu_view_lang_english, "&Engelska");
InsertGuiPair(menu_view_lang_polish, "&Polska");
InsertGuiPair(menu_view_lang_spanish, "&Spanska");
@ -1264,6 +1277,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(cant_init_calculations, "Beräkningen kunde inte initieras!");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "Den andra tråden för uträkning kunde inte skapas");
InsertGuiPair(cant_create_pad, "I could not create the pad window");
InsertGuiPair(cant_create_main_window, "Applikationens huvudfönster kunde inte skapas");
InsertGuiPair(cant_init_common_controls,"Inställningarna kunde inte initieras (InitCommonControlsEx)");
InsertGuiPair(about_text,

View File

@ -115,6 +115,7 @@ public:
menu_view_normal_view,
menu_view_compact_view,
menu_view_always_on_top,
menu_view_pad,
menu_view_lang_english,
menu_view_lang_polish,
menu_view_lang_spanish,
@ -132,6 +133,7 @@ public:
cant_init_calculations,
message_box_error_caption,
cant_create_thread,
cant_create_pad,
cant_create_main_window,
cant_init_common_controls,
cant_find_help,

View File

@ -402,6 +402,7 @@ HMENU menu = GetMenu(hWnd);
SetMenuLanguageItem(menu, IDM_NORMAL_VIEW, Languages::menu_view_normal_view);
SetMenuLanguageItem(menu, IDM_COMPACT_VIEW, Languages::menu_view_compact_view);
SetMenuLanguageItem(menu, IDM_ALWAYS_ON_TOP, Languages::menu_view_always_on_top);
SetMenuLanguageItem(menu, IDM_PAD, Languages::menu_view_pad);
SetMenuLanguageItem(menu, IDM_LANGUAGE_ENGLISH, Languages::menu_view_lang_english);
SetMenuLanguageItem(menu, IDM_LANGUAGE_POLISH, Languages::menu_view_lang_polish);
SetMenuLanguageItem(menu, IDM_LANGUAGE_SPANISH, Languages::menu_view_lang_spanish);
@ -764,6 +765,15 @@ void WmInitMenuPopUpView(HMENU menu)
}
if( GetPrgRes()->IsPadVisible() )
{
CheckMenuItem(menu,IDM_PAD,MF_BYCOMMAND|MF_CHECKED);
}
else
{
CheckMenuItem(menu,IDM_PAD,MF_BYCOMMAND|MF_UNCHECKED);
}
// languages
@ -891,6 +901,14 @@ return true;
}
BOOL WmCommand_Pad(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
GetPrgRes()->TurnPad();
return true;
}
BOOL WmCommand_HelpAbout(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
DialogBox(GetPrgRes()->GetInstance(),MAKEINTRESOURCE(IDD_ABOUT_DIALOG),hWnd,AboutProc);
@ -1155,11 +1173,12 @@ return true;
}
void CreateCommandMessagesTable(Messages & cmessages)
void CreateCommandMessagesTable(Messages<BOOL> & cmessages)
{
cmessages.Associate(IDM_ALWAYS_ON_TOP, WmCommand_AlwaysOnTop);
cmessages.Associate(IDM_NORMAL_VIEW, WmCommand_NormalView);
cmessages.Associate(IDM_COMPACT_VIEW, WmCommand_CompactView);
cmessages.Associate(IDM_PAD, WmCommand_Pad);
cmessages.Associate(IDM_HELP_ABOUT, WmCommand_HelpAbout);
cmessages.Associate(IDM_NEW_WINDOW, WmCommand_NewWindow);
cmessages.Associate(IDM_CLOSE_PROGRAM, WmCommand_CloseProgram);
@ -1182,7 +1201,7 @@ void CreateCommandMessagesTable(Messages & cmessages)
BOOL WmCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static Messages command_messages;
static Messages<BOOL> command_messages;
if( command_messages.Empty() )
// initiation
@ -1196,7 +1215,7 @@ static Messages command_messages;
void CreateMainMessagesTable(Messages & messages)
void CreateMainMessagesTable(Messages<BOOL> & messages)
{
messages.Associate(WM_INITDIALOG, WmInitDialog);
messages.Associate(WM_MOVE, WmMove);

View File

@ -42,10 +42,12 @@
#include <windows.h>
template<typename ProcReturnType>
class Messages
{
public:
typedef BOOL (*MessageFunction)(HWND, UINT, WPARAM, LPARAM);
typedef ProcReturnType (*MessageFunction)(HWND, UINT, WPARAM, LPARAM);
typedef std::map<UINT, MessageFunction> MessageTable;
@ -61,19 +63,28 @@ public:
}
bool Call(UINT key, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ProcReturnType Call(UINT key, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool * method_exists = 0)
{
MessageTable::iterator i = message_table.find(key);
typename MessageTable::iterator i = message_table.find(key);
if( i == message_table.end() )
{
if( method_exists )
*method_exists = false;
return false;
}
if( method_exists )
*method_exists = true;
return i->second(hWnd, message, wParam, lParam);
}
bool IsMessage(UINT key)
{
MessageTable::iterator i = message_table.find(key);
typename MessageTable::iterator i = message_table.find(key);
if( i == message_table.end() )
return false;

View File

@ -376,6 +376,16 @@ HWND ProgramResources::GetMainWindow()
return main_window;
}
void ProgramResources::SetPadWindow(HWND h)
{
pad_window = h;
}
HWND ProgramResources::GetPadWindow()
{
return pad_window;
}
void ProgramResources::SetTabWindow(unsigned int id, HWND h)
{
if( id >= sizeof(tab_window) / sizeof(HWND) )
@ -430,6 +440,26 @@ int ProgramResources::GetPrecision()
void ProgramResources::TurnPad()
{
show_pad = !show_pad;
if( show_pad )
{
ShowWindow(pad_window, SW_SHOW);
}
else
{
ShowWindow(pad_window, SW_HIDE);
}
}
bool ProgramResources::IsPadVisible()
{
return show_pad;
}
ProgramResources::ProgramResources()
{
// if you want to change the input buffer you have also to change
@ -481,6 +511,8 @@ ProgramResources::ProgramResources()
variables_id = 0;
functions_id = 0;
show_pad = false;
}

View File

@ -43,12 +43,13 @@
\brief various kinds of objects using by the application
*/
#include <ttmath/ttmathobjects.h>
#include "compileconfig.h"
#include "iniparser.h"
#include "languages.h"
#include "threadcontroller.h"
#include "convert.h"
#include <ttmath/ttmathobjects.h>
#include <string>
#include <vector>
#include <cstdlib>
@ -198,6 +199,9 @@ public:
HWND GetMainWindow();
void SetPadWindow(HWND h);
HWND GetPadWindow();
/*!
handles to the dialogs which are placed on the tab control
*/
@ -339,6 +343,19 @@ public:
void SetDegRadGrad(int angle);
int GetDegRadGrad();
/*!
is the pad window is visible then the method hides it (and vice versa)
*/
void TurnPad();
/*!
returning true if the pad window is visible
*/
bool IsPadVisible();
private:
bool IsWhiteCharacter(int c);
@ -363,6 +380,7 @@ private:
HINSTANCE hInstance;
HWND main_window;
HWND pad_window;
HWND tab_window[6];
int precision;
@ -393,7 +411,7 @@ private:
int angle_deg_rad_grad;
int bad_line;
bool show_pad;
};

View File

@ -187,11 +187,12 @@
#define IDM_VIEW_INDEX 0
#define IDM_EDIT_INDEX 1
#define IDM_HELP_INDEX 2
#define IDM_LANGUAGE_INDEX 6
#define IDM_LANGUAGE_INDEX 8
#define IDM_NEW_WINDOW 40001
#define IDM_NORMAL_VIEW 40002
#define IDM_COMPACT_VIEW 40003
#define IDM_ALWAYS_ON_TOP 40004
#define IDM_PAD 40005
#define IDM_LANGUAGE_ENGLISH 40010
#define IDM_LANGUAGE_POLISH 40011
#define IDM_LANGUAGE_SPANISH 40012

View File

@ -23,6 +23,8 @@ BEGIN
MENUITEM "No&rmal", 40002
MENUITEM "&Compact", 40003
MENUITEM SEPARATOR
MENUITEM "&Pad", 40005
MENUITEM SEPARATOR
MENUITEM "&Always on top", 40004
POPUP "&Language"
BEGIN

View File

@ -43,6 +43,7 @@
\brief it tells us whether there was a stop signal or not
*/
#include "compileconfig.h"
#include <ttmath/ttmathtypes.h>
#include <windows.h>

View File

@ -919,7 +919,7 @@ return true;
void CreateTabCommandMessagesTable(Messages & cmessages)
void CreateTabCommandMessagesTable(Messages<BOOL> & cmessages)
{
cmessages.Associate(IDC_BUTTON_PRESS_0, WmTabCommand_Press_0_9);
cmessages.Associate(IDC_BUTTON_PRESS_1, WmTabCommand_Press_0_9);
@ -1006,7 +1006,7 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
*/
BOOL WmTabCommand(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static Messages command_messages;
static Messages<BOOL> command_messages;
if( command_messages.Empty() )
// initiation
@ -1388,7 +1388,7 @@ return false;
void CreateTabMessagesTable(Messages & messages)
void CreateTabMessagesTable(Messages<BOOL> & messages)
{
messages.Associate(WM_INITDIALOG, WmTabInitDialog);
messages.Associate(WM_COMMAND, WmTabCommand);
@ -1412,7 +1412,7 @@ void CreateTabMessagesTable(Messages & messages)
BOOL CALLBACK TabWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static Messages messages;
static Messages<BOOL> messages;
if( messages.Empty() )
// initiation

View File

@ -82,6 +82,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
if( !GetPrgRes()->GetMainWindow() )
return ShowError( Languages::cant_create_main_window );
if( !CreatePadWindow() )
return ShowError( Languages::cant_create_pad );
// there's the main loop of messages here
MainMessagesLoop();
@ -185,7 +188,7 @@ MSG msg;
*/
BOOL CALLBACK MainWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static Messages messages;
static Messages<BOOL> messages;
if( messages.Empty() )
// initiation

View File

@ -47,6 +47,7 @@
#include "resource.h"
#include "messages.h"
#include "tabs.h"
#include "pad.h"
#include <windows.h>
#include <commctrl.h>
@ -66,7 +67,7 @@ namespace MainWindowFunctions
bool SetNextFocus(WPARAM wParam);
bool CopyResult();
bool Paste();
void CreateMainMessagesTable(Messages & messages);
void CreateMainMessagesTable(Messages<BOOL> & messages);
BOOL CALLBACK AboutProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
}