|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: ToolBarDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of ToolBarDlg.cpp
//----------------------------------------------------------------------------
// ToolBarDlg.cpp : implementation file
//
#include "stdafx.h"
#include "chicago.h"
#include "ToolBarDlg.h"
#include "..\..\LgLib\Version.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;#endif
/////////////////////////////////////////////////////////////////////////////
// CToolBarDlg dialog
static TBBUTTON stbButtons[] ={ { 0, IDM_SYSTEM_RESET, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Reset program", 0 }// ,{ 1, IDM_SYSTEM_ENABLE, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Enable zone/devise/sensor", 1 }
// ,{ 2, IDM_VIEW_MAIN, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"View main screen", 2 }
// ,{ 3, IDM_VIEW_DETAIL, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"View detail screen", 3 }
// ,{ 4, IDM_VIEW_OPTIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Change zoom factor", 4 }
// ,{ 5, IDM_SUPPORT_DATETIME, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Change date/time", 5 }
// ,{ 6, IDM_SUPPORT_GUARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Change guard", 6 }
,{ 7, IDM_SUPPORT_MUTE, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Mute sound", 7 } ,{ 8, IDM_SUPPORT_REPORT, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"History/report", 8 }// ,{ 9, IDM_SUPPORT_SOUND, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Enable/disable zone sound", 9 }
// ,{ 10, IDM_SUPPORT_STATISTIC, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Show statistic", 10 }
// ,{ 11, IDM_SYSTEM_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON, { 0, 0 }, (DWORD)"Exit", 11 }
};
CToolBarDlg::CToolBarDlg(CWnd* pParent /*=NULL*/) : CDialog(CToolBarDlg::IDD, pParent){ //{{AFX_DATA_INIT(CToolBarDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_nButtonCount = sizeof(stbButtons)/sizeof(stbButtons[0]); m_pButton = new TBBUTTON[ m_nButtonCount ]; for( int i = 0; i < m_nButtonCount; i++ ) { m_pButton[i].idCommand = stbButtons[i].idCommand; m_pButton[i].iBitmap = stbButtons[i].iBitmap; m_pButton[i].iString = stbButtons[i].iString; m_pButton[i].fsState = stbButtons[i].fsState; m_pButton[i].fsStyle = stbButtons[i].fsStyle; m_pButton[i].dwData = stbButtons[i].dwData;// m_pButton[i].bReserved = tbButtons[i].bReserved;
}
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CToolBarDlg::CToolBarDlg") );}
void CToolBarDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CToolBarDlg)
DDX_Control(pDX, IDC_STATIC_MODE, m_StaticMode); //}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CToolBarDlg, CDialog) //{{AFX_MSG_MAP(CToolBarDlg)
ON_WM_DESTROY() ON_WM_SIZE() ON_WM_MOVE() //}}AFX_MSG_MAP
END_MESSAGE_MAP()
//static const int seqTableCount = sizeof(seqTable) / sizeof( seqTable[0] );
BOOL CToolBarDlg::OnToolTipNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult ){ return FALSE;
TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR; if( (pTTT->hdr.code == TTN_NEEDTEXT) )//&& ( pTTT->uFlags & 0x40 ) )
{ int uId = pNMHDR->idFrom; for( int i = 0; i < m_nButtonCount; i++ ) if( m_pButton[i].idCommand == uId ) { pTTT->lpszText = (LPSTR)m_pButton[i].dwData;//tbToolTips[i];
pTTT->hinst = NULL; return TRUE; } } return FALSE;}
void CToolBarDlg::CreateButtons( CMenu *pMenu ){ for( unsigned int i = 0; i < pMenu->GetMenuItemCount(); i++ ) { CHAR pBuffer[100]; MENUITEMINFO mii; mii.cbSize = sizeof(MENUITEMINFO); mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_SUBMENU; mii.cch = 100; mii.dwTypeData = pBuffer; pMenu->GetMenuItemInfo( i, &mii, TRUE ); if( mii.hSubMenu ) CreateButtons( pMenu->GetSubMenu(i) ); else if( mii.fType==MFT_STRING && mii.hSubMenu==NULL ) { for( int j = 0; j < m_nButtonCount; j++ ) { if( LOWORD(m_pButton[j].idCommand) == LOWORD(mii.wID) ) { m_ToolBarCtrl.AddButtons( 1, &m_pButton[j] ); break; } } } }}
BOOL CToolBarDlg::Create( UINT nIDTemplate, CWnd* pParentWnd, CMenu *pMenu ) { CSize size( 60, 30 );
m_Size.cx = size.cx + ::GetSystemMetrics( SM_CXEDGE ) * 3 ; m_Size.cy = size.cy + ::GetSystemMetrics( SM_CYEDGE ) * 3; if( CDialog::Create(IDD, pParentWnd) ) { SetWindowLong( GetSafeHwnd(), GWL_STYLE, GetWindowLong( GetSafeHwnd(), GWL_STYLE ) | WS_DLGFRAME | WS_CLIPSIBLINGS );
CRect rect( 0, 0, GetSystemMetrics(SM_CXSCREEN), m_Size.cy ); m_ToolBarCtrl.Create( CBRS_TOOLTIPS | TBSTYLE_TOOLTIPS | TBSTYLE_WRAPABLE /* | CCS_NORESIZE*/ | CCS_NODIVIDER | WS_CHILD | WS_VISIBLE, rect, this, 0 ); m_ToolBarCtrl.SetBitmapSize( size ); m_ToolBarCtrl.AddBitmap( m_nButtonCount, IDB_BITMAP_TOOLBAR ); m_ToolBarCtrl.SetButtonSize( m_Size ); CreateButtons( pMenu );
m_ToolBarCtrl.AutoSize();
CRect r( 0, 0, m_Size.cx * m_ToolBarCtrl.GetButtonCount() + ::GetSystemMetrics( SM_CXEDGE ) * 3, m_Size.cy ); m_ToolBarCtrl.MoveWindow( &r );
m_StaticMode.ShowWindow( SW_HIDE );
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CToolBarDlg::Create"), _T("Succeeded") ); return TRUE; }
LGLOG( LOG_LEVEL_LOW, LOG_TYPE_ERROR, this, _T("CToolBarDlg::Create"), _T("CDialog::Create failed") ); return FALSE;}
BOOL CToolBarDlg::OnCommand(WPARAM wParam, LPARAM lParam) { return GetParent()->SendMessage( WM_COMMAND, wParam, lParam );}
void CToolBarDlg::OnDestroy() { CDialog::OnDestroy(); if( m_pButton ) delete [] m_pButton;}
BOOL CToolBarDlg::PreTranslateMessage(MSG* pMsg) { switch( pMsg->message ) { case WM_KEYDOWN: case WM_SYSKEYDOWN: return GetParent()->PreTranslateMessage( pMsg ); } return CDialog::PreTranslateMessage(pMsg);}
int CToolBarDlg::GetHeight(){ return m_Size.cy;}
void CToolBarDlg::OnSize(UINT nType, int cx, int cy) { LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CToolBarDlg::OnSize"), _T("Started...") );
CDialog::OnSize(nType, cx, cy);/*
if( m_StaticMode.GetSafeHwnd() ) { CRect r; GetClientRect( &r ); r.right -= 10; r.left += m_Size.cx * m_ToolBarCtrl.GetButtonCount() + ::GetSystemMetrics( SM_CXEDGE ) * 3; m_StaticMode.MoveWindow( &r ); }*/ if( m_ToolBarCtrl.GetSafeHwnd() ) { m_ToolBarCtrl.MoveWindow( 0, 0, cx, cy ); m_ToolBarCtrl.AutoSize(); }
LGLOG( LOG_LEVEL_HIGH, LOG_TYPE_INFO, this, _T("CToolBarDlg::OnSize"), _T("Done") );}
void CToolBarDlg::SetModeText(LPCTSTR pStr){ m_StaticMode.SetWindowText( pStr );}
BOOL CToolBarDlg::EnableButton( INT nID, BOOL bEnable ){ return m_ToolBarCtrl.EnableButton( nID, bEnable );}
void CToolBarDlg::OnMove(int x, int y) { CDialog::OnMove( x, y );
// MoveWindow( x+1, y, 90, 30 );
}
|