|
// DlgHelp.cpp : implementation file
//
#include "stdafx.h"
#include <fstream>
#include <string>
#include "CardGame.h"
#include "DlgHelp.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// DlgHelp dialog
static LPPICTURE gpMe = NULL;
static LPPICTURE gpPiazza = NULL;
static LPPICTURE gpSan = NULL;
static LPPICTURE gpPopolo = NULL;
// This method initialize the strings to show help rules and info
// english or italian, construct is a bool to check if the method is
// called by constructor, and we do not need to invalidate the rect or by change to language
void DlgHelp::init(bool construct)
{
// File names of the Info and for the Rules
const char* pFileNameEng[2] =
{".\\napoletane\\rulesEng.txt",
".\\napoletane\\infoEng.txt"};
const char* pFileNameIta[2] =
{".\\napoletane\\rulesIta.txt",
".\\napoletane\\infoIta.txt"};
mMsgRules = "";
mMsgInfo = "";
for (int i = 0; i <= 1; i++)
{
std::ifstream in((mLanguage == LANENGLISH) ? pFileNameEng[i] : pFileNameIta[i]);
if(!in)
{
if (0 == i)
mMsgRules = "Could not open file .\\Napoletane\\RulesEng (Ita).txt";
else
mMsgInfo = "Could not open file .\\Napoletane\\InfoEng (Ita).txt";
}
else
{
// Loading the strings by the files
std::string line;
while(std::getline(in, line))
if (0 == i)
mMsgRules += line + "\r\n";
else
mMsgInfo += line + "\r\n";
in.close();
}
}
if (!construct)
{
CRect rect;
GetClientRect(&rect);
InvalidateRect(&rect, TRUE);
}
}
DlgHelp::DlgHelp(CWnd* pParent /*=NULL*/)
: CDialog(DlgHelp::IDD, pParent), mLanguage(LANENGLISH)
{
//{{AFX_DATA_INIT(DlgHelp)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Loading picture in the help Dialog
myUtilities::LoadPictureFile(".\\napoletane\\me.jpg", gpMe);
myUtilities::LoadPictureFile(".\\napoletane\\piazza.jpg", gpPiazza);
myUtilities::LoadPictureFile(".\\napoletane\\san.jpg", gpSan);
myUtilities::LoadPictureFile(".\\napoletane\\Popolo.jpg", gpPopolo);
init(true);
}
void DlgHelp::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DlgHelp)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DlgHelp, CDialog)
//{{AFX_MSG_MAP(DlgHelp)
ON_WM_INITMENUPOPUP()
ON_WM_PAINT()
ON_WM_CANCELMODE()
ON_COMMAND(IDM_LANGUAGE_ENGLISH, OnLanguageEnglish)
ON_COMMAND(IDM_LANGUAGE_ITALIAN, OnLanguageItalian)
ON_UPDATE_COMMAND_UI(IDM_LANGUAGE_ITALIAN, OnUpdateLanguageItalian)
ON_UPDATE_COMMAND_UI(IDM_LANGUAGE_ENGLISH, OnUpdateLanguageEnglish)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DlgHelp message handlers
// This method is important to solve the check "V" symbol problem in the menu
// attached to a dialog box
void DlgHelp::OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu)
{
ASSERT(pPopupMenu != NULL);
// Check the enabled state of various menu items.
CCmdUI state;
state.m_pMenu = pPopupMenu;
ASSERT(state.m_pOther == NULL);
ASSERT(state.m_pParentMenu == NULL);
// Determine if menu is popup in top-level menu and set m_pOther to
// it if so (m_pParentMenu == NULL indicates that it is secondary popup).
HMENU hParentMenu;
if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu)
state.m_pParentMenu = pPopupMenu; // Parent == child for tracking popup.
else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
{
CWnd* pParent = this;
// Child windows don't have menus--need to go to the top!
if (pParent != NULL &&
(hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
{
int nIndexMax = ::GetMenuItemCount(hParentMenu);
for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
{
if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu)
{
// When popup is found, m_pParentMenu is containing menu.
state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
break;
}
}
}
}
state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
state.m_nIndex++)
{
state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
if (state.m_nID == 0)
continue; // Menu separator or invalid cmd - ignore it.
ASSERT(state.m_pOther == NULL);
ASSERT(state.m_pMenu != NULL);
if (state.m_nID == (UINT)-1)
{
// Possibly a popup menu, route to first item of that popup.
state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
if (state.m_pSubMenu == NULL ||
(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
state.m_nID == (UINT)-1)
{
continue; // First item of popup can't be routed to.
}
state.DoUpdate(this, TRUE); // Popups are never auto disabled.
}
else
{
// Normal menu item.
// Auto enable/disable if frame window has m_bAutoMenuEnable
// set and command is _not_ a system command.
state.m_pSubMenu = NULL;
state.DoUpdate(this, FALSE);
}
// Adjust for menu deletions and additions.
UINT nCount = pPopupMenu->GetMenuItemCount();
if (nCount < state.m_nIndexMax)
{
state.m_nIndex -= (state.m_nIndexMax - nCount);
while (state.m_nIndex < nCount &&
pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
{
state.m_nIndex++;
}
}
state.m_nIndexMax = nCount;
}
}
void DlgHelp::OnPaint()
{
CPaintDC dc(this); // device context for painting
SetDlgItemText(IDC_EDITHELP, mMsgRules.c_str());
SetDlgItemText(IDC_EDITCV, mMsgInfo.c_str());
myUtilities::RenderPic(this, dc.m_hDC, gpMe, 30, 10);
myUtilities::RenderPic(this, dc.m_hDC, gpPiazza, 550, 10);
myUtilities::RenderPic(this, dc.m_hDC, gpPopolo, 550, 150);
myUtilities::RenderPic(this, dc.m_hDC, gpSan, 550, 300);
// SetCheck(mLanguage == LANENGLISH ? 0 : 1);
}
void DlgHelp::OnCancelMode()
{
CDialog::OnCancelMode();
}
void DlgHelp::OnLanguageEnglish()
{
mLanguage = LANENGLISH;
init(false);
}
void DlgHelp::OnLanguageItalian()
{
mLanguage = LANITALIAN;
init(false);
}
void DlgHelp::OnUpdateLanguageItalian(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(mLanguage == LANITALIAN ? 1 : 0);
}
void DlgHelp::OnUpdateLanguageEnglish(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(mLanguage == LANENGLISH ? 1 : 0);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am born in 1965 in Ascoli Piceno (Italy).
My email is maurus@rocketmail.com
HIGHER EDUCATION:
Degree in Computer Science with a mark of 95/110,
University of Pisa in July 1992.
KNOWLEDGE OF FOREIGN LANGUAGES:
Mother tongue Italian.
Very good knowledge of both English and French.
COMPUTER KNOWLEDGE:
Operating systems:
Windows, Windows CE.
real time systems on micro.
Programming languages:
C, C++, VisualC++, Pascal, Basic, Coral, Assembly, Win32.
Libraries:
Qt, STL, Roguewave, OpenGL, MFC.
Tools
Cycle V, Design Patterns
Frameworks:
Visual Studio, DevC++, Qt Creator, Codewarrior
Micro: Mitsubishi, Texas DSP, Intel.
WORKING EXPERIENCES:
From april 1994 to march 2000 I worked in Gem Elettronica (http://www.gemrad.com) in San Benedetto del Tronto (Italy), a company that produce real time systems, naval radars, geographical position system (G.P.S.), cartographical consoles in civil and military environment (Custom Officers, Italian Militar Navy, Carabinieri).
I developed software in C/C++ inside a team work environment for international naval radar sites. I cooperated with other programmers of the Lockheed Martin Company, the Rohde & Schwarze and the Alenia Marconi Systems.
I mainly worked with real time systems, localisation radio and GPS systems.
From march 2000 to july 2001 I worked in Ericsson Cables (http://www.ericsson.com/networktechnologies) in Sundbyberg (Sweden).
I developed software for fusion splicers in a Windows CE environment in C++, Win32, MFC.
Video analyses, micro motor motion and micro cameras.
From August 2001 to February 2003
I worked in France, Paris developing in C++ under Windows, for a French company that produced software to share informations.
From March 2003
I am actually working in my first company Gem Elettronica.
I also develop Vessel Traffic Systems and Laser Gyrosteps interfaces.
My current job is to manage projects with naval and river radars.
We used Qt, Win32, MFC, C++, STL, DLL, OpenGL