Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

MainFrm.cpp

Go to the documentation of this file.
00001 // MainFrm.cpp : implementation of the CMainFrame class
00002 //
00003 
00004 #include "stdafx.h"
00005 #include "3dvis.h"
00006 
00007 #include "MainFrm.h"
00008 
00009 
00010 #include <string>
00011 using std::string;
00012 
00013 
00014 #ifdef _DEBUG
00015 #define new DEBUG_NEW
00016 #undef THIS_FILE
00017 static char THIS_FILE[] = __FILE__;
00018 #endif
00019 
00020 
00022 // CMainFrame
00023 
00024 IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
00025 
00026 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
00027         //{{AFX_MSG_MAP(CMainFrame)
00028         ON_WM_CREATE()
00029         //}}AFX_MSG_MAP
00030         ON_MESSAGE(MYWM_PROGRESS,OnProgress)
00031         ON_MESSAGE(MYWM_PROGRESS_MIN_MAX, OnProgressMinMax)
00032         ON_MESSAGE(MYWM_CHANGE_RENDERING, OnChangeRendering)
00033         ON_MESSAGE(MYWM_HIDE_BARS, OnHideBars)
00034         ON_MESSAGE(MYWM_SHOW_BAR, OnShowBar)
00035 END_MESSAGE_MAP()
00036 
00037 static UINT indicators[] =
00038 {
00039         ID_SEPARATOR,           // status line indicator
00040         ID_INDICATOR_CAPS,
00041         ID_INDICATOR_NUM,
00042         ID_INDICATOR_SCRL,
00043 };
00044 
00045 
00047 // CMainFrame construction/destruction
00048 
00049 CMainFrame::CMainFrame()
00050 {
00051         // TODO: add member initialization code here
00052         
00053 }
00054 
00055 CMainFrame::~CMainFrame()
00056 {
00057 }
00058 
00059 
00060 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
00061 {
00062         if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
00063                 return -1;
00064         
00065         if (!m_wndToolBar.CreateEx(this) ||
00066                 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
00067         {
00068                 TRACE0("Failed to create toolbar\n");
00069                 return -1;      // fail to create
00070         }
00071 
00072 
00073         if (!m_wndDlgBar.Create(this, IDR_MAINFRAME, 
00074                 CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
00075         {
00076                 TRACE0("Failed to create dialogbar\n");
00077                 return -1;              // fail to create
00078         }
00079 
00080         if (!m_wndVolumeBar.Create(this, IDR_VOLUMEFRAME,
00081                 CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR)) {
00082                 TRACE0("Failed to create volumebar\n");
00083                 return -1;
00084         }
00085 
00086 
00087         if (!m_wndReBar.Create(this) ||
00088                 !m_wndReBar.AddBar(&m_wndToolBar, NULL, NULL, RBBS_BREAK | RBBS_GRIPPERALWAYS) ||
00089                 !m_wndReBar.AddBar(&m_wndDlgBar, NULL, NULL, RBBS_NOGRIPPER) ||
00090                 !m_wndReBar.AddBar(&m_wndVolumeBar, NULL, NULL, RBBS_NOGRIPPER))
00091         {
00092                 TRACE0("Failed to create rebar\n");
00093                 return -1;      // fail to create
00094         }
00095 
00096 
00097         if (!m_wndStatusBar.Create(this) ||
00098                 !m_wndStatusBar.SetIndicators(indicators,
00099                   sizeof(indicators)/sizeof(UINT)))
00100         {
00101                 TRACE0("Failed to create status bar\n");
00102                 return -1;      // fail to create
00103         }
00104 
00105 
00106         m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
00107                 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
00108 
00109         
00110 
00111         if (!m_wndVolumeDlg.Create(IDD_VOLUME_DIALOG, this)) {
00112                 TRACE0("Failed to create VolumeDialog!");
00113                 return -1;
00114         }
00115 
00116         m_wndDlgBar.ShowWindow(SW_HIDE);
00117         m_wndVolumeBar.ShowWindow(SW_HIDE);
00118 
00119 
00120         CMenu *optionsMenu = GetMenu()->GetSubMenu(1);
00121         optionsMenu->AppendMenu(MF_SEPARATOR);
00122 
00123         string name = "preset_";
00124         
00125 
00126         for (int i = 0; i < ((CMy3dvisApp *)AfxGetApp())->m_dNumPresets; i++) {
00127                 name[6] = i + '0';
00128                 optionsMenu->AppendMenu(MF_STRING, ID_PRESET_0 + i, name.c_str());
00129         }
00130 
00131         return 0;
00132 }
00133 
00134 
00135 
00136 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
00137 {
00138         if( !CFrameWnd::PreCreateWindow(cs) )
00139                 return FALSE;
00140         // TODO: Modify the Window class or styles here by modifying
00141         //  the CREATESTRUCT cs
00142 
00143         return TRUE;
00144 }
00145 
00146 
00147 
00148 
00149 LRESULT CMainFrame::OnHideBars(WPARAM wp, LPARAM lp) {
00150         m_wndDlgBar.ShowWindow(SW_HIDE);
00151         m_wndVolumeBar.ShowWindow(SW_HIDE);
00152         
00153         RecalcLayout();
00154         DrawMenuBar();
00155         return 0;
00156 }
00157 
00158 
00159 LRESULT CMainFrame::OnShowBar(WPARAM wp, LPARAM lp) {
00160         if (wp == 0)
00161                 m_wndDlgBar.ShowWindow(SW_NORMAL);
00162         else if (wp == 1)
00163                 m_wndVolumeBar.ShowWindow(SW_NORMAL);
00164 
00165         RecalcLayout();
00166         DrawMenuBar();
00167         return 0;
00168 }
00169 
00170 
00171 LRESULT CMainFrame::OnProgress(WPARAM wp, LPARAM lp) {
00172         m_wndStatusBar.OnProgress(wp); // pass to prog/status bar
00173         return 0;
00174 }
00175 
00176 
00177 LRESULT CMainFrame::OnProgressMinMax(WPARAM wp, LPARAM lp) {
00178         m_wndStatusBar.OnProgressMinMax(wp, lp);
00179         return 0;
00180 }
00181 
00182 
00183 LRESULT CMainFrame::OnChangeRendering(WPARAM wp, LPARAM lp) {
00184         //hide the toolbox
00185         if (wp == 0) {
00186                 m_wndVolumeBar.ShowWindow(SW_HIDE);
00187                 m_wndDlgBar.ShowWindow(SW_NORMAL);
00188                 
00189                 
00190                 GetMenu()->EnableMenuItem(ID_MENU_VOLUME, MF_GRAYED);
00191 
00192                 m_wndVolumeDlg.ShowWindow(SW_HIDE);
00193         }
00194         //show the toolbox
00195         else if (wp == 1) {
00196                 m_wndDlgBar.ShowWindow(SW_HIDE);
00197                 m_wndVolumeBar.ShowWindow(SW_NORMAL);
00198                 
00199                 
00200                 GetMenu()->EnableMenuItem(ID_MENU_VOLUME, MF_ENABLED);
00201 
00202 
00203                 if (!m_wndVolumeDlg.IsWindowVisible()) {
00204                         if (lp == 1)
00205                                 m_wndVolumeDlg.ShowWindow(SW_NORMAL);
00206                 }
00207                 else
00208                         m_wndVolumeDlg.ShowWindow(SW_HIDE);
00209         }
00210 
00211         RecalcLayout();
00212         DrawMenuBar();
00213         return 0;
00214 }
00215 
00216 
00218 // CMainFrame diagnostics
00219 
00220 #ifdef _DEBUG
00221 void CMainFrame::AssertValid() const
00222 {
00223         CFrameWnd::AssertValid();
00224 }
00225 
00226 void CMainFrame::Dump(CDumpContext& dc) const
00227 {
00228         CFrameWnd::Dump(dc);
00229 }
00230 
00231 #endif //_DEBUG

Generated on Thu Jan 30 21:35:43 2003 for 3DVis by doxygen1.3-rc2