00001
00002
00003
00004 #include "stdafx.h"
00005 #include "MapEditor.h"
00006 #include "BarDialog.h"
00007
00008 #include "MapEditorChildFrm.h"
00009 #include "MapEditorDoc.h"
00010 #include "LandscapeView.h"
00011
00012
00013
00014
00015 IMPLEMENT_DYNAMIC(CBarDialog, CDialogBar)
00016 CBarDialog::CBarDialog()
00017 : CDialogBar()
00018 {
00019 }
00020
00021 CBarDialog::~CBarDialog()
00022 {
00023 }
00024
00025 void CBarDialog::DoDataExchange(CDataExchange* pDX)
00026 {
00027 CDialogBar::DoDataExchange(pDX);
00028 }
00029
00030
00031 BEGIN_MESSAGE_MAP(CBarDialog, CDialogBar)
00032 ON_WM_HSCROLL()
00033 ON_WM_CREATE()
00034 ON_WM_SIZE()
00035 END_MESSAGE_MAP()
00036
00037
00038
00039
00040 void CBarDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
00041 {
00042
00043 {
00044 SetSunTime();
00045 }
00046
00047 CDialogBar::OnHScroll(nSBCode, nPos, pScrollBar);
00048 }
00049
00050 void CBarDialog::SetSunTime()
00051 {
00052 float Time = (float)m_SliderTime.GetPos() / (float)m_SliderTime.GetRangeMax();
00053 ((CMEChildFrame*)GetParent())->m_pDocument->m_pLandscapeView->SetSunTime( Time );
00054
00055 char pText[256];
00056 int Minutes = (int)(Time * 1440.0f);
00057
00058 Minutes += 360;
00059 Minutes %= 1440;
00060
00061 sprintf( pText, "%.2i:%.2i", Minutes / 60, Minutes % 60 );
00062 SetDlgItemText( IDC_STATIC_TIME, pText );
00063 }
00064
00065 int CBarDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
00066 {
00067 if (CDialogBar::OnCreate(lpCreateStruct) == -1)
00068 return -1;
00069
00070 RECT Rect;
00071
00072 GetClientRect( &Rect );
00073 m_SliderTime.Create( WS_CHILD | WS_VISIBLE, Rect, this, -1 );
00074 m_SliderTime.SetRange( 0, 100 );
00075 m_SliderTime.SetPos( 10 );
00076
00077 SetSunTime();
00078
00079
00080 return 0;
00081 }
00082
00083 void CBarDialog::OnSize(UINT nType, int cx, int cy)
00084 {
00085 CDialogBar::OnSize(nType, cx, cy);
00086
00087 CRect Rect, StaticRect, NewRect;
00088
00089 GetClientRect( &Rect );
00090
00091 CWnd* pWnd = GetDlgItem( IDC_STATIC_TIME );
00092 if( pWnd )
00093 {
00094 pWnd->GetClientRect( &StaticRect );
00095 pWnd->MoveWindow( &CRect( Rect.right - StaticRect.right - 4, 4, Rect.right - 4, Rect.bottom - 4 ) );
00096 }
00097
00098 Rect.DeflateRect( 4, 4, 70, 4 );
00099 m_SliderTime.MoveWindow( &Rect );
00100
00101 SetSunTime();
00102 }