本文整理汇总了C++中TGadget::GetBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ TGadget::GetBounds方法的具体用法?C++ TGadget::GetBounds怎么用?C++ TGadget::GetBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGadget
的用法示例。
在下文中一共展示了TGadget::GetBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//
/// Called by Paint to repaint all of the gadgets, PaintGadgets iterates through the
/// list of gadgets, determines the gadget's area, and repaints each gadget.
///
/// You can override this function to implement a specific look (for example,
/// separator line, raised, and so on).
//
void
TGadgetWindow::PaintGadgets(TDC& dc, bool, TRect& rect)
{
TPoint viewport = dc.GetViewportOrg();
for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) {
if (gadget->GetBounds().Touches(rect)) {
dc.SetViewportOrg((TPoint&)gadget->GetBounds());
// If the gadget is a sloppy painter & needs clipping support, set the
// clip rect before painting, otherwise just paint. Most gadgets don't
// need this help
//
if (gadget->Clip) {
TRegion savedClipRgn;
dc.GetClipRgn(savedClipRgn);
dc.IntersectClipRect(gadget->GetBounds());
gadget->Paint(dc);
dc.SelectClipRgn(savedClipRgn);
}
else
gadget->Paint(dc);
}
}
dc.SetViewportOrg(viewport);
}
示例2: p
//
/// Pass RButton messages to the gadget at the mouse location or the one with
/// capture.
///
/// \note The default right-mouse down handler of TGadget does
/// *NOT* set capture
//
void
TGadgetWindow::EvRButtonUp(uint modKeys, const TPoint& point)
{
TGadget* gadget = Capture ? Capture : GadgetFromPoint(point);
if (gadget && (gadget->GetEnabled() || Capture)){
TPoint p(point.x - gadget->GetBounds().left, point.y - gadget->GetBounds().top);
gadget->RButtonUp(modKeys, p);
}
TWindow::EvRButtonUp(modKeys, point);
}
示例3: GadgetFromPoint
//
/// Pass RButton messages to the gadget at the mouse location or the one
/// with Capture
///
/// \note The default right-mouse down handler of TGadget does
/// *NOT* set capture
//
void
TGadgetWindow::EvRButtonDown(uint modKeys, const TPoint& point)
{
TGadget* gadget = Capture ? Capture : GadgetFromPoint(point);
if (gadget && (gadget->GetEnabled() || Capture)) {
TPoint gadgetPoint = point - *(TSize*)&gadget->GetBounds().TopLeft();
gadget->RButtonDown(modKeys, gadgetPoint);
}
TWindow::EvRButtonDown(modKeys, point);
}
示例4: GadgetReleaseCapture
//
/// This indicates that a gadget has been removed from this gadget window.
//
void
TGadgetWindow::Removed(TGadget& gadget)
{
// Re-adjust gadget now that it doesn't live in a window
//
if (gadget.WideAsPossible)
WideAsPossible--;
// Clear last know gadget as mouse location
//
if (&gadget == AtMouse)
AtMouse = 0;
// Release caption if it has/had it
//
GadgetReleaseCapture(gadget);
// Notify gadget and reset/adjust variables to reflect new state of gadget
//
gadget.Removed();
gadget.Window = 0;
gadget.Next = 0;
gadget.GetBounds() -= gadget.GetBounds().TopLeft();
}
示例5: bounds
//
/// Tiles the gadgets in the direction requested (horizontal or vertical). Derived
/// classes can adjust the spacing between gadgets.
///
/// Horizontal direction results in a row-major layout,
/// and vertical direction results in column-major layout
//
TRect
TToolBox::TileGadgets()
{
TSize cellSize;
ComputeCellSize(cellSize);
int numRows, numColumns;
ComputeNumRowsColumns(numRows, numColumns);
TRect innerRect;
GetInnerRect(innerRect);
TRect invalidRect;
invalidRect.SetEmpty();
if (Direction == Horizontal) {
// Row Major
//
int y = innerRect.top;
TGadget* g = Gadgets;
for (int r = 0; r < numRows; r++) {
int x = innerRect.left;
for (int c = 0; c < numColumns && g; c++) {
TRect bounds(TPoint(x, y), cellSize);
TRect originalBounds(g->GetBounds());
if (bounds != g->GetBounds()) {
g->SetBounds(bounds);
if (invalidRect.IsNull())
invalidRect = bounds;
else
invalidRect |= bounds;
if (originalBounds.TopLeft() != TPoint(0, 0))
invalidRect |= originalBounds;
}
x += cellSize.cx;
g = g->NextGadget();
}
y += cellSize.cy;
}
}
else {
// Column Major
//
int x = innerRect.left;
TGadget* g = Gadgets;
for (int c = 0; c < numColumns; c++) {
int y = innerRect.top;
for (int r = 0; r < numRows && g; r++) {
TRect bounds(TPoint(x, y), cellSize);
TRect originalBounds(g->GetBounds());
if (bounds != originalBounds) {
g->SetBounds(bounds);
if (invalidRect.IsNull())
invalidRect = bounds;
else
invalidRect |= bounds;
if (originalBounds.TopLeft() != TPoint(0, 0))
invalidRect |= originalBounds;
}
y += cellSize.cy;
g = g->NextGadget();
}
x += cellSize.cx;
}
}
return invalidRect;
}
示例6: 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;
}
//.........这里部分代码省略.........
示例7: 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);
}
}
示例8: IsThemeBackgroundEnabled
//.........这里部分代码省略.........
//
/// Virtual called by TileGadgets() for each gadget in order to give derived
/// classes a chance to modify the gadget positioning. Default is to overlap
/// adjacent plain-bordered gadgets
//
void
TGadgetWindow::PositionGadget(TGadget* previous, TGadget* next, TPoint& origin)
{
// Overlap the button borders
// !CQ make sure this is right for win95. Also in regular controlbar
//
if (previous->GetBorderStyle() == TGadget::Plain &&
next->GetBorderStyle() == TGadget::Plain)
if (Direction == Horizontal)
origin.x -= TUIMetric::CxBorder;
else
origin.y -= TUIMetric::CyBorder;
}
//
/// Tiles the gadgets in the direction requested (horizontal or vertical). Calls
/// PositionGadget() to give derived classes an opportunity to adjust the spacing
/// between gadgets in their windows.
//
TRect
TGadgetWindow::TileGadgets()
{
TLayoutInfo layout(NumGadgets);
LayoutGadgets(Direction, layout);
TRect invalidRect(0,0,0,0);
int i = 0;
for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
TRect originalBounds = gadget->GetBounds();
TRect bounds = layout.GadgetBounds[i];
if (originalBounds != bounds) {
gadget->SetBounds(bounds);
if (originalBounds.TopLeft() != TPoint(0, 0))
invalidRect |= originalBounds;
invalidRect |= bounds;
}
}
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
//