mirror of
https://review.haiku-os.org/haiku
synced 2025-01-24 07:14:48 +01:00
c333966291
...instead of in BMenuItem and remove the truncation code from BMenuItem. The label truncation code cannot work in BMenuItem because the super menu helpfully resizes itself to fit the menu item. So, instead we do the label truncation in BMCPrivate making sure that BMenuItem there can't expand the BMCMenuBar because we set the width to fMenuField->_MenuBarWidth() explicity. Note that this only truncates the label in BMCMenuField, i.e. the label inside the menufield, it does nothing to the labels of the menu items in the attached BMenu or BPopUpMenu which is exactly what we want.
75 lines
1.7 KiB
C++
75 lines
1.7 KiB
C++
/*
|
|
* Copyright 2001-2013 Haiku, Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*
|
|
* Authors:
|
|
* Stephan Aßmus, superstippi@gmx.de
|
|
* Marc Flerackers, mflerackers@androme.be
|
|
* John Scipione, jscipione@gmail.com
|
|
*/
|
|
#ifndef _BMC_PRIVATE_H
|
|
#define _BMC_PRIVATE_H
|
|
|
|
|
|
#include <BeBuild.h>
|
|
#include <MenuBar.h>
|
|
#include <MenuItem.h>
|
|
#include <MessageFilter.h>
|
|
|
|
class BMessageRunner;
|
|
|
|
|
|
class _BMCFilter_ : public BMessageFilter {
|
|
public:
|
|
_BMCFilter_(BMenuField* menuField, uint32 what);
|
|
virtual ~_BMCFilter_();
|
|
|
|
virtual filter_result Filter(BMessage* message, BHandler** handler);
|
|
|
|
private:
|
|
_BMCFilter_& operator=(const _BMCFilter_&);
|
|
|
|
BMenuField* fMenuField;
|
|
};
|
|
|
|
|
|
class _BMCMenuBar_ : public BMenuBar {
|
|
public:
|
|
_BMCMenuBar_(BRect frame, bool fixedSize,
|
|
BMenuField* menuField);
|
|
_BMCMenuBar_(BMenuField* menuField);
|
|
_BMCMenuBar_(BMessage* data);
|
|
virtual ~_BMCMenuBar_();
|
|
|
|
static BArchivable* Instantiate(BMessage* data);
|
|
|
|
virtual void AttachedToWindow();
|
|
virtual void Draw(BRect updateRect);
|
|
virtual void FrameResized(float width, float height);
|
|
virtual void MessageReceived(BMessage* msg);
|
|
virtual void MakeFocus(bool focused = true);
|
|
|
|
void TogglePopUpMarker(bool show)
|
|
{ fShowPopUpMarker = show; }
|
|
bool IsPopUpMarkerShown() const
|
|
{ return fShowPopUpMarker; }
|
|
|
|
virtual BSize MinSize();
|
|
virtual BSize MaxSize();
|
|
|
|
private:
|
|
_BMCMenuBar_&operator=(const _BMCMenuBar_&);
|
|
|
|
void _Init(bool setMaxContentWidth);
|
|
|
|
void _DrawItems(BRect updateRect);
|
|
|
|
BMenuField* fMenuField;
|
|
bool fFixedSize;
|
|
BMessageRunner* fRunner;
|
|
bool fShowPopUpMarker;
|
|
float fPreviousWidth;
|
|
};
|
|
|
|
#endif // _BMC_PRIVATE_H
|