5f603da01a
Just use BControLook where appropriate. It already provides a nice arrow drawing function (also used in DeskBar expander and in scrollbar buttons). Fix second part of #8900 Changes by John Scipione: Update menu mark and submenu arrow color with menu text color Use text color for checkmark and submenu arrow colors, tint less black. This means that colored bg/white text menu item will also draw a white checkmark and submenu arrow. Break out BMenuItem::Draw functionality into private methods _IsActive, _LowColor() and _HighColor() methods and use them to set the mark colors. Scale submenu arrow and checkmark with item height (which scales with font size.) does not align shortcuts with submenu arrows... but if you were to do that you'd add item->Bounds().Height() / 2. Signed-off-by: John Scipione <jscipione@gmail.com> Change-Id: I8299094ef88bf227510b116eb1b84c261dc94723 Reviewed-on: https://review.haiku-os.org/c/341 Reviewed-by: Stefano Ceccherini <stefano.ceccherini@gmail.com> Reviewed-by: Axel Dörfler <axeld@pinc-software.de> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
122 lines
3.0 KiB
C++
122 lines
3.0 KiB
C++
/*
|
|
* Copyright 2006-2007, Haiku, Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _MENU_ITEM_H
|
|
#define _MENU_ITEM_H
|
|
|
|
|
|
#include <Archivable.h>
|
|
#include <InterfaceDefs.h>
|
|
#include <Invoker.h>
|
|
#include <Menu.h>
|
|
|
|
|
|
class BMessage;
|
|
class BWindow;
|
|
|
|
namespace BPrivate {
|
|
class MenuItemPrivate;
|
|
}
|
|
|
|
class BMenuItem : public BArchivable, public BInvoker {
|
|
public:
|
|
BMenuItem(const char* label, BMessage* message,
|
|
char shortcut = 0, uint32 modifiers = 0);
|
|
BMenuItem(BMenu* menu,
|
|
BMessage* message = NULL);
|
|
BMenuItem(BMessage* data);
|
|
virtual ~BMenuItem();
|
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
|
virtual status_t Archive(BMessage* archive,
|
|
bool deep = true) const;
|
|
|
|
virtual void SetLabel(const char* name);
|
|
virtual void SetEnabled(bool enable);
|
|
virtual void SetMarked(bool mark);
|
|
virtual void SetTrigger(char trigger);
|
|
virtual void SetShortcut(char shortcut, uint32 modifiers);
|
|
|
|
const char* Label() const;
|
|
bool IsEnabled() const;
|
|
bool IsMarked() const;
|
|
char Trigger() const;
|
|
char Shortcut(uint32* _modifiers = NULL) const;
|
|
|
|
BMenu* Submenu() const;
|
|
BMenu* Menu() const;
|
|
BRect Frame() const;
|
|
|
|
protected:
|
|
virtual void GetContentSize(float* _width, float* _height);
|
|
virtual void TruncateLabel(float maxWidth, char* newLabel);
|
|
virtual void DrawContent();
|
|
virtual void Draw();
|
|
virtual void Highlight(bool highlight);
|
|
bool IsSelected() const;
|
|
BPoint ContentLocation() const;
|
|
|
|
private:
|
|
friend class BMenu;
|
|
friend class BPopUpMenu;
|
|
friend class BMenuBar;
|
|
friend class BPrivate::MenuItemPrivate;
|
|
|
|
virtual void _ReservedMenuItem1();
|
|
virtual void _ReservedMenuItem2();
|
|
virtual void _ReservedMenuItem3();
|
|
virtual void _ReservedMenuItem4();
|
|
|
|
void Install(BWindow* window);
|
|
void Uninstall();
|
|
void SetSuper(BMenu* superMenu);
|
|
void Select(bool select);
|
|
void SetAutomaticTrigger(int32 index,
|
|
uint32 trigger);
|
|
|
|
protected:
|
|
virtual status_t Invoke(BMessage* message = NULL);
|
|
|
|
private:
|
|
BMenuItem(const BMenuItem& other);
|
|
BMenuItem& operator=(const BMenuItem& other);
|
|
|
|
private:
|
|
void _InitData();
|
|
void _InitMenuData(BMenu* menu);
|
|
|
|
bool _IsActivated();
|
|
rgb_color _LowColor();
|
|
rgb_color _HighColor();
|
|
|
|
void _DrawMarkSymbol();
|
|
void _DrawShortcutSymbol();
|
|
void _DrawSubmenuSymbol();
|
|
void _DrawControlChar(char shortcut, BPoint where);
|
|
|
|
private:
|
|
char* fLabel;
|
|
BMenu* fSubmenu;
|
|
BWindow* fWindow;
|
|
BMenu* fSuper;
|
|
BRect fBounds;
|
|
uint32 fModifiers;
|
|
float fCachedWidth;
|
|
int16 fTriggerIndex;
|
|
char fUserTrigger;
|
|
char fShortcutChar;
|
|
bool fMark;
|
|
bool fEnabled;
|
|
bool fSelected;
|
|
uint32 fTrigger;
|
|
|
|
uint32 _reserved[3];
|
|
};
|
|
|
|
// BSeparatorItem now has its own declaration file, but for source
|
|
// compatibility we're exporting that class from here too.
|
|
#include <SeparatorItem.h>
|
|
|
|
#endif // _MENU_ITEM_H
|