#include "ApplicationInterface.h" #include #include #include #include "resource.h" HINSTANCE g_hInst; // The current instance HWND g_hWnd; // The main window DWORD g_tMain; // The main thread id. HWND g_hwndCB; // The command bar handle HDC hdc; // Only valid when painting HBRUSH background; HFONT navFont; // For navigation HFONT textFont; // For navigation int font; // Current font id HFONT defaultFont; void initApplicationInterface() { font=FONT_DEFAULT; LOGFONT fontSpecs; memset(&fontSpecs,0,sizeof(fontSpecs)); fontSpecs.lfHeight=-10; fontSpecs.lfWeight=200; fontSpecs.lfPitchAndFamily=FF_SWISS; fontSpecs.lfQuality=5; navFont=CreateFontIndirect(&fontSpecs); fontSpecs.lfHeight=-12; textFont=CreateFontIndirect(&fontSpecs); background=(HBRUSH) GetStockObject(WHITE_BRUSH); } void closeApplicationInterface() { DeleteObject(textFont); DeleteObject(navFont); } void loadString(UINT id, LPTSTR buffer) { LoadString(g_hInst, id, buffer, MAX_LOADSTRING); } WCString loadString(UINT id) { TCHAR chars[MAX_LOADSTRING]; loadString(id,chars); return WCString(chars); } void setTitle(const WCString &title) { SetWindowText(g_hWnd,title.w_str()); } void refreshScreen() { InvalidateRect(g_hWnd, NULL, TRUE); UpdateWindow(NULL); } void drawText(RECT* rt, const WCString &text) { drawText(rt,text.w_str(), text.length()); } void drawRText(RECT* rt, const WCString &text) { drawRText(rt,text.w_str(), text.length()); } #define MARGIN 2 int drawVerseText(RECT* rt, const WCString &text) { RECT tmp=*rt; tmp.left+=MARGIN; DrawText(hdc, text.w_str(),text.length(),&tmp,DT_LEFT|DT_WORDBREAK|DT_CALCRECT); tmp.left=rt->left; tmp.right=rt->right; clearRect(&tmp); tmp.left+=MARGIN; DrawText(hdc, text.w_str(),text.length(),&tmp,DT_LEFT|DT_WORDBREAK); return (tmp.bottom)-(tmp.top); } void setFont(int id) { HFONT newFont; switch (id) { case FONT_NAVIGATION: newFont=navFont; break; case FONT_TEXT: newFont=textFont; break; default: id=FONT_DEFAULT; newFont=defaultFont; } if ((font==FONT_DEFAULT)&&(id!=FONT_DEFAULT)) //let's remember the default font defaultFont=(HFONT)SelectObject(hdc,newFont); else if (font!=id) SelectObject(hdc,newFont); } void selectMenu(std::map& menus, int mode) { for (int i=0;i