📄 layout.cpp
字号:
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
#include "Layout.hpp"
#include "Common.hpp"
#include "Debug.hpp"
#include "resource.h"
const Layout_t::MetricsRCData_t* Layout_t::s_pMetrics = NULL;
HRESULT
Layout_t::InitializeRCData(
void
)
{
Layout_t::MetricsRCData_t* pMetrics;
HRESULT hr = CommonUtilities_t::InitializeRCDataHelper(
IDR_METRICS_DATA,
sizeof(Layout_t::MetricsRCData_t),
reinterpret_cast<void**>(&pMetrics)
);
s_pMetrics = pMetrics;
return hr;
}
#define HANDLE_METRIC(MetricName) \
int Layout_t::##MetricName(){\
return s_pMetrics->m_##MetricName;\
}
#define HANDLE_MARGINS(MetricName) \
int Layout_t::##MetricName##LeftMargin(){\
return s_pMetrics->m_##MetricName##Margins.m_LeftMargin;\
}\
int Layout_t::##MetricName##TopMargin(){\
return s_pMetrics->m_##MetricName##Margins.m_TopMargin;\
}\
int Layout_t::##MetricName##RightMargin(){\
return s_pMetrics->m_##MetricName##Margins.m_RightMargin;\
}\
int Layout_t::##MetricName##BottomMargin(){\
return s_pMetrics->m_##MetricName##Margins.m_BottomMargin;\
}
#define HANDLE_TILE_MARGINS(MetricName) \
int Layout_t::##MetricName##TileLeft(){\
return s_pMetrics->m_##MetricName##TileMargins.m_LeftMargin;\
}\
int Layout_t::##MetricName##TileTop(){\
return s_pMetrics->m_##MetricName##TileMargins.m_TopMargin;\
}\
int Layout_t::##MetricName##TileRight(){\
return s_pMetrics->m_##MetricName##TileMargins.m_RightMargin;\
}\
int Layout_t::##MetricName##TileBottom(){\
return s_pMetrics->m_##MetricName##TileMargins.m_BottomMargin;\
}
HANDLE_METRIC(ButtonWidth)
HANDLE_METRIC(ButtonHeight)
HANDLE_TILE_MARGINS(Button)
HANDLE_METRIC(ButtonConnectorLine)
HANDLE_METRIC(PopupItemWidth)
HANDLE_METRIC(PopupItemHeight)
HANDLE_METRIC(PopupTextMargin)
HANDLE_METRIC(PopupRightArrowTopMargin)
HANDLE_METRIC(PopupRightArrowRightMargin)
HANDLE_METRIC(PopupUpArrowTopMargin)
HANDLE_METRIC(PopupUpArrowRightMargin)
HANDLE_METRIC(MenuBarHeight)
HANDLE_METRIC(MenuBarTop)
HANDLE_METRIC(MenuBarRight)
HANDLE_METRIC(ListBoxDefaultItemHeight)
HANDLE_METRIC(LogoTopMargin)
HANDLE_METRIC(LogoRightMargin)
HANDLE_METRIC(DialogScreenTitleHeight)
HANDLE_MARGINS(DialogScreenTitle)
HANDLE_METRIC(DialogScreenTitleTextHorzMargin)
HANDLE_TILE_MARGINS(DialogScreenTitle)
HANDLE_METRIC(DialogScreenScrollArrowWidth)
HANDLE_METRIC(DialogScreenScrollArrowHeight)
HANDLE_MARGINS(DialogScreenScrollArrow)
HANDLE_METRIC(MessageBoxHeight)
HANDLE_METRIC(MessageBoxTextMargin)
HANDLE_METRIC(MessageBoxIconWidth)
HANDLE_METRIC(MessageBoxIconHeight)
HANDLE_METRIC(MessageBoxTitleHeight)
HANDLE_METRIC(MessageBoxTitleToDividerMargin)
HANDLE_METRIC(MessageBoxTitleToIconMargin)
HANDLE_METRIC(MessageBoxTitleToTextMargin)
HANDLE_METRIC(StatusHeaderTextMargin)
HANDLE_TILE_MARGINS(StatusHeader)
HANDLE_METRIC(ToolTipTextMargin)
HANDLE_METRIC(ToolTipItemDelta)
HANDLE_TILE_MARGINS(TrackbarThumb)
HANDLE_TILE_MARGINS(TrackbarChannel)
// Display Items
HANDLE_METRIC(TextItemHeight)
HANDLE_METRIC(TextItemHorzMargin)
HANDLE_METRIC(TextItemVerMargin)
HANDLE_METRIC(LabeledItemToControlMargin)
HANDLE_METRIC(LabeledItemHorzMargin)
HANDLE_METRIC(LabeledItemVerMargin)
const Colors_t::ColorsRCData_t* Colors_t::s_pColors = NULL;
HRESULT
Colors_t::InitializeRCData(
void
)
{
Colors_t::ColorsRCData_t* pColors;
HRESULT hr = CommonUtilities_t::InitializeRCDataHelper(
IDR_COLORS_DATA,
sizeof(Colors_t::ColorsRCData_t),
reinterpret_cast<void**>(&pColors)
);
s_pColors = pColors;
return hr;
}
#define HANDLE_COLOR(ColorName) \
int Colors_t::##ColorName(){\
return s_pColors->m_##ColorName;\
}
HANDLE_COLOR(DefaultTransparentColor)
HANDLE_COLOR(DefaultBackgroundColor)
HANDLE_COLOR(DefaultTextColor)
HANDLE_COLOR(GradientTopBackgroundColor)
HANDLE_COLOR(GradientBottomBackgroundColor)
HANDLE_COLOR(MenuButtonDownTextColor)
HANDLE_COLOR(MenuButtonUpTextColor)
HANDLE_COLOR(ButtonDownConnectorLineColor)
HANDLE_COLOR(ButtonUpConnectorLineColor)
HANDLE_COLOR(PopupMenuItemBackgroundColor)
HANDLE_COLOR(PopupMenuItemSelectedBackgroundColor)
HANDLE_COLOR(PopupMenuItemBorderColor)
HANDLE_COLOR(PopupMenuItemSelectedBorderColor)
HANDLE_COLOR(PopupMenuItemTextColor)
HANDLE_COLOR(PopupMenuItemSelectedTextColor)
HANDLE_COLOR(PopupMenuItemDisabledTextColor)
HANDLE_COLOR(DialogScreenTitleTextColor)
HANDLE_COLOR(ListBoxBackgroundColor)
HANDLE_COLOR(MessageBoxBackgroundColor)
HANDLE_COLOR(MessageBoxTextColor)
HANDLE_COLOR(MessageBoxTitleColor)
HANDLE_COLOR(MessageBoxBorderColor)
HANDLE_COLOR(MessageBoxDividerLineColor)
HANDLE_COLOR(ToolTipBackgroundColor)
HANDLE_COLOR(ToolTipTextColor)
HANDLE_COLOR(DisplayItemBackgroundColor)
HANDLE_COLOR(DisplayItemSelectedBackgroundColor)
HANDLE_COLOR(DisplayItemTextColor)
HANDLE_COLOR(DisplayItemSelectedTextColor)
HANDLE_COLOR(DisplayItemBorderColor)
HANDLE_COLOR(DisplayItemSelectedBorderColor)
/*------------------------------------------------------------------------------
PHGetColor
Exposed through phcommon API.
Retrieves the specified color from the resources
Parameters:
PH_COLOR: Color identifier
Returns (COLORREF): CLR_INVALID indicates failure
------------------------------------------------------------------------------*/
EXTERN_C
COLORREF
WINAPI
PHGetColor(
PH_COLOR Id
)
{
switch (Id)
{
case phcDefaultTransparentColor:
return Colors_t::DefaultTransparentColor();
case phcDefaultBackgroundColor:
return Colors_t::DefaultBackgroundColor();
case phcDefaultTextColor:
return Colors_t::DefaultTextColor();
case phcDisplayItemBackgroundColor:
return Colors_t::DisplayItemBackgroundColor();
case phcDisplayItemSelectedBackgroundColor:
return Colors_t::DisplayItemSelectedBackgroundColor();
case phcDisplayItemTextColor:
return Colors_t::DisplayItemTextColor();
case phcDisplayItemSelectedTextColor:
return Colors_t::DisplayItemSelectedTextColor();
case phcDisplayItemBorderColor:
return Colors_t::DisplayItemBorderColor();
case phcDisplayItemSelectedBorderColor:
return Colors_t::DisplayItemSelectedBorderColor();
}
return CLR_INVALID;
}
const Fonts_t::FontsRCData_t* Fonts_t::s_pFonts = NULL;
HRESULT
Fonts_t::InitializeRCData(
void
)
{
Fonts_t::FontsRCData_t* pFonts;
HRESULT hr = CommonUtilities_t::InitializeRCDataHelper(
IDR_FONTS_DATA,
sizeof(Fonts_t::FontsRCData_t),
reinterpret_cast<void**>(&pFonts)
);
s_pFonts = pFonts;
return hr;
}
#define HANDLE_FONT(FontName) \
HFONT Fonts_t::##FontName(){\
return GlobalData_t::s_GDICacheObject.LoadCachedFont(\
reinterpret_cast<UINT>(&s_pFonts->m_##FontName),\
s_pFonts->m_##FontName.m_FontNameId,\
s_pFonts->m_##FontName.m_Height,\
s_pFonts->m_##FontName.m_Weight\
);\
}
HANDLE_FONT(StandardText)
HANDLE_FONT(StandardTextBold)
HANDLE_FONT(InformationText)
HANDLE_FONT(LargeText)
HANDLE_FONT(BigNumbersText)
/*------------------------------------------------------------------------------
PHGetFont
Exposed through phcommon API.
Retrieves the specified font from GDI cache (creates the font if needed)
Parameters:
PH_FONT: Font identifier
Returns (HFONT): NULL indicates failure
------------------------------------------------------------------------------*/
EXTERN_C
HFONT
WINAPI
PHGetFont(
PH_FONT Id
)
{
typedef HFONT (*PFN_FONT)(void);
static const PFN_FONT sc_ExposedFonts[] =
{
Fonts_t::StandardText,
Fonts_t::StandardTextBold,
Fonts_t::InformationText,
Fonts_t::LargeText,
Fonts_t::BigNumbersText,
};
if (Id < _countof(sc_ExposedFonts))
{
ASSERT(Id < phfLast);
return sc_ExposedFonts[Id]();
}
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -