* Added layout-friendly constructor.

* Fixed invalidation in FrameResized().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21427 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2007-06-17 01:17:49 +00:00
parent 4fa167e12d
commit 8000c5e973
2 changed files with 38 additions and 10 deletions

View File

@ -36,12 +36,15 @@ class BMenuField;
class BMenuBar : public BMenu
{
public:
BMenuBar( BRect frame,
const char *title,
uint32 resizeMask =
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
menu_layout layout = B_ITEMS_IN_ROW,
bool resizeToFit = true);
BMenuBar(BRect frame,
const char *title,
uint32 resizeMask =
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
menu_layout layout = B_ITEMS_IN_ROW,
bool resizeToFit = true);
BMenuBar(const char *title,
menu_layout layout = B_ITEMS_IN_ROW,
uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS);
BMenuBar(BMessage *data);
virtual ~BMenuBar();
static BArchivable *Instantiate(BMessage *data);

View File

@ -51,6 +51,21 @@ BMenuBar::BMenuBar(BRect frame, const char *title, uint32 resizeMask,
}
BMenuBar::BMenuBar(const char *title, menu_layout layout, uint32 flags)
: BMenu(BRect(), title, B_FOLLOW_NONE,
flags | B_WILL_DRAW | B_FRAME_EVENTS | B_SUPPORTS_LAYOUT,
layout, false),
fBorder(B_BORDER_FRAME),
fTrackingPID(-1),
fPrevFocusToken(-1),
fMenuSem(-1),
fLastBounds(NULL),
fTracking(false)
{
InitData(layout);
}
BMenuBar::BMenuBar(BMessage *data)
: BMenu(data),
fBorder(B_BORDER_FRAME),
@ -222,11 +237,21 @@ BMenuBar::FrameMoved(BPoint newPosition)
void
BMenuBar::FrameResized(float newWidth, float newHeight)
{
BRect bounds(Bounds());
BRect rect(fLastBounds->right - 12, fLastBounds->top, bounds.right, bounds.bottom);
// invalidate right border
if (newWidth != fLastBounds->Width()) {
BRect rect(min_c(fLastBounds->right, newWidth), 0,
max_c(fLastBounds->right, newWidth), newHeight);
Invalidate(rect);
}
// invalidate bottom border
if (newHeight != fLastBounds->Height()) {
BRect rect(0, min_c(fLastBounds->bottom, newHeight) - 1,
newWidth, max_c(fLastBounds->bottom, newHeight));
Invalidate(rect);
}
fLastBounds->Set(0, 0, newWidth, newHeight);
Invalidate(rect);
BMenu::FrameResized(newWidth, newHeight);
}