本文整理汇总了C++中TGadget::GetDesiredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ TGadget::GetDesiredSize方法的具体用法?C++ TGadget::GetDesiredSize怎么用?C++ TGadget::GetDesiredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGadget
的用法示例。
在下文中一共展示了TGadget::GetDesiredSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: desiredSize
//
// Compute the cell size which is determined by the widest and the highest
// gadget
//
void
TToolBox::ComputeCellSize(TSize& cellSize)
{
cellSize.cx = cellSize.cy = 0;
for (TGadget* g = Gadgets; g; g = g->NextGadget()) {
TSize desiredSize(0, 0);
g->GetDesiredSize(desiredSize);
if (desiredSize.cx > cellSize.cx)
cellSize.cx = desiredSize.cx;
if (desiredSize.cy > cellSize.cy)
cellSize.cy = desiredSize.cy;
}
}
示例2: desiredSize
//
/// Helper for LayoutGadgets() to calculate vertical tiling
//
void
TGadgetWindow::LayoutVertically(TLayoutInfo& layout)
{
TRect innerRect;
GetInnerRect(innerRect);
int leftM, rightM, topM, bottomM;
GetMargins(Margins, leftM, rightM, topM, bottomM);
layout.DesiredSize = TSize(0,0);
layout.GadgetBounds = new TRect[NumGadgets];
// Now tile all the gadgets
//
int y = topM;
int x = leftM;
int w = 0;
int i = 0;
// Pass 1: calculate gadget sizes and column width
//
TGadget* gadget;
for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
TSize desiredSize(0, 0);
gadget->GetDesiredSize(desiredSize);
// Stash away the DesiredSize for the next pass
//
layout.GadgetBounds[i].left = desiredSize.cx;
layout.GadgetBounds[i].top = desiredSize.cy;
w = std::max(w, (int)desiredSize.cx);
}
// Pass 2: place the gadget in the column, centered horizontally
//
i = 0;
for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
TRect bounds = gadget->GetBounds();
// Recover desired size from where we stashed it
//
TSize desiredSize(layout.GadgetBounds[i].left, layout.GadgetBounds[i].top);
bounds.top = y;
bounds.bottom = bounds.top + desiredSize.cy;
bounds.left = x + (w - desiredSize.cx) / 2; // Center horizontally
bounds.right = bounds.left + desiredSize.cx;
layout.GadgetBounds[i] = bounds;
y += bounds.Height();
if (gadget->Next) {
TPoint origin(0, y);
PositionGadget(gadget, gadget->Next, origin);
y = origin.y;
}
// Update gadget window's desired size
//
layout.DesiredSize.cx = (int)std::max(int(bounds.right+rightM), (int)layout.DesiredSize.cx);
layout.DesiredSize.cy = (int)std::max(int(bounds.bottom+bottomM), (int)layout.DesiredSize.cy);
}
}
示例3: if
//
/// Helper for LayoutGadgets() to calculate rectangular 2D tiling
//
void
TGadgetWindow::LayoutRectangularly(TLayoutInfo& layout)
{
TRect innerRect;
GetInnerRect(innerRect);
layout.DesiredSize = TSize(0,0);
layout.GadgetBounds = new TRect[NumGadgets];
// !CQ memset((void*)layout.GadgetBounds, 0, sizeof(TRect) * NumGadgets);// Debugging code
int leftM, rightM, topM, bottomM;
GetMargins(Margins, leftM, rightM, topM, bottomM);
// Now tile all the gadgets. Assume no wide-as-possibles.
//
int x = leftM;
int y = topM;
int right = RowWidth - rightM; // Base right margin limit on RowWidth
// If any controls are wider than right margin, push out the right margin.
//
TGadget* gadget;
for (gadget = Gadgets; gadget; gadget = gadget->Next) {
TSize desiredSize;
gadget->GetDesiredSize(desiredSize);
// SIR June 20th 2007 max instead of ::max
right = max(right, (int)(x + desiredSize.cx + rightM));
}
// Scan gadgets, positioning & placing all of the EndOfRow flags
//
TGadget* rowStart; // Tracks the first gadget in the row
TGadget* lastBreak; // Tracks the last gadget in the row
bool contRow = false; // Working on a group continuation row
bool contBreak = false; // Finished group on continuation row
int i = 0;
int istart = 0;
int iend = 0; // Tracks the last visible gadget in the row
int ibreak = 0;
int rowHeight;
rowStart = Gadgets;
lastBreak = Gadgets;
for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
gadget->SetEndOfRow(false);
// !CQ ignore wide-as-possible gadget requests
//
TSize desiredSize;
gadget->GetDesiredSize(desiredSize);
TRect bounds = gadget->GetBounds();
// Do the horizontal layout of this control
//
bounds.left = x;
bounds.right = bounds.left + desiredSize.cx;
// Store gadget's height in bottom, so we can calculate the row height
// later
//
bounds.top = 0;
bounds.bottom = desiredSize.cy;
// If too big or a new group on a group continue row, (& is not the first
// & is visible) then back up to iend & reset to lastBreak+1
//
if ((bounds.right > right || contBreak) &&
gadget != rowStart && gadget->IsVisible()) {
lastBreak->SetEndOfRow(true);
// Update gadget window's desired size
//
layout.DesiredSize.cx =
std::max((layout.GadgetBounds[iend].right+rightM), layout.DesiredSize.cx);
// Do the vertical layout of this row
//
FinishRow(istart, rowStart, lastBreak, y, layout, rowHeight);
contRow = lastBreak->IsVisible(); // Next row is a group continuation
x = leftM;
y += rowHeight;
if (!contRow)
y += RowMargin;
gadget = lastBreak; // will get bumped to Next by for incr
i = ibreak; // so will this
rowStart = lastBreak = gadget->Next; // Begin next row
istart = i+1;
contBreak = false;
continue;
}
//.........这里部分代码省略.........
示例4: IsThemeBackgroundEnabled
//.........这里部分代码省略.........
}
}
DirtyLayout = false;
return invalidRect;
}
//
/// Helper for LayoutGadgets() to calculate horizontal tiling
//
void
TGadgetWindow::LayoutHorizontally(TLayoutInfo& layout)
{
TRect innerRect;
GetInnerRect(innerRect);
int leftM, rightM, topM, bottomM;
GetMargins(Margins, leftM, rightM, topM, bottomM);
layout.DesiredSize = TSize(0,0);
layout.GadgetBounds = new TRect[NumGadgets];
// First pass tally the width of all gadgets that don't have "WideAsPossible"
// set if any have it seet so that we can divide up the extra width
//
// NOTE: we must also take into account any adjustments to the gadget spacing
//
int wideAsPossibleWidth;
if (WideAsPossible) {
int width = 0;
for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) {
if (!gadget->WideAsPossible) {
TSize desiredSize(0, 0);
gadget->GetDesiredSize(desiredSize);
width += desiredSize.cx;
}
if (gadget->Next) {
TPoint spacing(0, 0);
PositionGadget(gadget, gadget->Next, spacing);
width += spacing.x;
}
}
wideAsPossibleWidth = std::max(( (innerRect.Width() - width) / (int)WideAsPossible ), 0);
}
else
wideAsPossibleWidth = 0;
// Now tile all the gadgets
//
int x = leftM;
int y = topM;
int h = 0;
int i = 0;
// Pass 1: calculate the gadget sizes and row height
//
TGadget* gadget;
for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
TSize desiredSize(0, 0);
gadget->GetDesiredSize(desiredSize);
// Stash away the desiredSize for the next pass
//