本文整理汇总了C++中PixelRect::GetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelRect::GetSize方法的具体用法?C++ PixelRect::GetSize怎么用?C++ PixelRect::GetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelRect
的用法示例。
在下文中一共展示了PixelRect::GetSize方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetButtonPosition
PixelRect GetButtonPosition(unsigned MenuID, const PixelRect& rcScreen) {
PixelRect rc = rcScreen;
rc.Grow(-1); // remove Margin
unsigned i = MenuID - 1;
assert(i < MenuButtons.size());
const PixelScalar row = ScreenLandscape ? LandscapeLayout[i].row : PortraitLayout[i].row;
const PixelScalar col = ScreenLandscape ? LandscapeLayout[i].col :PortraitLayout[i].col;
const PixelScalar nbRow = ScreenLandscape ? 5 : 7;
const PixelScalar nbCol = ScreenLandscape ? 5 : 4;
const PixelSize size = {
std::min<PixelScalar>((rc.GetSize().cx-(nbCol-1))/nbCol, NIBLSCALE(80)),
std::min<PixelScalar>((rc.GetSize().cy-nbRow-1)/nbRow, NIBLSCALE(40))
};
const double x_interval = (rc.GetSize().cx - size.cx * nbCol) / (nbCol-1);
const double y_interval = (rc.GetSize().cy - size.cy * nbRow) / (nbRow-1);
const RasterPoint origin = {
rc.left + (PixelScalar)(col * (size.cx + x_interval)),
rc.top + (PixelScalar)(row * (size.cy + y_interval))
};
return PixelRect(origin, size);
}
示例2: GetParentClientRect
void
WidgetDialog::AutoSize()
{
const PixelRect parent_rc = GetParentClientRect();
const PixelSize parent_size = parent_rc.GetSize();
widget.Prepare();
PixelSize min_size = widget.Get()->GetMinimumSize();
min_size.cy += GetTitleHeight();
PixelSize max_size = widget.Get()->GetMaximumSize();
max_size.cy += GetTitleHeight();
const PixelScalar min_height_with_buttons =
min_size.cy + Layout::GetMaximumControlHeight();
const PixelScalar max_height_with_buttons =
max_size.cy + Layout::GetMaximumControlHeight();
if (/* need full dialog height even for minimum widget height? */
min_height_with_buttons >= parent_size.cy ||
/* try to avoid putting buttons left on portrait screens; try to
comply with maximum widget height only on landscape
screens */
(parent_size.cx > parent_size.cy &&
max_height_with_buttons >= parent_size.cy)) {
/* need full height, buttons must be left */
PixelRect rc = parent_rc;
if (max_size.cy < parent_size.cy)
rc.bottom = rc.top + max_size.cy;
PixelRect remaining = buttons.LeftLayout(rc);
PixelSize remaining_size = remaining.GetSize();
if (remaining_size.cx > max_size.cx)
rc.right -= remaining_size.cx - max_size.cx;
Move(rc);
widget.Move(buttons.LeftLayout());
return;
}
/* see if buttons fit at the bottom */
PixelRect rc = parent_rc;
if (max_size.cx < parent_size.cx)
rc.right = rc.left + max_size.cx;
PixelRect remaining = buttons.BottomLayout(rc);
PixelSize remaining_size = remaining.GetSize();
if (remaining_size.cy > max_size.cy)
rc.bottom -= remaining_size.cy - max_size.cy;
Move(rc);
widget.Move(buttons.BottomLayout());
}
示例3:
void
KeyboardWidget::PrepareSize(const PixelRect &rc)
{
const PixelSize new_size = rc.GetSize();
button_width = new_size.cx / 10;
button_height = new_size.cy / 5;
}
示例4: assert
void
Window::Create(ContainerWindow *parent, PixelRect rc,
const WindowStyle window_style)
{
assert(IsScreenInitialized());
assert(rc.left <= rc.right);
assert(rc.right - rc.left < 0x8000);
assert(rc.top <= rc.bottom);
assert(rc.bottom - rc.top < 0x8000);
double_clicks = window_style.double_clicks;
this->parent = parent;
position = rc.GetOrigin();
size = rc.GetSize();
tab_stop = window_style.tab_stop;
control_parent = window_style.control_parent;
visible = window_style.visible;
enabled = window_style.enabled;
has_border = window_style.has_border;
text_style = window_style.text_style;
if (parent != NULL)
parent->AddChild(*this);
OnCreate();
OnResize(size);
}
示例5: RasterPoint
static void
Draw(Canvas &canvas)
{
PixelRect rc = canvas.GetRect();
rc.Grow(-0.2 * rc.GetSize().cx);
/* draw the banner text with a large font */
Font small_font;
small_font.LoadFile("/opt/LK8000/share/fonts/DejaVuSansCondensed.ttf", (rc.GetSize().cy / 25));
canvas.Select(small_font);
canvas.SetTextColor(COLOR_BLACK);
canvas.SetBackgroundTransparent();
const TCHAR *const text = _T("Powered Off");
const PixelSize text_size = canvas.CalcTextSize(text);
const RasterPoint text_pos = {
rc.left + 16,
rc.bottom - 16 - text_size.cy
};
canvas.DrawText(text_pos.x, text_pos.y, text);
Font big_font;
big_font.LoadFile("/opt/LK8000/share/fonts/DejaVuSansCondensed-Bold.ttf", (rc.GetSize().cy / 10));
canvas.Select(big_font);
const TCHAR *const text2 = _T("LK8000");
const PixelSize text2_size = canvas.CalcTextSize(text2);
const RasterPoint text2_pos = {
(rc.left + rc.GetSize().cx + text2_size.cx) / 2,
(rc.top + (rc.GetSize().cy / 10))
};
canvas.DrawText(text2_pos.x, text2_pos.y, text2);
const double Scale = (double)rc.GetSize().cx / (double)bird_size.cx;
RasterPoint polygon[array_size(bird_polygon)] = {};
std::transform(std::begin(bird_polygon), std::end(bird_polygon), std::begin(polygon), [Scale, rc, text2_size, text2_pos]( const RasterPoint& pt ) {
return RasterPoint(pt.x*Scale + rc.left, pt.y*Scale + text2_pos.y + text2_size.cy);
});
canvas.SelectBlackBrush();
canvas.DrawPolygon(polygon, array_size(polygon));
}
示例6: ResizeButtons
void
KeyboardWidget::OnResize(const PixelRect &rc)
{
const PixelSize new_size = rc.GetSize();
button_width = new_size.cx / 10;
button_height = new_size.cy / 5;
ResizeButtons();
MoveButtons(rc);
}
示例7: ValidateGeometry
InfoBoxLayout::Layout
InfoBoxLayout::Calculate(PixelRect rc, InfoBoxSettings::Geometry geometry)
{
const PixelSize screen_size = rc.GetSize();
geometry = ValidateGeometry(geometry, screen_size);
Layout layout;
layout.geometry = geometry;
layout.landscape = screen_size.cx > screen_size.cy;
layout.count = geometry_counts[(unsigned)geometry];
assert(layout.count <= InfoBoxSettings::Panel::MAX_CONTENTS);
CalcInfoBoxSizes(layout, screen_size, geometry);
layout.ClearVario();
unsigned right = rc.right;
switch (geometry) {
case InfoBoxSettings::Geometry::SPLIT_8:
case InfoBoxSettings::Geometry::OBSOLETE_SPLIT_8:
if (layout.landscape) {
rc.left = MakeLeftColumn(layout, layout.positions, 4,
rc.left, rc.top, rc.bottom);
rc.right = MakeRightColumn(layout, layout.positions + 4, 4,
rc.right, rc.top, rc.bottom);
} else {
rc.top = MakeTopRow(layout, layout.positions, 4,
rc.left, rc.right, rc.top);
rc.bottom = MakeBottomRow(layout, layout.positions + 4, 4,
rc.left, rc.right, rc.bottom);
}
break;
case InfoBoxSettings::Geometry::BOTTOM_8_VARIO:
layout.vario.left = rc.right - layout.control_size.cx;
layout.vario.right = rc.right;
layout.vario.top = rc.bottom - layout.control_size.cy * 2;
layout.vario.bottom = rc.bottom;
right = layout.vario.left;
/* fall through */
case InfoBoxSettings::Geometry::BOTTOM_RIGHT_8:
case InfoBoxSettings::Geometry::OBSOLETE_BOTTOM_RIGHT_8:
if (layout.landscape) {
rc.right = MakeRightColumn(layout, layout.positions + 4, 4,
rc.right, rc.top, rc.bottom);
rc.right = MakeRightColumn(layout, layout.positions, 4,
rc.right, rc.top, rc.bottom);
} else {
rc.bottom = MakeBottomRow(layout, layout.positions + 4, 4,
rc.left, right, rc.bottom);
rc.bottom = MakeBottomRow(layout, layout.positions, 4,
rc.left, right, rc.bottom);
}
break;
case InfoBoxSettings::Geometry::TOP_8_VARIO:
layout.vario.left = rc.right - layout.control_size.cx;
layout.vario.right = rc.right;
layout.vario.top = rc.top;
layout.vario.bottom = rc.top + layout.control_size.cy * 2;
right = layout.vario.left;
/* fall through */
case InfoBoxSettings::Geometry::TOP_LEFT_8:
case InfoBoxSettings::Geometry::OBSOLETE_TOP_LEFT_8:
if (layout.landscape) {
rc.left = MakeLeftColumn(layout, layout.positions, 4,
rc.left, rc.top, rc.bottom);
rc.left = MakeLeftColumn(layout, layout.positions + 4, 4,
rc.left, rc.top, rc.bottom);
} else {
rc.top = MakeTopRow(layout, layout.positions, 4,
rc.left, right, rc.top);
rc.top = MakeTopRow(layout, layout.positions + 4, 4,
rc.left, right, rc.top);
}
break;
case InfoBoxSettings::Geometry::LEFT_6_RIGHT_3_VARIO:
layout.vario.left = rc.right - layout.control_size.cx;
layout.vario.right = rc.right;
layout.vario.top = 0;
layout.vario.bottom = layout.vario.top + layout.control_size.cy * 3;
rc.left = MakeLeftColumn(layout, layout.positions, 6,
rc.left, rc.top, rc.bottom);
rc.right = MakeRightColumn(layout, layout.positions + 6, 3, rc.right,
rc.top + 3 * layout.control_size.cy, rc.bottom);
break;
//.........这里部分代码省略.........
示例8: OnTaskPaintListItem
static void OnTaskPaintListItem(WindowControl * Sender, LKSurface& Surface){
int n = UpLimit - LowLimit;
TCHAR sTmp[120];
TCHAR wpName[120];
TCHAR landableStr[5] = TEXT(" [X]");
// LKTOKEN [email protected]_ "L"
landableStr[2] = MsgToken(1238)[0];
LockTaskData();
const PixelRect rcClient(Sender->GetClientRect());
const int w0 = rcClient.GetSize().cx - DLGSCALE(1);
const int w1 = Surface.GetTextWidth(TEXT(" 000km"));
_stprintf(sTmp, _T(" 000%s"), MsgToken(2179));
const int w2 = Surface.GetTextWidth(sTmp);
const int TextMargin = (rcClient.GetSize().cy - Surface.GetTextHeight(TEXT("A"))) / 2;
const int p1 = w0-w1-w2- rcClient.GetSize().cy - DLGSCALE(2);
const int p2 = w0-w2- rcClient.GetSize().cy - DLGSCALE(2);
const PixelRect rc = {
0,
0,
rcClient.GetSize().cy,
rcClient.GetSize().cy
};
if (DrawListIndex < n){
int i = LowLimit + DrawListIndex;
// if ((WayPointList[Task[i].Index].Flags & LANDPOINT) >0)
// MapWindow::DrawRunway(hDC, &WayPointList[Task[i].Index], rc, 3000,true);
MapWindow::DrawTaskPicto(Surface, DrawListIndex, rc, 2500);
if (Task[i].Index>=0) {
_stprintf(wpName, TEXT("%s%s"),
WayPointList[Task[i].Index].Name,
(WayPointList[Task[i].Index].Flags & LANDPOINT) ? landableStr : TEXT(""));
if (AATEnabled && ValidTaskPoint(i+1) && (i>0)) {
if (Task[i].AATType==0 || Task[i].AATType==3) {
_stprintf(sTmp, TEXT("%s %.1f"),
wpName, Task[i].AATCircleRadius*DISTANCEMODIFY);
} else {
if(Task[i].AATType==2 && DoOptimizeRoute()) {
_stprintf(sTmp, TEXT("%s %.1f/1"),
wpName, Task[i].PGConeSlope);
} else {
_stprintf(sTmp, TEXT("%s %.1f"),
wpName, Task[i].AATSectorRadius*DISTANCEMODIFY);
}
}
} else {
_stprintf(sTmp, TEXT("%s"), wpName);
}
Surface.SetBackgroundTransparent();
Surface.SetTextColor(RGB_BLACK);
Surface.DrawTextClip(rc.right + DLGSCALE(2), TextMargin, sTmp, p1-DLGSCALE(4));
_stprintf(sTmp, TEXT("%.0f %s"),Task[i].Leg*DISTANCEMODIFY,Units::GetDistanceName());
Surface.DrawText(rc.right+p1+w1-Surface.GetTextWidth(sTmp), TextMargin, sTmp);
_stprintf(sTmp, TEXT("%d%s"), iround(Task[i].InBound),MsgToken(2179));
Surface.DrawText(rc.right +p2+w2-Surface.GetTextWidth(sTmp), TextMargin, sTmp);
}
} else {
Surface.SetTextColor(RGB_BLACK);
// if (DrawListIndex==n) { // patchout 091126
if (DrawListIndex==n && UpLimit < MAXTASKPOINTS) { // patch 091126
// LKTOKEN [email protected]_ = "add waypoint"
_stprintf(sTmp, TEXT(" (%s)"), MsgToken(832));
Surface.DrawText(rc.right +DLGSCALE(2), TextMargin, sTmp);
} else if ((DrawListIndex==n+1) && ValidTaskPoint(0)) {
if (!AATEnabled || ISPARAGLIDER) {
// LKTOKEN [email protected]_ = "Total:"
Surface.DrawText(rc.right +DLGSCALE(2), TextMargin, MsgToken(735));
_stprintf(sTmp, TEXT("%.0f %s%s"), lengthtotal*DISTANCEMODIFY, Units::GetDistanceName(), fai_ok?_T(" FAI"):_T(""));
Surface.DrawText(rc.right +p1+w1-Surface.GetTextWidth(sTmp), TextMargin, sTmp);
} else {
double d1 = CALCULATED_INFO.TaskDistanceToGo;
if ((CALCULATED_INFO.TaskStartTime>0.0) && (CALCULATED_INFO.Flying) && (ActiveTaskPoint>0)) {
d1 += CALCULATED_INFO.TaskDistanceCovered;
}
if (d1==0.0) {
d1 = CALCULATED_INFO.AATTargetDistance;
}
_stprintf(sTmp, TEXT("%s %.0f min %.0f (%.0f) %s"),
// LKTOKEN [email protected]_ = "Total:"
//.........这里部分代码省略.........
示例9: InitInstance
//
// FUNCTION: InitInstance()
//
// PURPOSE: creates main window
//
// COMMENTS:
//
// In this function, we create and display the main program window.
//
BOOL InitInstance()
{
extern bool CommandResolution;
if(!IsEmbedded() && !CommandResolution) {
ScreenSizeX = 800;
ScreenSizeY = 480;
}
#if defined(ENABLE_SDL) && defined(USE_FULLSCREEN)
#if (SDL_MAJOR_VERSION >= 2)
SDL_DisplayMode mode = {};
if(SDL_GetCurrentDisplayMode(0, &mode) == 0) {
ScreenSizeX = mode.w;
ScreenSizeY = mode.h;
} else {
fprintf(stderr, "SDL_GetCurrentDisplayMode() has failed: %s\n", ::SDL_GetError());
}
#else
ScreenSizeX = 0;
ScreenSizeY = 0;
#endif
#endif
PreloadInitialisation(true);
RECT WindowSize;
#ifdef __linux__
WindowSize=WindowResize(ScreenSizeX, ScreenSizeY);
#endif
#ifdef WIN32
#ifdef UNDER_CE
WindowSize=WindowResize( GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
#else
WindowSize=WindowResize(ScreenSizeX, ScreenSizeY);
#endif
#endif
if (!goInstallSystem) Poco::Thread::sleep(50); // 091119
#if TESTBENCH
StartupStore(TEXT(". Create main window%s"),NEWLINE);
#endif
if(!MainWindow.Create(WindowSize)) {
StartupStore(TEXT(". FAILURE: Create main window%s"),NEWLINE);
return FALSE;
}
const PixelRect rc(MainWindow.GetClientRect());
ScreenSizeX = rc.GetSize().cx;
ScreenSizeY = rc.GetSize().cy;
InitLKScreen();
InitLKFonts(); // causing problems with CreateButtonLabels?
LKLoadFixedBitmaps();
LKLoadProfileBitmaps();
LKObjects_Create();
ButtonLabel::CreateButtonLabels(rc);
ButtonLabel::SetLabelText(0,TEXT("MODE"));
extern void InitLKFonts();
// reload updating LK fonts after loading profile for fontquality
InitLKFonts();
ButtonLabel::SetFont(MapWindowBoldFont);
Message::Initialize(rc); // creates window, sets fonts
MainWindow.SetVisible(true);
return TRUE;
}
示例10: InitInstance
//
// FUNCTION: InitInstance()
//
// PURPOSE: creates main window
//
// COMMENTS:
//
// In this function, we create and display the main program window.
//
BOOL InitInstance()
{
extern bool CommandResolution;
if(!IsEmbedded() && !CommandResolution) {
ScreenSizeX = 800;
ScreenSizeY = 480;
}
#if defined(ENABLE_SDL) && defined(USE_FULLSCREEN)
#if (SDL_MAJOR_VERSION >= 2)
SDL_DisplayMode mode = {};
if(SDL_GetCurrentDisplayMode(0, &mode) == 0) {
ScreenSizeX = mode.w;
ScreenSizeY = mode.h;
} else {
fprintf(stderr, "SDL_GetCurrentDisplayMode() has failed: %s\n", ::SDL_GetError());
}
#else
ScreenSizeX = 0;
ScreenSizeY = 0;
#endif
#endif
PreloadInitialisation(true);
RECT WindowSize;
#ifdef __linux__
#ifdef USE_VIDEOCORE
uint32_t iWidth, iHeight;
if(graphics_get_display_size(0, &iWidth, &iHeight) >= 0) {
ScreenSizeX=iWidth;
ScreenSizeY=iHeight;
}
#endif
#ifdef ANDROID
const PixelSize Size = native_view->GetSize();
ScreenSizeX=Size.cx;
ScreenSizeY=Size.cy;
#endif
WindowSize=WindowResize(ScreenSizeX, ScreenSizeY);
#endif
#ifdef WIN32
#if defined(UNDER_CE) || defined(USE_FULLSCREEN)
WindowSize=WindowResize( GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
#else
WindowSize=WindowResize(ScreenSizeX, ScreenSizeY);
#endif
#endif
#if TESTBENCH
StartupStore(TEXT(". Create main window%s"),NEWLINE);
#endif
if(!MainWindow.Create(WindowSize)) {
StartupStore(TEXT(". FAILURE: Create main window%s"),NEWLINE);
return FALSE;
}
const PixelRect rc(MainWindow.GetClientRect());
ScreenSizeX = rc.GetSize().cx;
ScreenSizeY = rc.GetSize().cy;
ScreenHasChanged();
InitLKScreen();
InitLKFonts(); // causing problems with CreateButtonLabels?
LKLoadFixedBitmaps();
LKLoadProfileBitmaps();
LKObjects_Create();
ButtonLabel::CreateButtonLabels(rc);
ButtonLabel::SetFont(MapWindowBoldFont);
Message::Initialize(rc); // creates window, sets fonts
MainWindow.SetVisible(true);
return TRUE;
}