Header
Product Comparison: USB I2C | USB SPI | USB GPIO
  • My Account
  • Shopping Cart
  • Products
  • My Account
  • About
  • Products
  • PC-I2C/SPI/GPIO Adapters
  • Main Page
  • Classes
  • Files
  • File List
  • File Members

D:/_sources/u2c_12/ControlPanel/MainFrm.cpp

Go to the documentation of this file.
00001 // Copyright (C)2006 Diolan ( http://www.diolan.com )
00002 //
00003 // This program is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU General Public License
00005 // as published by the Free Software Foundation
00006 //
00007 // This program is distributed in the hope that it will be useful,
00008 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 // GNU General Public License for more details.
00011 
00012 
00013 #include "stdafx.h"
00014 #include "ControlPanel.h"
00015 
00016 #include "MainFrm.h"
00017 
00018 #ifdef _DEBUG
00019 #define new DEBUG_NEW
00020 #undef THIS_FILE
00021 static char THIS_FILE[] = __FILE__;
00022 #endif
00023 
00025 // CMainFrame
00026 
00027 IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
00028 
00029 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
00030         //{{AFX_MSG_MAP(CMainFrame)
00031         ON_WM_CREATE()
00032         ON_WM_CLOSE()
00033         //}}AFX_MSG_MAP
00034 
00035         ON_COMMAND_EX(IDD_I2C_BRIDGE_DEVICES, OnBarCheck) 
00036         ON_UPDATE_COMMAND_UI(IDD_I2C_BRIDGE_DEVICES, OnUpdateControlBarMenu)
00037         ON_COMMAND_EX(IDD_I2C_READ, OnBarCheck) 
00038         ON_UPDATE_COMMAND_UI(IDD_I2C_READ, OnUpdateControlBarMenu)
00039         ON_COMMAND_EX(IDD_I2C_WRITE, OnBarCheck) 
00040         ON_UPDATE_COMMAND_UI(IDD_I2C_WRITE, OnUpdateControlBarMenu)
00041         ON_COMMAND_EX(IDD_I2C_LOW_LEVEL, OnBarCheck) 
00042         ON_UPDATE_COMMAND_UI(IDD_I2C_LOW_LEVEL, OnUpdateControlBarMenu)
00043         ON_COMMAND_EX(IDD_I2C_BUS_LEVEL, OnBarCheck)
00044         ON_UPDATE_COMMAND_UI(IDD_I2C_BUS_LEVEL, OnUpdateControlBarMenu)
00045         ON_COMMAND_EX(IDD_SPI_BAR, OnBarCheck)
00046         ON_UPDATE_COMMAND_UI(IDD_SPI_BAR, OnUpdateControlBarMenu)
00047 
00048         ON_WM_TIMER()
00049 END_MESSAGE_MAP()
00050 
00051 static UINT indicators[] =
00052 {
00053         ID_SEPARATOR,           // status line indicator
00054         ID_INDICATOR_CAPS,
00055         ID_INDICATOR_NUM,
00056         ID_INDICATOR_SCRL,
00057 };
00058 
00060 // CMainFrame construction/destruction
00061 
00062 CMainFrame::CMainFrame()
00063 {
00064         // TODO: add member initialization code here
00065         
00066 }
00067 
00068 CMainFrame::~CMainFrame()
00069 {
00070 }
00071 
00072 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
00073 {
00074         if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
00075                 return -1;
00076         
00077         if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
00078                 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
00079                 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
00080         {
00081                 TRACE0("Failed to create toolbar\n");
00082                 return -1;      // fail to create
00083         }
00084         if (!m_wndStatusBar.Create(this) ||
00085                 !m_wndStatusBar.SetIndicators(indicators,
00086                   sizeof(indicators)/sizeof(UINT)))
00087         {
00088                 TRACE0("Failed to create status bar\n");
00089                 return -1;      // fail to create
00090         }
00091 
00092         // TODO: Delete these three lines if you don't want the toolbar to
00093         //  be dockable
00094         m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
00095         EnableDocking(CBRS_ALIGN_ANY);
00096         DockControlBar(&m_wndToolBar);
00097 
00098         if(!m_I2CBridgeDevices.Create(this, IDD_I2C_BRIDGE_DEVICES, 
00099                 CBRS_TOP | CBRS_TOOLTIPS| CBRS_FLYBY | CBRS_GRIPPER, IDD_I2C_BRIDGE_DEVICES))
00100         {
00101                 TRACE0("Failed to create m_I2CBridgeDevices\n");
00102                 return -1;
00103         }
00104         m_I2CBridgeDevices.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00105         EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00106         DockControlBar(&m_I2CBridgeDevices);
00107 
00108         if (!m_I2cReadBar.Create(this))
00109         {
00110                 TRACE0("Failed to create m_I2cReadBar\n");
00111                 return -1;
00112         }
00113         m_I2cReadBar.EnableDocking(CBRS_ALIGN_TOP |CBRS_ALIGN_BOTTOM);
00114         EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00115         DockControlBar(&m_I2cReadBar);
00116 
00117 
00118         if (!m_I2cWriteBar.Create(this))
00119         {
00120                 TRACE0("Failed to create m_I2cWriteBar\n");
00121                 return -1;
00122         }
00123 
00124 
00125         m_I2cWriteBar.EnableDocking(CBRS_ALIGN_TOP |CBRS_ALIGN_BOTTOM);
00126         EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00127         DockControlBar(&m_I2cWriteBar);
00128 
00129         if(!m_I2cLowLevelBar.Create(this))
00130         {
00131                 TRACE0("Failed to create m_I2cLowLevelBar\n");
00132                 return -1;
00133         }
00134         m_I2cLowLevelBar.EnableDocking(CBRS_ALIGN_TOP |CBRS_ALIGN_BOTTOM);
00135         EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00136         DockControlBar(&m_I2cLowLevelBar);
00137 
00138         if (!m_I2cBusLevelBar.Create(this, IDD_I2C_BUS_LEVEL,
00139                 CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_GRIPPER, IDD_I2C_BUS_LEVEL))
00140         {
00141                 TRACE0("Failed to create m_I2cBusLevelBar\n");
00142                 return -1;
00143         }
00144         m_I2cBusLevelBar.SetWindowText("I2c bus level commands bar");
00145         m_I2cBusLevelBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00146         EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00147         DockControlBar(&m_I2cBusLevelBar);
00148 
00149         if (!m_SpiBar.Create(this))
00150         {
00151                 TRACE0("Failed to create m_SpiBar\n");
00152                 return -1;
00153         }
00154         m_SpiBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00155         EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
00156         DockControlBar(&m_SpiBar);
00157 
00158         LoadBarState("Bars\\");
00159         if(m_wndToolBar.CalcFixedLayout(FALSE, TRUE).cy != m_I2CBridgeDevices.m_sizeDefault.cy)
00160                 m_wndToolBar.SetHeight(m_I2CBridgeDevices.m_sizeDefault.cy);// = m_I2CBridgeDevices.GetHight
00161         return 0;
00162 }
00163 
00164 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
00165 {
00166         if( !CFrameWnd::PreCreateWindow(cs) )
00167                 return FALSE;
00168         // TODO: Modify the Window class or styles here by modifying
00169         //  the CREATESTRUCT cs
00170 
00171         return TRUE;
00172 }
00173 
00175 // CMainFrame diagnostics
00176 
00177 #ifdef _DEBUG
00178 void CMainFrame::AssertValid() const
00179 {
00180         CFrameWnd::AssertValid();
00181 }
00182 
00183 void CMainFrame::Dump(CDumpContext& dc) const
00184 {
00185         CFrameWnd::Dump(dc);
00186 }
00187 
00188 #endif //_DEBUG
00189 
00191 // CMainFrame message handlers
00192 
00193 
00194 
00195 
00196 
00197 void CMainFrame::OnClose() 
00198 {
00199         // TODO: Add your message handler code here and/or call default
00200         SaveBarState("Bars\\");
00201         CFrameWnd::OnClose();
00202 }
00203 
00204 void CMainFrame::EnableControls(bool bEnable)
00205 {
00206         m_I2cReadBar.EnableControls(bEnable);
00207         m_I2cWriteBar.EnableControls(bEnable);
00208         m_I2cLowLevelBar.EnableControls(bEnable);
00209         m_I2cBusLevelBar.EnableControls(bEnable);
00210         m_I2CBridgeDevices.EnableControls(bEnable);
00211         m_SpiBar.EnableControls(bEnable);
00212 }
00213 
  • Products
  • PC-I2C/SPI/GPIO Adapters
  • Comparison
  • PC-I2C/SPI/GPIO Adapter DLN-1
  • USB-I2C/SPI/GPIO Adapter DLN-2
  • Multiprotocol Master DLN-4M
  • Multiprotocol Slave DLN-4S
  • Downloads
  • Software
  • Documentation
  • SW Tools & Examples
  • Development Boards
  • Open Source Projects
  • Discontinued Products
  • API Documentation
  • Downloads
  • SW Tools and Examples
footer top footer bottom
© Copyright Diolan 2006-2012