page_uipanel.cpp
来自「混乱竞技场的全套代码,客户端资源可以网上搜」· C++ 代码 · 共 391 行
CPP
391 行
// Page_UIPanel.cpp : implementation file
//
#include "stdafx.h"
#include "gstools.h"
#include "Page_UIPanel.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const int CHARSET_LIST[18] = {
-1,
0,
1,
2,
128,
129,
134,
136,
255,
130,
177,
178,
161,
162,
163,
222,
238,
204
};
/////////////////////////////////////////////////////////////////////////////
// CPage_UIPanel property page
const UINT ALIGN[3] = {DT_LEFT,DT_RIGHT,DT_CENTER};
int GetAlignIndex(UINT align)
{
for(int i=0; i<3; i++)
{
if(ALIGN[i]==align)
return i;
}
return 0;
}
IMPLEMENT_DYNCREATE(CPage_UIPanel, CPropertyPage)
CPage_UIPanel::CPage_UIPanel() : CPropertyPage(CPage_UIPanel::IDD)
{
//{{AFX_DATA_INIT(CPage_UIPanel)
m_bBackLayer = TRUE;
m_bCanMove = FALSE;
m_header_left = 0;
m_header_top = 0;
m_header_right = 0;
m_header_bottom = 0;
m_str_image_normal = _T("");
m_str_image_normal_touch = _T("");
m_str_sound_click = _T("");
m_str_sound_touch = _T("");
m_size_x = 0;
m_size_y = 0;
m_is_visuable = TRUE;
m_is_enable = TRUE;
m_str_image_press = _T("");
m_str_image_press_touch = _T("");
m_str_image_sense = _T("");
m_bChecked = FALSE;
m_str_name = _T("");
m_str_config = _T("");
m_str_style = _T("");
m_str_base_style = _T("");
m_str_image_disable = _T("");
m_isCaption = FALSE;
m_nAlign = 0;
m_bCanEdit = FALSE;
m_strCaption = _T("");
m_strColor = _T("");
m_strFont = _T("");
m_nFontSize = 0;
m_charset_index = 1;
m_str_bk_color = _T("");
//}}AFX_DATA_INIT
}
CPage_UIPanel::~CPage_UIPanel()
{
}
void CPage_UIPanel::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPage_UIPanel)
DDX_Check(pDX, IDC_BACK_LAYER, m_bBackLayer);
DDX_Check(pDX, IDC_CAN_MOVE, m_bCanMove);
DDX_Text(pDX, IDC_EDIT_HEADER1, m_header_left);
DDX_Text(pDX, IDC_EDIT_HEADER2, m_header_top);
DDX_Text(pDX, IDC_EDIT_HEADER3, m_header_right);
DDX_Text(pDX, IDC_EDIT_HEADER4, m_header_bottom);
DDX_Text(pDX, IDC_EDIT_IMAGE, m_str_image_normal);
DDX_Text(pDX, IDC_EDIT_IMAGE2, m_str_image_normal_touch);
DDX_Text(pDX, IDC_EDIT_IMAGE3, m_str_sound_click);
DDX_Text(pDX, IDC_EDIT_IMAGE4, m_str_sound_touch);
DDX_Text(pDX, IDC_EDIT1, m_size_x);
DDX_Text(pDX, IDC_EDIT2, m_size_y);
DDX_Check(pDX, IDC_VISUABLE, m_is_visuable);
DDX_Check(pDX, IDC_ENABLE, m_is_enable);
DDX_Text(pDX, IDC_EDIT_IMAGE5, m_str_image_press);
DDX_Text(pDX, IDC_EDIT_IMAGE6, m_str_image_press_touch);
DDX_Text(pDX, IDC_EDIT_IMAGE7, m_str_image_sense);
DDX_Check(pDX, IDC_CHECKED, m_bChecked);
DDX_Text(pDX, IDC_EDIT3, m_str_name);
DDX_Text(pDX, IDC_EDIT4, m_str_config);
DDX_Text(pDX, IDC_EDIT5, m_str_style);
DDX_Text(pDX, IDC_EDIT6, m_str_base_style);
DDX_Text(pDX, IDC_EDIT_IMAGE8, m_str_image_disable);
DDX_Check(pDX, IDC_CAPTION, m_isCaption);
DDX_CBIndex(pDX, IDC_COMBO_ALIGN, m_nAlign);
DDX_Check(pDX, IDC_EDIT_BOX, m_bCanEdit);
DDX_Text(pDX, IDEDIT_CAPTION, m_strCaption);
DDX_Text(pDX, IDEDIT_FONT_COLOR, m_strColor);
DDX_Text(pDX, IDEDIT_FONT_NAME, m_strFont);
DDX_Text(pDX, IDEDIT_FONT_SIZE, m_nFontSize);
DDX_CBIndex(pDX, IDC_COMBO_CHARSET, m_charset_index);
DDX_Text(pDX, IDEDIT_BK_COLOR, m_str_bk_color);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPage_UIPanel, CPropertyPage)
//{{AFX_MSG_MAP(CPage_UIPanel)
ON_BN_CLICKED(IDC_BUTTON1, OnButton_image_normal)
ON_BN_CLICKED(IDC_BUTTON2, OnButton_image_normal_touch)
ON_BN_CLICKED(IDC_BUTTON5, OnButton_image_press)
ON_BN_CLICKED(IDC_BUTTON6, OnButton_image_press_touch)
ON_BN_CLICKED(IDC_BUTTON7, OnButton_image_sense)
ON_BN_CLICKED(IDC_BUTTON8, OnButton_image_disable)
ON_BN_CLICKED(IDC_BUTTON3, OnButton_sound_click)
ON_BN_CLICKED(IDC_BUTTON4, OnButton_sound_touch)
ON_BN_CLICKED(IDC_BTN_FONT_COLOR, OnBtnFontColor)
ON_BN_CLICKED(IDC_BTN_BK_COLOR, OnBtnBkColor)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPage_UIPanel message handlers
BOOL CPage_UIPanel::SetUI(CGsUIPanel *pUI)
{
m_ptr_ui = pUI;
if(NULL==m_ptr_ui)
return FALSE;
m_bCanMove = m_ptr_ui->IsCanMove();
m_bBackLayer = m_ptr_ui->IsBackLayer();
m_is_visuable = m_ptr_ui->IsVisible();
m_is_enable = m_ptr_ui->IsEnable();
m_bChecked = m_ptr_ui->IsStyleChecked();
m_str_image_normal = m_ptr_ui->GetImageNormal();
m_str_image_normal_touch = m_ptr_ui->GetImageNormalTouch();
m_str_image_press = m_ptr_ui->GetImagePress();
m_str_image_press_touch = m_ptr_ui->GetImagePressTouch();
m_str_image_sense = m_ptr_ui->GetImageSense();
m_str_image_disable = m_ptr_ui->GetImageDisable();
m_str_sound_touch = m_ptr_ui->GetSoundTouch();
m_str_sound_click = m_ptr_ui->GetSoundTClick();
m_str_name = m_ptr_ui->GetName();
m_str_config = m_ptr_ui->GetConfig();
m_str_style = m_ptr_ui->GetStyle();
m_str_base_style = m_ptr_ui->GetBaseStyle();
m_isCaption = m_ptr_ui->IsTextbox();
m_nAlign = GetAlignIndex(m_ptr_ui->GetAlign());
m_bCanEdit = m_ptr_ui->IsCanEdit();
m_strCaption = m_ptr_ui->GetCaption();
D3DCOLOR cr = m_ptr_ui->GetColor();
m_strColor.Format("%d,%d,%d,%d", RGBA_GETRED(cr), RGBA_GETGREEN(cr), RGBA_GETBLUE(cr), RGBA_GETALPHA(cr));
cr = m_ptr_ui->GetBkColor();
m_str_bk_color.Format("%d,%d,%d,%d", RGBA_GETRED(cr), RGBA_GETGREEN(cr), RGBA_GETBLUE(cr), RGBA_GETALPHA(cr));
m_strFont = m_ptr_ui->GetFont()->strFont;
m_nFontSize = m_ptr_ui->GetFont()->size;
for(m_charset_index=0; m_charset_index<18; m_charset_index++)
{
if(m_ptr_ui->GetFont()->charset==CHARSET_LIST[m_charset_index])
break;
}
GPOINT point = m_ptr_ui->GetSize();
GRECT rc = m_ptr_ui->GetHeaderRect();
m_size_x = point.x;
m_size_y = point.y;
m_header_left = rc.left;
m_header_top = rc.top;
m_header_right = rc.right;
m_header_bottom = rc.bottom;
UpdateData(FALSE);
return TRUE;
}
BOOL CPage_UIPanel::Save()
{
if(NULL==m_ptr_ui)
return FALSE;
UpdateData();
m_ptr_ui->SetCanMove(m_bCanMove);
m_ptr_ui->SetBackLayer(m_bBackLayer);
m_ptr_ui->SetEnable(m_is_enable);
m_ptr_ui->SetVisible(m_is_visuable);
m_ptr_ui->SetStyleChecked(m_bChecked);
m_ptr_ui->SetStyle(m_str_style);
m_ptr_ui->SetBaseStyle(m_str_base_style);
m_ptr_ui->SetName(m_str_name);
m_ptr_ui->SetSize(GPOINT(m_size_x, m_size_y));
m_ptr_ui->SetHeaderRect(GRECT(m_header_left, m_header_top, m_header_right, m_header_bottom));
m_ptr_ui->SetImageNormal((LPCSTR)m_str_image_normal);
m_ptr_ui->SetImageNormalTouch((LPCSTR)m_str_image_normal_touch);
m_ptr_ui->SetImagePress((LPCSTR)m_str_image_press);
m_ptr_ui->SetImagePressTouch((LPCSTR)m_str_image_press_touch);
m_ptr_ui->SetImageSense((LPCSTR)m_str_image_sense);
m_ptr_ui->SetImageDisable((LPCSTR)m_str_image_disable);
m_ptr_ui->SetSoundClick((LPCSTR)m_str_sound_click);
m_ptr_ui->SetSoundTouch((LPCSTR)m_str_sound_touch);
m_ptr_ui->SetTextbox(m_isCaption);
m_ptr_ui->SetAlign(ALIGN[m_nAlign]);
m_ptr_ui->SetCanEdit(m_bCanEdit);
m_ptr_ui->SetColor(CGsFunc::StringToColor((LPCSTR)m_strColor));
m_ptr_ui->SetBkColor(CGsFunc::StringToColor((LPCSTR)m_str_bk_color));
strcpy(m_ptr_ui->GetFont()->strFont, (LPCSTR)m_strFont);
m_ptr_ui->GetFont()->size = m_nFontSize;
m_ptr_ui->GetFont()->charset = CHARSET_LIST[m_charset_index];
m_ptr_ui->SetFont();
m_ptr_ui->SetCaption((LPCSTR)m_strCaption);
return TRUE;
}
void CPage_UIPanel::OnButton_image_normal()
{
// TODO: Add your control notification handler code here
UpdateData();
CDlgSelectImage dlg;
if(IDOK!=dlg.DoModal())
{
return;
}
m_str_image_normal = dlg.m_str_image;
m_ptr_ui->SetImageNormal((LPCSTR)m_str_image_normal);
UpdateData(FALSE);
}
void CPage_UIPanel::OnButton_image_normal_touch()
{
// TODO: Add your control notification handler code here
UpdateData();
CDlgSelectImage dlg;
if(IDOK!=dlg.DoModal())
{
return;
}
m_str_image_normal_touch = dlg.m_str_image;
m_ptr_ui->SetImageNormalTouch((LPCSTR)m_str_image_normal_touch);
UpdateData(FALSE);
}
void CPage_UIPanel::OnButton_image_press()
{
// TODO: Add your control notification handler code here
UpdateData();
CDlgSelectImage dlg;
if(IDOK!=dlg.DoModal())
{
return;
}
m_str_image_press = dlg.m_str_image;
m_ptr_ui->SetImagePress((LPCSTR)m_str_image_press);
UpdateData(FALSE);
}
void CPage_UIPanel::OnButton_image_press_touch()
{
// TODO: Add your control notification handler code here
UpdateData();
CDlgSelectImage dlg;
if(IDOK!=dlg.DoModal())
{
return;
}
m_str_image_press_touch = dlg.m_str_image;
m_ptr_ui->SetImagePressTouch((LPCSTR)m_str_image_press_touch);
UpdateData(FALSE);
}
void CPage_UIPanel::OnButton_image_sense()
{
// TODO: Add your control notification handler code here
UpdateData();
CDlgSelectImage dlg;
if(IDOK!=dlg.DoModal())
{
return;
}
m_str_image_sense = dlg.m_str_image;
m_ptr_ui->SetImageSense((LPCSTR)m_str_image_sense);
UpdateData(FALSE);
}
void CPage_UIPanel::OnButton_image_disable()
{
// TODO: Add your control notification handler code here
UpdateData();
CDlgSelectImage dlg;
if(IDOK!=dlg.DoModal())
{
return;
}
m_str_image_disable = dlg.m_str_image;
m_ptr_ui->SetImageDisable((LPCSTR)m_str_image_disable);
UpdateData(FALSE);
}
void CPage_UIPanel::OnButton_sound_click()
{
// TODO: Add your control notification handler code here
}
void CPage_UIPanel::OnButton_sound_touch()
{
// TODO: Add your control notification handler code here
}
void CPage_UIPanel::OnBtnFontColor()
{
// TODO: Add your control notification handler code here
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
UpdateData();
D3DCOLOR cr = CGsFunc::StringToColor((LPCSTR)m_strColor);
m_strColor.Format("%d,%d,%d,%d",
GetRValue(dlg.GetColor()),
GetGValue(dlg.GetColor()),
GetBValue(dlg.GetColor()),
RGBA_GETALPHA(cr));
UpdateData(FALSE);
}
}
void CPage_UIPanel::OnBtnBkColor()
{
// TODO: Add your control notification handler code here
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
UpdateData();
D3DCOLOR cr = CGsFunc::StringToColor((LPCSTR)m_str_bk_color);
m_str_bk_color.Format("%d,%d,%d,%d",
GetRValue(dlg.GetColor()),
GetGValue(dlg.GetColor()),
GetBValue(dlg.GetColor()),
RGBA_GETALPHA(cr));
UpdateData(FALSE);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?