GME  13
CompassOptDlg.cpp
Go to the documentation of this file.
00001 // CompassOptDlg.cpp : implementation file
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "objectinspector.h"
00006 #include "CompassOptDlg.h"
00007 #include "CompassData.h"
00008 #include "InPlaceCommon.h"
00009 
00010 #ifdef _DEBUG
00011 #define new DEBUG_NEW
00012 #undef THIS_FILE
00013 static char THIS_FILE[] = __FILE__;
00014 #endif
00015 
00017 // CCompassOptDlg dialog
00018 
00019 
00020 CCompassOptDlg::CCompassOptDlg(CWnd* pParent /*=NULL*/)
00021         : CDialog(CCompassOptDlg::IDD, pParent)
00022 {
00023         //{{AFX_DATA_INIT(CCompassOptDlg)
00024         m_nRadio = -1;
00025         //}}AFX_DATA_INIT
00026 
00027         m_bInited = true;
00028         m_bClosed = false;
00029 }
00030 
00031 
00032 void CCompassOptDlg::SetParameters(const CPoint& ptRightTop, UINT uCompassVal)
00033 {
00034         m_ptRightTop            = ptRightTop;
00035         m_uCompassVal           = uCompassVal;
00036 }
00037 
00038 
00039 UINT CCompassOptDlg::GetCompassVal(void) const
00040 {
00041         return m_uCompassVal;
00042 }
00043 
00044 
00045 void CCompassOptDlg::DoDataExchange(CDataExchange* pDX)
00046 {
00047         CDialog::DoDataExchange(pDX);
00048         //{{AFX_DATA_MAP(CCompassOptDlg)
00049         DDX_Radio(pDX, IDC_RADIO_CENTER, m_nRadio);
00050         //}}AFX_DATA_MAP
00051 }
00052 
00053 
00054 BEGIN_MESSAGE_MAP(CCompassOptDlg, CDialog)
00055         //{{AFX_MSG_MAP(CCompassOptDlg)
00056         ON_WM_NCACTIVATE()
00057         ON_BN_CLICKED(IDC_RADIO_CENTER, OnRadioCenter)
00058         ON_BN_DOUBLECLICKED(IDC_RADIO_CENTER, OnDoubleclickedRadioCenter)
00059         ON_BN_CLICKED(IDC_RADIO_EAST, OnRadioEast)
00060         ON_BN_DOUBLECLICKED(IDC_RADIO_EAST, OnDoubleclickedRadioEast)
00061         ON_BN_CLICKED(IDC_RADIO_NORTH, OnRadioNorth)
00062         ON_BN_DOUBLECLICKED(IDC_RADIO_NORTH, OnDoubleclickedRadioNorth)
00063         ON_BN_CLICKED(IDC_RADIO_NORTHEAST, OnRadioNortheast)
00064         ON_BN_DOUBLECLICKED(IDC_RADIO_NORTHEAST, OnDoubleclickedRadioNortheast)
00065         ON_BN_CLICKED(IDC_RADIO_NORTHWEST, OnRadioNorthwest)
00066         ON_BN_DOUBLECLICKED(IDC_RADIO_NORTHWEST, OnDoubleclickedRadioNorthwest)
00067         ON_BN_CLICKED(IDC_RADIO_SOUTH, OnRadioSouth)
00068         ON_BN_DOUBLECLICKED(IDC_RADIO_SOUTH, OnDoubleclickedRadioSouth)
00069         ON_BN_CLICKED(IDC_RADIO_SOUTHEAST, OnRadioSoutheast)
00070         ON_BN_DOUBLECLICKED(IDC_RADIO_SOUTHEAST, OnDoubleclickedRadioSoutheast)
00071         ON_BN_CLICKED(IDC_RADIO_SOUTHWEST, OnRadioSouthwest)
00072         ON_BN_DOUBLECLICKED(IDC_RADIO_SOUTHWEST, OnDoubleclickedRadioSouthwest)
00073         ON_BN_CLICKED(IDC_RADIO_WEST, OnRadioWest)
00074         ON_BN_DOUBLECLICKED(IDC_RADIO_WEST, OnDoubleclickedRadioWest)
00075         ON_WM_PAINT()
00076         //}}AFX_MSG_MAP
00077 END_MESSAGE_MAP()
00078 
00080 // CCompassOptDlg message handlers
00081 
00082 
00083 BOOL CCompassOptDlg::OnNcActivate(BOOL bActive) 
00084 {
00085         if(m_bInited)
00086         {
00087                 m_bInited=false;
00088         }
00089         else
00090         {       
00091                 if (!bActive && !m_bClosed) {
00092                         m_bClosed = true;
00093                         EndDialog(IDCANCEL);
00094                         DWORD pos = GetMessagePos();
00095                         CPoint msgPoint(GET_X_LPARAM(pos), GET_Y_LPARAM(pos));
00096                         RelayMouseClickToInspectorList(m_pParentWnd, msgPoint);
00097                 }
00098                 // OnOK();
00099         }
00100         return FALSE;
00101 }
00102 
00103 
00104 BOOL CCompassOptDlg::OnInitDialog() 
00105 {
00106         CDialog::OnInitDialog();
00107 
00108         ASSERT(CCompassData::bIsSingle(m_uCompassVal));
00109         
00110         CRect rectWnd;
00111         GetWindowRect(rectWnd);
00112         CPoint ptLeftTop(m_ptRightTop.x-rectWnd.Width(),m_ptRightTop.y);
00113         SetWindowPos(NULL,ptLeftTop.x,ptLeftTop.y,0,0,SWP_NOSIZE|SWP_NOZORDER);
00114 
00115 
00116 
00117         if(m_uCompassVal&CMPS_CENTER)
00118         {
00119                 m_nRadio=0;
00120         }
00121 
00122 
00123         if(m_uCompassVal&CMPS_NORTH)
00124         {
00125                 m_nRadio=1;
00126         }
00127 
00128         if(m_uCompassVal&CMPS_EAST)
00129         {
00130                 m_nRadio=3;
00131         }
00132         
00133         if(m_uCompassVal&CMPS_SOUTH)
00134         {
00135                 m_nRadio=5;
00136         }
00137 
00138         if(m_uCompassVal&CMPS_WEST)
00139         {
00140                 m_nRadio=7;
00141         }
00142 
00143         if(m_uCompassVal&CMPS_NORTHEAST)
00144         {
00145                 m_nRadio=2;
00146         }
00147 
00148         if(m_uCompassVal&CMPS_SOUTHEAST)
00149         {
00150                 m_nRadio=4;
00151         }
00152 
00153         if(m_uCompassVal&CMPS_SOUTHWEST)
00154         {
00155                 m_nRadio=6;
00156         }
00157 
00158         if(m_uCompassVal&CMPS_NORTHWEST)
00159         {
00160                 m_nRadio=8;
00161         }
00162 
00163         UpdateData(FALSE);
00164         
00165         m_bInited=true;
00166 
00167     m_background.LoadBitmap( IDB_COMPASS_OPT );
00168         
00169         return TRUE;                  
00170 }
00171 
00172 
00173 
00174 void CCompassOptDlg::OnOK()
00175 {
00176 
00177         UpdateData(TRUE);
00178 
00179         m_uCompassVal=0;
00180 
00181         switch(m_nRadio)
00182         {
00183                 case 0:
00184                 {
00185                         m_uCompassVal|=CMPS_CENTER;
00186 
00187                 }break;
00188 
00189                 case 1:
00190                 {
00191                         m_uCompassVal|=CMPS_NORTH;
00192 
00193                 }break;
00194                 
00195                 case 2:
00196                 {
00197                         m_uCompassVal|=CMPS_NORTHEAST;
00198 
00199                 }break;
00200 
00201                 case 3:
00202                 {
00203                         m_uCompassVal|=CMPS_EAST;
00204 
00205                 }break;
00206 
00207                 case 4:
00208                 {
00209                         m_uCompassVal|=CMPS_SOUTHEAST;
00210 
00211                 }break;
00212 
00213                 case 5:
00214                 {
00215                         m_uCompassVal|=CMPS_SOUTH;
00216 
00217                 }break;
00218 
00219                 case 6:
00220                 {
00221                         m_uCompassVal|=CMPS_SOUTHWEST;
00222 
00223                 }break;
00224 
00225                 case 7:
00226                 {
00227                         m_uCompassVal|=CMPS_WEST;
00228 
00229                 }break;
00230 
00231                 case 8:
00232                 {
00233                         m_uCompassVal|=CMPS_NORTHWEST;
00234 
00235                 }break;
00236 
00237                 default:
00238                 {
00239                         ASSERT(0);
00240                         return;
00241                 }
00242         }
00243         
00244         m_bClosed = true;
00245         CDialog::OnOK();
00246 }
00247 
00248 
00249 void CCompassOptDlg::OnRadioCenter() 
00250 {
00251         if(m_bInited)
00252         {
00253                 OnOK();
00254         }
00255 }
00256 
00257 void CCompassOptDlg::OnDoubleclickedRadioCenter() 
00258 {
00259         if(m_bInited)
00260         {
00261                 OnOK();
00262         }
00263 }
00264 
00265 void CCompassOptDlg::OnRadioEast() 
00266 {
00267         if(m_bInited)
00268         {
00269                 OnOK();
00270         }
00271 }
00272 
00273 void CCompassOptDlg::OnDoubleclickedRadioEast() 
00274 {
00275         if(m_bInited)
00276         {
00277                 OnOK();
00278         }       
00279 }
00280 
00281 void CCompassOptDlg::OnRadioNorth() 
00282 {
00283         if(m_bInited)
00284         {
00285                 OnOK();
00286         }       
00287 }
00288 
00289 void CCompassOptDlg::OnDoubleclickedRadioNorth() 
00290 {
00291         if(m_bInited)
00292         {
00293                 OnOK();
00294         }
00295 }
00296 
00297 void CCompassOptDlg::OnRadioNortheast() 
00298 {
00299         if(m_bInited)
00300         {
00301                 OnOK();
00302         }
00303 }
00304 
00305 void CCompassOptDlg::OnDoubleclickedRadioNortheast() 
00306 {
00307         if(m_bInited)
00308         {
00309                 OnOK();
00310         }
00311 }
00312 
00313 void CCompassOptDlg::OnRadioNorthwest() 
00314 {
00315         if(m_bInited)
00316         {
00317                 OnOK();
00318         }
00319 }
00320 
00321 void CCompassOptDlg::OnDoubleclickedRadioNorthwest() 
00322 {
00323         if(m_bInited)
00324         {
00325                 OnOK();
00326         }       
00327 }
00328 
00329 void CCompassOptDlg::OnRadioSouth() 
00330 {
00331         if(m_bInited)
00332         {
00333                 OnOK();
00334         }
00335 }
00336 
00337 void CCompassOptDlg::OnDoubleclickedRadioSouth() 
00338 {
00339         if(m_bInited)
00340         {
00341                 OnOK();
00342         }
00343 }
00344 
00345 void CCompassOptDlg::OnRadioSoutheast() 
00346 {
00347         if(m_bInited)
00348         {
00349                 OnOK();
00350         }       
00351 }
00352 
00353 void CCompassOptDlg::OnDoubleclickedRadioSoutheast() 
00354 {
00355         if(m_bInited)
00356         {
00357                 OnOK();
00358         }       
00359 }
00360 
00361 void CCompassOptDlg::OnRadioSouthwest() 
00362 {
00363         if(m_bInited)
00364         {
00365                 OnOK();
00366         }
00367 
00368         
00369 }
00370 
00371 void CCompassOptDlg::OnDoubleclickedRadioSouthwest() 
00372 {
00373         if(m_bInited)
00374         {
00375                 OnOK();
00376         }
00377 }
00378 
00379 void CCompassOptDlg::OnRadioWest() 
00380 {
00381         if(m_bInited)
00382         {
00383                 OnOK();
00384         }       
00385 }
00386 
00387 void CCompassOptDlg::OnDoubleclickedRadioWest() 
00388 {
00389         if(m_bInited)
00390         {
00391                 OnOK();
00392         }       
00393 }
00394 
00395 void CCompassOptDlg::OnPaint() 
00396 {
00397         CPaintDC dc(this);
00398 
00399     CDC         memdc;
00400     CBitmap   * oldbmp;
00401     CRect       rect;
00402 
00403     GetClientRect( &rect );
00404 
00405     memdc.CreateCompatibleDC( &dc );
00406     oldbmp = memdc.SelectObject( &m_background );
00407     dc.StretchBlt   ( 0, 0, rect.right, rect.bottom
00408                     , &memdc
00409                     , 0, 0
00410                     , 130, 130 //m_background.GetBitmapDimension().cx
00411                     //, m_background.GetBitmapDimension().cy
00412                     , SRCCOPY 
00413                     );
00414 
00415     memdc.SelectObject( oldbmp );
00416 }