Scope
MainDlgFrame.h
1 #pragma once
2 
3 #include "controllers/ScopeLogger.h"
4 #include "MainDlgView.h"
5 #include "ThirdParty/ToolbarHelper.h"
6 #include "resource.h"
7 
8 // Forward declaration
9 namespace scope {
10  class ScopeController;
11 }
12 
13 namespace scope {
14  namespace gui {
15 
17 typedef CWinTraits<WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE> CMainDlgFrameTraits;
18 
21  public CAeroImpl<CMainDlgFrame>,
22  public CFrameWindowImpl<CMainDlgFrame, CWindow, CMainDlgFrameTraits>,
23  public CUpdateUI<CMainDlgFrame>,
24  public CToolBarHelper<CMainDlgFrame>,
25  public CIdleHandler,
26  public CMessageFilter {
27 
28 protected:
30  typedef CFrameWindowImpl<CMainDlgFrame, CWindow, CMainDlgFrameTraits> CMainDlgFrameType;
31 
33  bool firstpaint;
34 
36  CMultiPaneStatusBarCtrl m_wndStatusBar;
37 
40 
43 
46 
48  static std::array<UINT, 4> viewareas_ids;
49 
51  static std::array<UINT, 4> histogramareas_ids;
52 
53 protected:
55  void NewChannelFrame(const uint32_t& _area, const RECT& _rect);
56 
58  void NewHistogramFrame(const uint32_t& _area, const RECT& _rect);
59 
61  void NewLogFrame(const RECT& _rect);
62 
64  void RecreateWindows();
65 
66 public:
68  CCommandBarCtrl m_CmdBar;
69 
71  : firstpaint(true) {
72  }
73 
75  virtual void PrepareToolBarMenu(UINT nMenuID, HMENU hMenu);
76 
77  DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)
78 
79  BEGIN_UPDATE_UI_MAP(CMainDlgFrame)
80  UPDATE_ELEMENT(ID_TOOLS_SHUTTEROPEN, UPDUI_MENUPOPUP)
81  UPDATE_ELEMENT(0, UPDUI_STATUSBAR) // status
82  UPDATE_ELEMENT(1, UPDUI_STATUSBAR) // memory
83  UPDATE_ELEMENT(2, UPDUI_STATUSBAR) // config
84  END_UPDATE_UI_MAP()
85 
86  BEGIN_MSG_MAP(CMainDlgFrame)
87  MSG_WM_FORWARDMSG(OnForwardMsg)
88  MSG_WM_CREATE(OnCreate)
89  MSG_WM_PAINT(OnPaint)
90  MSG_WM_TIMER(OnTimer)
91  MSG_WM_DESTROY(OnDestroy)
92  COMMAND_ID_HANDLER(ID_APP_EXIT, OnFileExit)
93  COMMAND_ID_HANDLER(IDC_NEWCHANNELDROPDOWN, OnNewChannelFrame)
94  COMMAND_ID_HANDLER(ID_NEWVIEW_AREA1, OnNewChannelFrame)
95  COMMAND_ID_HANDLER(ID_NEWVIEW_AREA2, OnNewChannelFrame)
96  COMMAND_ID_HANDLER(ID_NEWVIEW_AREA3, OnNewChannelFrame)
97  COMMAND_ID_HANDLER(ID_NEWVIEW_AREA4, OnNewChannelFrame)
98  COMMAND_ID_HANDLER(IDC_NEWHISTOGRAMDROPDOWN, OnNewHistogramFrame)
99  COMMAND_ID_HANDLER(ID_NEWHISTOGRAM_AREA1, OnNewHistogramFrame)
100  COMMAND_ID_HANDLER(ID_NEWHISTOGRAM_AREA2, OnNewHistogramFrame)
101  COMMAND_ID_HANDLER(ID_NEWHISTOGRAM_AREA3, OnNewHistogramFrame)
102  COMMAND_ID_HANDLER(ID_NEWHISTOGRAM_AREA4, OnNewHistogramFrame)
103  COMMAND_ID_HANDLER(ID_OPEN_LOGBOOK, OnOpenLogbook)
104  COMMAND_ID_HANDLER(ID_FILE_LOADPARAMETERS, OnLoadParameters)
105  COMMAND_ID_HANDLER(ID_FILE_SAVEPARAMETERS, OnSaveParameters)
106  COMMAND_ID_HANDLER(ID_FILE_SAVEDEFAULTPARAMETERS, OnSaveDefaultParameters)
107  COMMAND_ID_HANDLER(ID_TOOLS_ZEROGALVOOUTPUTS, OnZeroGalvoOutputs)
108  COMMAND_ID_HANDLER(ID_TOOLS_SHUTTEROPEN, OnShutterOpen)
109  COMMAND_ID_HANDLER(ID_TOOLS_SAVEWINDOWPOSITIONS, OnSaveWindowPositions)
110  COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
111  CHAIN_MSG_MAP(CToolBarHelper<CMainDlgFrame>)
112  CHAIN_MSG_MAP(CUpdateUI<CMainDlgFrame>)
113  CHAIN_MSG_MAP(CMainDlgFrameType)
114  CHAIN_CLIENT_COMMANDS()
115  END_MSG_MAP()
116 
118  void OnToolBarCombo(HWND hWndCombo, UINT nID, int nSel, LPCTSTR lpszText, DWORD_PTR dwItemData) {}
119 
123  virtual BOOL PreTranslateMessage(MSG* pMsg);
124 
126  virtual BOOL OnIdle();
127 
129  void OnTimer(UINT_PTR nIDEvent);
130 
132  LRESULT OnCreate(LPCREATESTRUCT lParam);
133 
135  void OnPaint(CDCHandle dc);
136 
138  BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData);
139 
141  void OnDestroy();
142 
144  LRESULT OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
145 
147  LRESULT OnNewChannelFrame(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
148 
150  LRESULT OnNewHistogramFrame(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
151 
153  LRESULT OnOpenLogbook(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
154 
156  LRESULT OnLoadParameters(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
157 
159  LRESULT OnSaveParameters(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
160 
162  LRESULT OnSaveDefaultParameters(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
163 
165  LRESULT OnZeroGalvoOutputs(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
166 
168  LRESULT OnShutterOpen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
169 
171  LRESULT OnSaveWindowPositions(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
172 
174  LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
180  void QuitApplication();
182 };
183 
184 }}
Main controller of microscope hardware and acquisition, also interface to the GUI.
void OnPaint(CDCHandle dc)
Recreates stored frames on first call.
LRESULT OnSaveWindowPositions(WORD, WORD, HWND, BOOL &)
Calls ScopeController::SaveCurrentWindowPositions.
LRESULT OnSaveDefaultParameters(WORD, WORD, HWND, BOOL &)
Opens dialog to save the default ScopeParameters.
LRESULT OnCreate(LPCREATESTRUCT lParam)
Creates the frame with all its stuff and the CMainDialogView inside.
LRESULT OnOpenLogbook(WORD, WORD, HWND, BOOL &)
Opens the LogFrame window.
LRESULT OnZeroGalvoOutputs(WORD, WORD, HWND, BOOL &)
Calls ScopeController::ZeroGalvoOutputs.
The main application dialog frame.
Definition: MainDlgFrame.h:20
View class of the main dialog.
Definition: MainDlgView.h:13
LRESULT OnLoadParameters(WORD, WORD, HWND, BOOL &)
Opens dialog to load ScopeParameters.
CWinTraits< WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_CLIPCHILDREN|WS_CLIPSIBLINGS, WS_EX_APPWINDOW|WS_EX_WINDOWEDGE > CMainDlgFrameTraits
Traits for this window are standard CFrameWinTraits but without WS_THICKFRAME => no resize possible...
Definition: MainDlgFrame.h:17
void NewLogFrame(const RECT &_rect)
Opens a CLogFrame.
A logger class to log various messages and user comments.
Definition: ScopeLogger.h:24
LRESULT OnFileExit(WORD, WORD, HWND, BOOL &)
Calls QuitApplication.
CMainDlgView m_dlgView
the view with the dialog controls
Definition: MainDlgFrame.h:39
void QuitApplication()
Calls ScopeController::PrepareQuit and sends close message and subsequently quits the whole applicati...
LRESULT OnShutterOpen(WORD, WORD, HWND, BOOL &)
Calls ScopeController::OpenShutter.
scope::ScopeLogger scope_logger
our ScopeLogger here
Definition: MainDlgFrame.h:45
scope::ScopeController scope_controller
our ScopeController here
Definition: MainDlgFrame.h:42
void RecreateWindows()
Opens windows as saved.
void NewChannelFrame(const uint32_t &_area, const RECT &_rect)
Opens a new CChannelFrame.
LRESULT OnSaveParameters(WORD, WORD, HWND, BOOL &)
Opens dialog to save ScopeParameters.
static std::array< UINT, 4 > histogramareas_ids
ids for the new histogram toolbar dropdown menu items.
Definition: MainDlgFrame.h:51
CCommandBarCtrl m_CmdBar
the command bar.
Definition: MainDlgFrame.h:68
LRESULT OnAppAbout(WORD, WORD, HWND, BOOL &)
Opens the about dialog.
bool firstpaint
to recreate stored windows
Definition: MainDlgFrame.h:33
BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData)
Forwards to the view.
LRESULT OnNewHistogramFrame(WORD, WORD, HWND, BOOL &)
Opens a new CHistogramFrame, determines which dropdown menu item/area was choosen.
virtual void PrepareToolBarMenu(UINT nMenuID, HMENU hMenu)
Used in CToolBarHelper to fill the dropdown menus.
void NewHistogramFrame(const uint32_t &_area, const RECT &_rect)
Opens a new CHistogramFrame.
void OnTimer(UINT_PTR nIDEvent)
Update the memory consumption display.
LRESULT OnNewChannelFrame(WORD, WORD, HWND, BOOL &)
Opens a new CChannelFrame, determines which dropdown menu item/area was choosen.
CMultiPaneStatusBarCtrl m_wndStatusBar
the status bar
Definition: MainDlgFrame.h:36
void OnDestroy()
Destroys view and removes message stuff.
CFrameWindowImpl< CMainDlgFrame, CWindow, CMainDlgFrameTraits > CMainDlgFrameType
Need to typedef this, otherwise problems with CHAIN_MSG_MAP macro...
Definition: MainDlgFrame.h:30
static std::array< UINT, 4 > viewareas_ids
ids for the new view toolbar dropdown menu items.
Definition: MainDlgFrame.h:48
*virtual BOOL OnIdle()
=