#ifndef APPLICATIONINTERFACE_H #define APPLICATIONINTERFACE_H #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // This file contains a wrapper for the windows CE functions that are needed for the gui #define WIN32_LEAN_AND_MEAN #include #include "utils.h" #include "WCString.h" #define setMenuSelected(hWndMB, idButton, checked) SendMessage((hWndMB), TB_CHECKBUTTON,\ (WPARAM)idButton, (LPARAM)MAKELONG(checked,0)); #define getMenu(hWndMB) (HMENU)SendMessage((hWndMB), SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0); #define getSubMenu(hWndMB,ID_MENU) (HMENU)SendMessage((hWndMB), SHCMBM_GETSUBMENU, (WPARAM)0, (LPARAM)ID_MENU); #define setSubMenu(hWndMB,ID_MENU) (HMENU)SendMessage((hWndMB), SHCMBM_SETSUBMENU, (WPARAM)0, (LPARAM)ID_MENU); extern HDC hdc; // Only valid when painting extern HBRUSH background; extern DWORD g_tMain; extern HINSTANCE g_hInst; // The current instance extern HWND g_hWnd; // The main window extern HWND g_hwndCB; #define WM_TXT_START WM_USER + 0x00F1 #define WM_TXT_END WM_USER + 0x00F2 #define MENU_HEIGHT 26 #define MAX_LOADSTRING 100 #define FONT_DEFAULT 0 #define FONT_NAVIGATION 1 #define FONT_TEXT 2 #define NOCOLOR 0xFFFFFFFF #define BUTTON_WIDTH_BK 26 #define BUTTON_WIDTH_NM 20 #define BUTTON_HEIGHT 17 #define PADDING_WIDTH 3 #define PADDING_HEIGHT 3 void initApplicationInterface(); void closeApplicationInterface(); // load string from string table void loadString(UINT id, LPTSTR buffer); WCString loadString(UINT id); // sets the main title void setTitle(const WCString &title); // Refreshes the whole application screen void refreshScreen(); // Draws the text inside the rectangle inline void drawText(RECT* rt, const TCHAR* text, int length) { ExtTextOut(hdc, rt->left+2, rt->top+2, ETO_CLIPPED|ETO_OPAQUE, rt, text, length, 0); } void drawText(RECT* rt,const WCString &text); // Draws the text right-aligned inside the rectangle inline void drawRText(RECT* rt, const TCHAR* text, int length) { SIZE textSize; GetTextExtentPoint(hdc,text,length,&textSize); ExtTextOut(hdc, rt->right-2-textSize.cx, rt->top+2, ETO_CLIPPED|ETO_OPAQUE, rt, text, length, 0); } void drawRText(RECT* rt,const WCString &text); int drawVerseText(RECT* rt,const WCString &text); // fill the rectangle with the original background color inline void clearRect(RECT* rt) { FillRect(hdc, rt, background); } // set the font void setFont(int id=FONT_DEFAULT); // set the background color inline void setBackground(COLORREF color=NOCOLOR) { if (color==NOCOLOR) SetBkColor(hdc,(COLORREF)GetSysColor(COLOR_WINDOW)); else SetBkColor(hdc,color); } void selectMenu(std::map& menus, int mode); //void selectMenu(int mode); void addMenu(HMENU menu, int flags, int id,const WCString& text); void checkMenu(HMENU menu, int id, bool checked); // Get an id to give to the CreateWindow as hMenu HMENU registerID(int id); WCString getText(HWND edit); #endif