Page principale   Liste des namespaces   Hiérarchie des classes   Liste par ordre alphabétique   Liste des composants   Liste des fichiers   Membres des namespaces   Composants   Déclarations  

SDKInterfaceDlg.cpp

Aller à la documentation de ce fichier.
00001 // SDKInterfaceDlg.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "SDKInterface.h"
00006 #include "SDKInterfaceDlg.h"
00007 
00008 #ifdef _DEBUG
00009 #define new DEBUG_NEW
00010 #endif
00011 
00012 
00013 // CAboutDlg dialog used for App About
00014 
00015 class CAboutDlg : public CDialog
00016 {
00017 public:
00018         CAboutDlg();
00019 
00020 // Dialog Data
00021         enum { IDD = IDD_ABOUTBOX };
00022 
00023         protected:
00024         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00025 
00026 // Implementation
00027 protected:
00028         DECLARE_MESSAGE_MAP()
00029 };
00030 
00031 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
00032 {
00033 }
00034 
00035 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
00036 {
00037         CDialog::DoDataExchange(pDX);
00038 }
00039 
00040 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
00041 END_MESSAGE_MAP()
00042 
00043 
00044 // CSDKInterfaceDlg dialog
00045 
00046 
00047 
00048 CSDKInterfaceDlg::CSDKInterfaceDlg(CWnd* pParent /*=NULL*/)
00049         : CDialog(CSDKInterfaceDlg::IDD, pParent)
00050         , m_EditImage(_T(""))
00051         , m_EditMask(_T(""))
00052 {
00053         m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
00054 }
00055 
00056 void CSDKInterfaceDlg::DoDataExchange(CDataExchange* pDX)
00057 {
00058         CDialog::DoDataExchange(pDX);
00059         DDX_Text(pDX, IDC_EDITSELECTIMAGE, m_EditImage);
00060         DDX_Text(pDX, IDC_EDITSELECTMASK, m_EditMask);
00061         DDX_Control(pDX, IDC_LISTINTERFACE, m_ControlFileContent);
00062 }
00063 
00064 BEGIN_MESSAGE_MAP(CSDKInterfaceDlg, CDialog)
00065         ON_WM_SYSCOMMAND()
00066         ON_WM_PAINT()
00067         ON_WM_QUERYDRAGICON()
00068         //}}AFX_MSG_MAP
00069         ON_WM_RBUTTONDOWN()
00070         ON_WM_RBUTTONUP()
00071         ON_WM_MOUSEWHEEL()
00072         ON_WM_MOVE()
00073         ON_WM_TIMER()
00074         ON_WM_MOUSEMOVE()
00075         ON_BN_CLICKED(IDC_BUTSELECTIMAGE, OnBnClickedButselectimage)
00076         ON_BN_CLICKED(IDC_BUTSELECTMASK, OnBnClickedButselectmask)
00077         ON_BN_CLICKED(IDC_BUTADDACTION, OnBnClickedButaddaction)
00078         ON_BN_CLICKED(IDC_BUTSAVE, OnBnClickedButsave)
00079         ON_BN_CLICKED(IDC_BUTREMOVEACTION, OnBnClickedButremoveaction)
00080         ON_BN_CLICKED(IDC_BUTRESETACTION, OnBnClickedButresetaction)
00081         ON_BN_CLICKED(IDC_BUTRESETALL, OnBnClickedButresetall)
00082         ON_LBN_SELCHANGE(IDC_LISTINTERFACE, OnLbnSelchangeListinterface)
00083 END_MESSAGE_MAP()
00084 
00085 
00086 // CSDKInterfaceDlg message handlers
00087 
00088 BOOL CSDKInterfaceDlg::OnInitDialog()
00089 {
00090         CDialog::OnInitDialog();
00091 
00092         // Add "About..." menu item to system menu.
00093 
00094         // IDM_ABOUTBOX must be in the system command range.
00095         ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
00096         ASSERT(IDM_ABOUTBOX < 0xF000);
00097 
00098         CMenu* pSysMenu = GetSystemMenu(FALSE);
00099         if (pSysMenu != NULL)
00100         {
00101                 CString strAboutMenu;
00102                 strAboutMenu.LoadString(IDS_ABOUTBOX);
00103                 if (!strAboutMenu.IsEmpty())
00104                 {
00105                         pSysMenu->AppendMenu(MF_SEPARATOR);
00106                         pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
00107                 }
00108         }
00109 
00110         // Set the icon for this dialog.  The framework does this automatically
00111         //  when the application's main window is not a dialog
00112         SetIcon(m_hIcon, TRUE);                 // Set big icon
00113         SetIcon(m_hIcon, FALSE);                // Set small icon
00114 
00115         // TODO: Add extra initialization here
00116         int iWidth,iHeight;
00117         CPaintDC dc(this); // device context for painting
00118         m_hDC = ::GetDC(this->m_hWnd);
00119 
00120         //Openlg render 
00121         
00122         pclStaticCurrent = (CStatic *)GetDlgItem(IDC_OPENGLRENDER);
00123         GlRenderCurrent = new CGlView(pclStaticCurrent);
00124         
00125         GlRenderCurrent->SetPixelformat(m_hDC);
00126         GlRenderCurrent->InitGL();
00127         RECT rect;
00128         GetClientRect(&rect);
00129         pclStaticCurrent->GetWindowRect(&rect);
00130     iWidth = -(rect.right - rect.left);
00131     iHeight = rect.top - rect.bottom;
00132         GlRenderCurrent->ReSizeGLScene(iWidth, iHeight);
00133         SetTimer(1, 100, 0);
00134 /*      m_ControlFileContent.AddString("<filetype>interface<#filetype>");
00135         m_ControlFileContent.AddString("<Image>None<#Image>");
00136         m_ControlFileContent.AddString("<Mask>None<#Mask>");*/
00137         m_ControlFileContent.EnableScrollBar(SB_BOTH,ESB_ENABLE_BOTH);
00138         m_ControlFileContent.SetScrollRange(SB_HORZ ,0,1000,true);
00139         m_ControlFileContent.SetHorizontalExtent(1000);
00140         GlRenderCurrent->m_PControlFileContent=&m_ControlFileContent;
00141         return TRUE;  // return TRUE  unless you set the focus to a control
00142 }
00143 
00144 void CSDKInterfaceDlg::OnSysCommand(UINT nID, LPARAM lParam)
00145 {
00146         if ((nID & 0xFFF0) == IDM_ABOUTBOX)
00147         {
00148                 CAboutDlg dlgAbout;
00149                 dlgAbout.DoModal();
00150         }
00151         else
00152         {
00153                 CDialog::OnSysCommand(nID, lParam);
00154         }
00155 }
00156 
00157 // If you add a minimize button to your dialog, you will need the code below
00158 //  to draw the icon.  For MFC applications using the document/view model,
00159 //  this is automatically done for you by the framework.
00160 
00161 void CSDKInterfaceDlg::OnPaint() 
00162 {
00163         if (IsIconic())
00164         {
00165                 CPaintDC dc(this); // device context for painting
00166 
00167                 SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
00168 
00169                 // Center icon in client rectangle
00170                 int cxIcon = GetSystemMetrics(SM_CXICON);
00171                 int cyIcon = GetSystemMetrics(SM_CYICON);
00172                 CRect rect;
00173                 GetClientRect(&rect);
00174                 int x = (rect.Width() - cxIcon + 1) / 2;
00175                 int y = (rect.Height() - cyIcon + 1) / 2;
00176 
00177                 // Draw the icon
00178                 dc.DrawIcon(x, y, m_hIcon);
00179         }
00180         else
00181         {
00182                 CDialog::OnPaint();
00183         }
00184         GlRenderCurrent->DrawGLScene();
00185 }
00186 
00187 // The system calls this function to obtain the cursor to display while the user drags
00188 //  the minimized window.
00189 HCURSOR CSDKInterfaceDlg::OnQueryDragIcon()
00190 {
00191         return static_cast<HCURSOR>(m_hIcon);
00192 }
00193 
00194 void CSDKInterfaceDlg::OnRButtonDown(UINT nFlags, CPoint point)
00195 {
00196         // TODO : ajoutez ici le code de votre gestionnaire de messages et/ou les paramètres par défaut des appels
00197         m_MouseDownPoint=point;
00198     SetCapture();
00199         CDialog::OnRButtonDown(nFlags, point);
00200 }
00201 
00202 void CSDKInterfaceDlg::OnRButtonUp(UINT nFlags, CPoint point)
00203 {
00204         // TODO : ajoutez ici le code de votre gestionnaire de messages et/ou les paramètres par défaut des appels
00205         m_MouseDownPoint=CPoint(0,0);
00206         ReleaseCapture();
00207         CDialog::OnRButtonUp(nFlags, point);
00208 }
00209 
00210 BOOL CSDKInterfaceDlg::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
00211 {
00212         // TODO : ajoutez ici le code de votre gestionnaire de messages et/ou les paramètres par défaut des appels
00213         RECT rect;
00214         GetClientRect(&rect);
00215         pclStaticCurrent->GetWindowRect(&rect);
00216         CRgn RegOpengl;
00217         RegOpengl.CreateRectRgnIndirect(&rect);
00218         if(RegOpengl.PtInRegion(pt))
00219         {
00220                 if(zDelta<0)
00221                 {
00222                         GlRenderCurrent->IncreaseZoom();
00223                 }else
00224                 {
00225                         GlRenderCurrent->DecreaseZoom();
00226                 }
00227                  GlRenderCurrent->DrawGLScene();
00228         }
00229         return CDialog::OnMouseWheel(nFlags, zDelta, pt);
00230 }
00231 
00232 void CSDKInterfaceDlg::OnMove(int x, int y)
00233 {
00234         CDialog::OnMove(x, y);
00235         // TODO : ajoutez ici le code de votre gestionnaire de messages
00236 }
00237 
00238 void CSDKInterfaceDlg::OnTimer(UINT nIDEvent)
00239 {
00240         // TODO : ajoutez ici le code de votre gestionnaire de messages et/ou les paramètres par défaut des appels
00241         GlRenderCurrent->DrawGLScene();
00242         CDialog::OnTimer(nIDEvent);
00243 }
00244 
00245 void CSDKInterfaceDlg::OnMouseMove(UINT nFlags, CPoint point)
00246 {
00247         // TODO : ajoutez ici le code de votre gestionnaire de messages et/ou les paramètres par défaut des appels
00248     if (GetCapture()==this)
00249         {
00250         GlRenderCurrent->m_fAngleX+=(float)(point.y-m_MouseDownPoint.y)/3.6;
00251         GlRenderCurrent->m_fAngleY+=(float)(point.x-m_MouseDownPoint.x)/3.6;
00252         InvalidateRect(NULL,FALSE);
00253         m_MouseDownPoint=point;
00254                  GlRenderCurrent->DrawGLScene();
00255         }
00256         CDialog::OnMouseMove(nFlags, point);
00257 }
00258 
00259 void CSDKInterfaceDlg::OnBnClickedButselectimage()
00260 {
00261         // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
00262         char szFilters[]="Texture Files (*.bmp)|*.bmp|All Files (*.*)|*.*||";
00263         CFileDialog     fileDlg(true,"*.bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters,this);
00264         if(fileDlg.DoModal()==IDOK)
00265         {
00266                 GlRenderCurrent->LoadImage(fileDlg.GetPathName());
00267                 m_EditImage=fileDlg.GetFileName();
00268                 m_ControlFileContent.
00269                 UpdateData(false);
00270         }
00271 }
00272 
00273 void CSDKInterfaceDlg::OnBnClickedButselectmask()
00274 {
00275         // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
00276         char szFilters[]="Texture Files (*.bmp)|*.bmp|All Files (*.*)|*.*||";
00277         CFileDialog     fileDlg(true,"*.bmp",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters,this);
00278         if(fileDlg.DoModal()==IDOK)
00279         {
00280                 GlRenderCurrent->LoadMask(fileDlg.GetPathName());
00281                 m_EditMask=fileDlg.GetFileName();
00282                 UpdateData(false);
00283         }
00284         
00285 }
00286 
00287 void CSDKInterfaceDlg::OnBnClickedButaddaction()
00288 {
00289         // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
00290         DiaAddAction.DoModal();
00291         CString ActionString;
00292         ActionString+="<Interface_Action>";
00293                 ActionString+="<Action>";
00294                         ActionString+=DiaAddAction.m_EditAction;
00295                 ActionString+="<#Action>";
00296                 ActionString+="<Command>";
00297                         ActionString+=DiaAddAction.m_EditEvent;
00298                 ActionString+="<#Command>";
00299                 ActionString+="<Param>";
00300                         ActionString+=DiaAddAction.m_Param;
00301                 ActionString+="<#Param>";
00302                 ActionString+="<TopX>";
00303                         ActionString+=DiaAddAction.m_TopX;
00304                 ActionString+="<#TopX>";
00305                 ActionString+="<TopY>";
00306                         ActionString+=DiaAddAction.m_TopY;
00307                 ActionString+="<#TopY>";
00308                 ActionString+="<BottomX>";
00309                         ActionString+=DiaAddAction.m_BottomX;
00310                 ActionString+="<#BottomX>";
00311                 ActionString+="<BottomY>";
00312                         ActionString+=DiaAddAction.m_BottomY;
00313                 ActionString+="<#BottomY>";
00314         ActionString+="<#Interface_Action>";
00315         m_ControlFileContent.AddString(ActionString);
00316 }
00317 
00318 void CSDKInterfaceDlg::OnBnClickedButsave()
00319 {
00320         // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
00321         char szFilters[]="Texture Files (*.int)|*.int|All Files (*.*)|*.*||";
00322         CFileDialog     fileDlg(false,"*.int",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilters,this);
00323         if(fileDlg.DoModal()==IDOK)
00324         {
00325                 std::ofstream fout;
00326                 CString Buffer;
00327                 fout.open(fileDlg.GetPathName(),std::ios::out);
00328                 //1 write image and mask
00329                 fout<<"<filetype>interface<#filetype>"<<std::endl;
00330                 fout<<"<Image>"<<m_EditImage.GetString()<<"<#Image>"<<std::endl;
00331                 fout<<"<Mask>"<<m_EditMask.GetString()<<"<#Mask>"<<std::endl;
00332                 //2 write all action
00333                 for(int i=0;i<m_ControlFileContent.GetCount();i++)
00334                 {
00335                         m_ControlFileContent.GetText(i,Buffer);
00336                         fout<<Buffer.GetString()<<std::endl;
00337                 }
00338                 fout.close();
00339         }
00340 
00341 }
00342 
00343 void CSDKInterfaceDlg::OnBnClickedButremoveaction()
00344 {
00345         // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
00346 }
00347 
00348 void CSDKInterfaceDlg::OnBnClickedButresetaction()
00349 {
00350         // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
00351 }
00352 
00353 void CSDKInterfaceDlg::OnBnClickedButresetall()
00354 {
00355         // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
00356 }
00357 
00358 void CSDKInterfaceDlg::OnLbnSelchangeListinterface()
00359 {
00360         // TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
00361         CString Buffer;
00362         if(m_ControlFileContent.GetCount()>0)
00363         {
00364                 m_ControlFileContent.GetText(m_ControlFileContent.GetCurSel(),Buffer);
00365         
00366         //AfxMessageBox(Buffer);
00367         GlRenderCurrent->topx=ExNihilo::ExtractFloatValueFromSring(Buffer.GetBuffer(),"<TopX>","<#TopX>");
00368         GlRenderCurrent->topy=ExNihilo::ExtractFloatValueFromSring(Buffer.GetBuffer(),"<TopY>","<#TopY>");;
00369         GlRenderCurrent->bottomx=ExNihilo::ExtractFloatValueFromSring(Buffer.GetBuffer(),"<BottomX>","<#BottomX>");;
00370         GlRenderCurrent->bottomy=ExNihilo::ExtractFloatValueFromSring(Buffer.GetBuffer(),"<BottomY>","<#BottomY>");;
00371         }
00372 }

Généré le Tue Dec 10 18:18:13 2002 pour ExNihilo par doxygen1.3-rc1