reman3/Rayman_X/cpa/tempgrp/Ctl/Src/WControls/CTL_WSta.cpp

280 lines
8.0 KiB
C++

// CPACStat.cpp : implementation file
//////////////////////////////////////////
#include "StdAfx.h"
#include "WControls\CTL_WSta.hpp"
#include "Others\CTL_Pub.hpp"
#include "Others\CTL_Pri.hpp"
//ANNECY CB
#include "WControls\CTL_VBas.hpp"
//END ANNECY
//External Modules
#include "IncTUT.h"
//End of External Modules
extern CBrush g_clWhiteBrush;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//Colors for a value (not changeable in Setup)
COLORREF CTL_g_colref_ValueTextColor = RGB(0,0,0);
/////////////////////////////////////////////////////////////////////////////
// CTL_Editor_Static
IMPLEMENT_DYNAMIC(CTL_Editor_Static, CStatic)
BEGIN_MESSAGE_MAP(CTL_Editor_Static, CStatic)
//{{AFX_MSG_MAP(CTL_Editor_Static)
ON_WM_RBUTTONUP()
ON_WM_LBUTTONDBLCLK()
ON_WM_PAINT()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDOWN()
//ANNECY CB
ON_WM_MOUSEMOVE()
//END ANNECY
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//***************************************************************************
CTL_Editor_Static::CTL_Editor_Static(CString _csName,
CTL_tdeStaticType _tdeType,
long _lAdditionnalStyles,
CTL_Editor_Control *_pclParentControl,
CWnd *_pclParentWnd,
long _lUserDefinedType /*= 0*/,
long _lUserDefinedCode /*= 0*/)
: CTL_BaseWindowsControl(_pclParentControl,
_pclParentWnd,
_lUserDefinedType,
_lUserDefinedCode)
{
m_csTextToDisplay = _csName;
m_pri_tdeType = _tdeType;
m_pri_p_fnStaticHasBeenClicked_CallBack = CTL_g_p_fnDefaultCallBack_StaticHasBeenClicked;
m_pri_td_p_fn_vGetColor = CTL_g_p_fnDefaultCallBack_GetColor;
//Creates the control
DWORD lStyles = WS_CHILD | SS_NOTIFY | WS_BORDER;
switch ( m_pri_tdeType )
{
case CTL_STATIC_TYPE__FIELD_VALUE:
case CTL_STATIC_TYPE__NEUTRAL_FIELD:
lStyles |= (SS_CENTER);
break;
}
lStyles |= _lAdditionnalStyles;
m_pri_colBackGroundColor = RGB(132,132,132);
m_pri_colTextColor = RGB(0,0,0);
if ( Create(_csName,
lStyles,
CRect(0,0,0,0),
_pclParentWnd,
CTL_fn_lGetNextAvailableIDForControl()) )
{
SetFont(_pclParentWnd->GetFont());
}
}
//***************************************************************************
CTL_Editor_Static::~CTL_Editor_Static()
{
}
/////////////////////////////////////////////////////////////////////////////
// CTL_Editor_Static message handlers
//***************************************************************************
void CTL_Editor_Static::m_fn_vSetTextToDisplay(CString csNewText,
BOOL _bMustRefresDisplay /*= FALSE*/)
{
m_csTextToDisplay = csNewText;
if ( _bMustRefresDisplay )
InvalidateRect(NULL);
}
//***************************************************************************
CTL_tdeStaticType CTL_Editor_Static::m_pub_fn_tdeGetType()
{
return m_pri_tdeType;
}
//***************************************************************************
CString CTL_Editor_Static::m_pub_fn_csGetDisplayedString()
{
return m_csTextToDisplay;
}
//***************************************************************************
COLORREF CTL_Editor_Static::m_pub_fn_colGetBackGroundColor()
{
return m_pri_colBackGroundColor;
}
//***************************************************************************
void CTL_Editor_Static::m_pub_fn_vSetBackGroundColor(COLORREF _colNewColor,
BOOL _bMustRefresDisplay /*= FALSE*/)
{
m_pri_colBackGroundColor = _colNewColor;
if ( _bMustRefresDisplay )
InvalidateRect(NULL);
}
//***************************************************************************
COLORREF CTL_Editor_Static::m_pub_fn_colGetTextColor()
{
return m_pri_colTextColor;
}
//***************************************************************************
void CTL_Editor_Static::m_pub_fn_vSetTextColor(COLORREF _colNewColor,
BOOL _bMustRefresDisplay /*= FALSE*/)
{
m_pri_colTextColor = _colNewColor;
if ( _bMustRefresDisplay )
InvalidateRect(NULL);
}
//***************************************************************************
void CTL_Editor_Static::m_pub_fn_vSetStaticHasBeenClicked_CallBack(
CTL_td_p_fn_vStaticHasBeenClicked _p_fnStaticHasBeenClicked_CallBack)
{
m_pri_p_fnStaticHasBeenClicked_CallBack = _p_fnStaticHasBeenClicked_CallBack;
}
//***************************************************************************
void CTL_Editor_Static::m_pub_fn_v_SetColRefGetColor_CallBack(CTL_tdp_fn_vGetColor _p_fn_CallBack)
{
m_pri_td_p_fn_vGetColor = _p_fn_CallBack;
}
//***************************************************************************
void CTL_Editor_Static::OnRButtonUp(UINT nFlags, CPoint point)
{
//CPA2 Stegaru Cristian 98/06/19
CTL_tdeClickType clickType = CTL_CLICK_TYPE__RIGHT_CLICK;
if (MK_SHIFT == (MK_SHIFT & nFlags))
clickType = CTL_CLICK_TYPE__SHIFT_RIGHT_CLICK;
if ( m_pri_p_fnStaticHasBeenClicked_CallBack != NULL )
m_pri_p_fnStaticHasBeenClicked_CallBack(this, clickType);
//End CPA2 Stegaru Cristian 98/06/19
CStatic::OnRButtonUp(nFlags, point);
}
//***************************************************************************
void CTL_Editor_Static::OnLButtonDblClk(UINT nFlags, CPoint point)
{
if ( m_pri_p_fnStaticHasBeenClicked_CallBack != NULL )
m_pri_p_fnStaticHasBeenClicked_CallBack(this, CTL_CLICK_TYPE__LEFT_DOUBLE_CLICK);
CStatic::OnMButtonDblClk(nFlags, point);
}
//***************************************************************************
void CTL_Editor_Static::OnLButtonUp(UINT nFlags, CPoint point)
{
if ( m_pri_p_fnStaticHasBeenClicked_CallBack != NULL )
m_pri_p_fnStaticHasBeenClicked_CallBack(this, CTL_CLICK_TYPE__LEFT_CLICK);
CStatic::OnLButtonUp(nFlags, point);
}
//***************************************************************************
//ANNECY CB
void CTL_Editor_Static::OnMouseMove(UINT nFlags, CPoint point)
{
CTL_Editor_BaseFormView *pView = (CTL_Editor_BaseFormView *) GetParent();
ClientToScreen(&point);
pView->ScreenToClient(&point);
LPARAM lParam = point.x + (point.y << 16);
pView->SendMessage(WM_MOUSEMOVE, (WPARAM) nFlags, lParam);
}
//END ANNECY
void CTL_Editor_Static::OnLButtonDown(UINT nFlags, CPoint point)
{
//ANNECY CB
// if ( m_pri_p_fnStaticHasBeenClicked_CallBack != NULL )
// m_pri_p_fnStaticHasBeenClicked_CallBack(this, CTL_CLICK_TYPE__LEFT_BUTTON_DOWN);
// else
{
CTL_Editor_BaseFormView *pView = (CTL_Editor_BaseFormView *) GetParent();
ClientToScreen(&point);
pView->ScreenToClient(&point);
LPARAM lParam = point.x + (point.y << 16);
pView->SendMessage(WM_LBUTTONDOWN, (WPARAM) nFlags, lParam);
}
//END ANNECY
CStatic::OnLButtonDown(nFlags, point);
}
//***************************************************************************
void CTL_Editor_Static::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect crClientRect;
GetClientRect(crClientRect);
if ( m_pri_td_p_fn_vGetColor != NULL )
m_pri_td_p_fn_vGetColor(this, m_pri_colBackGroundColor, m_pri_colTextColor);
//Fills the window's rect
dc.FillSolidRect(crClientRect, m_pri_colBackGroundColor);
//Displays the string
dc.SelectObject(GetFont());
dc.SetTextColor(m_pri_colTextColor);
dc.SetBkMode(TRANSPARENT);
UINT nFormat = DT_SINGLELINE | DT_VCENTER;
if ( (GetStyle() & SS_CENTER) != 0 )
nFormat |= DT_CENTER;
else
nFormat |= DT_LEFT;
crClientRect.left ++;
dc.DrawText(m_csTextToDisplay, crClientRect, nFormat);
// Do not call CStatic::OnPaint() for painting messages
}
//***************************************************************************
long CTL_Editor_Static::m_fn_lGetMinLength()
{
CClientDC dc(this);
CString csWindowText;
GetWindowText(csWindowText);
dc.SelectObject(GetFont());
return (dc.GetTextExtent(csWindowText).cx);
}
//**********************************************************************************
//For TUT registration
void CTL_Editor_Static::m_pub_fn_vRegisterWindowsControl(CString _csAdditionnalInfo)
{
#ifndef CTL_WITH_NO_TUT
m_pro_fn_vRegisterWindowsControl(_csAdditionnalInfo, TUT_e_Window, "Static", this);
#endif //CTL_WITH_NO_TUT
}