BMenuBar::SetBorders() added.

* This allows you to only draw some of the borders.
This commit is contained in:
Axel Dörfler
2015-09-09 20:58:57 +02:00
parent f74aab0a2e
commit 14cc5b4c44
2 changed files with 26 additions and 7 deletions
+8 -5
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2003-2009, Haiku, Inc. All rights reserved. * Copyright 2003-2015, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#ifndef _MENU_BAR_H #ifndef _MENU_BAR_H
@@ -36,7 +36,7 @@ public:
| B_FRAME_EVENTS); | B_FRAME_EVENTS);
BMenuBar(BMessage* archive); BMenuBar(BMessage* archive);
virtual ~BMenuBar(); virtual ~BMenuBar();
static BArchivable* Instantiate(BMessage* archive); static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* archive, virtual status_t Archive(BMessage* archive,
bool deep = true) const; bool deep = true) const;
@@ -74,7 +74,9 @@ public:
virtual void SetBorder(menu_bar_border border); virtual void SetBorder(menu_bar_border border);
menu_bar_border Border() const; menu_bar_border Border() const;
void SetBorders(uint32 borders);
uint32 Borders() const;
virtual status_t Perform(perform_code code, void* data); virtual status_t Perform(perform_code code, void* data);
private: private:
@@ -94,7 +96,7 @@ private:
void StartMenuBar(int32 menuIndex, void StartMenuBar(int32 menuIndex,
bool sticky = true, bool showMenu = false, bool sticky = true, bool showMenu = false,
BRect* special_rect = NULL); BRect* special_rect = NULL);
static int32 _TrackTask(void *arg); static int32 _TrackTask(void *arg);
BMenuItem* _Track(int32 *action, int32 startIndex = -1, BMenuItem* _Track(int32 *action, int32 startIndex = -1,
bool showMenu = false); bool showMenu = false);
@@ -107,7 +109,8 @@ private:
int32 fPrevFocusToken; int32 fPrevFocusToken;
sem_id fMenuSem; sem_id fMenuSem;
BRect* fLastBounds; BRect* fLastBounds;
uint32 _reserved[2]; uint32 fBorders;
uint32 _reserved[1];
bool fTracking; bool fTracking;
}; };
+18 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2009, Haiku Inc. All rights reserved. * Copyright 2001-2015, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -286,7 +286,8 @@ BMenuBar::Draw(BRect updateRect)
be_control_look->DrawBorder(this, rect, updateRect, base, be_control_look->DrawBorder(this, rect, updateRect, base,
B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER); B_PLAIN_BORDER, flags, BControlLook::B_BOTTOM_BORDER);
be_control_look->DrawMenuBarBackground(this, rect, updateRect, base); be_control_look->DrawMenuBarBackground(this, rect, updateRect, base,
0, fBorders);
_DrawItems(updateRect); _DrawItems(updateRect);
} }
@@ -369,6 +370,20 @@ BMenuBar::Border() const
} }
void
BMenuBar::SetBorders(uint32 borders)
{
fBorders = borders;
}
uint32
BMenuBar::Borders() const
{
return fBorders;
}
// #pragma mark - // #pragma mark -
@@ -726,6 +741,7 @@ BMenuBar::_RestoreFocus()
void void
BMenuBar::_InitData(menu_layout layout) BMenuBar::_InitData(menu_layout layout)
{ {
fBorders = BControlLook::B_ALL_BORDERS;
fLastBounds = new BRect(Bounds()); fLastBounds = new BRect(Bounds());
SetItemMargins(8, 2, 8, 2); SetItemMargins(8, 2, 8, 2);
_SetIgnoreHidden(true); _SetIgnoreHidden(true);