2007-10-29 13:40:16 +03:00
|
|
|
/*
|
2015-09-09 21:08:26 +03:00
|
|
|
* Copyright 2003-2015, Haiku, Inc. All rights reserved.
|
2009-08-27 15:12:41 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
2007-10-29 13:40:16 +03:00
|
|
|
*/
|
2002-10-23 17:54:44 +04:00
|
|
|
#ifndef _MENU_BAR_H
|
|
|
|
#define _MENU_BAR_H
|
|
|
|
|
2009-08-26 16:22:10 +04:00
|
|
|
|
2002-10-23 17:54:44 +04:00
|
|
|
#include <InterfaceDefs.h>
|
|
|
|
#include <Menu.h>
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
|
|
|
|
enum menu_bar_border {
|
|
|
|
B_BORDER_FRAME,
|
|
|
|
B_BORDER_CONTENTS,
|
|
|
|
B_BORDER_EACH_ITEM
|
|
|
|
};
|
|
|
|
|
|
|
|
class BMenu;
|
|
|
|
class BWindow;
|
|
|
|
class BMenuItem;
|
|
|
|
class BMenuField;
|
|
|
|
|
2007-10-29 13:40:16 +03:00
|
|
|
|
|
|
|
class BMenuBar : public BMenu {
|
2009-08-26 16:22:10 +04:00
|
|
|
public:
|
2013-11-07 04:26:19 +04:00
|
|
|
BMenuBar(BRect frame, const char* name,
|
|
|
|
uint32 resizingMode = B_FOLLOW_LEFT_RIGHT
|
2009-08-26 16:22:10 +04:00
|
|
|
| B_FOLLOW_TOP,
|
|
|
|
menu_layout layout = B_ITEMS_IN_ROW,
|
|
|
|
bool resizeToFit = true);
|
2013-11-07 04:26:19 +04:00
|
|
|
BMenuBar(const char* name,
|
2009-08-26 16:22:10 +04:00
|
|
|
menu_layout layout = B_ITEMS_IN_ROW,
|
|
|
|
uint32 flags = B_WILL_DRAW
|
|
|
|
| B_FRAME_EVENTS);
|
|
|
|
BMenuBar(BMessage* archive);
|
|
|
|
virtual ~BMenuBar();
|
2015-09-09 21:08:26 +03:00
|
|
|
|
2009-08-26 16:22:10 +04:00
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
|
|
|
virtual status_t Archive(BMessage* archive,
|
|
|
|
bool deep = true) const;
|
|
|
|
|
|
|
|
virtual void AttachedToWindow();
|
|
|
|
virtual void DetachedFromWindow();
|
|
|
|
virtual void AllAttached();
|
|
|
|
virtual void AllDetached();
|
|
|
|
|
|
|
|
virtual void WindowActivated(bool state);
|
|
|
|
virtual void MakeFocus(bool state = true);
|
|
|
|
|
|
|
|
virtual void ResizeToPreferred();
|
|
|
|
virtual void GetPreferredSize(float* _width,
|
|
|
|
float* _height);
|
|
|
|
virtual BSize MinSize();
|
|
|
|
virtual BSize MaxSize();
|
|
|
|
virtual BSize PreferredSize();
|
|
|
|
virtual void FrameMoved(BPoint newPosition);
|
|
|
|
virtual void FrameResized(float newWidth, float newHeight);
|
|
|
|
|
|
|
|
virtual void Show();
|
|
|
|
virtual void Hide();
|
|
|
|
|
|
|
|
virtual void Draw(BRect updateRect);
|
|
|
|
|
|
|
|
virtual void MessageReceived(BMessage *message);
|
|
|
|
virtual void MouseDown(BPoint where);
|
|
|
|
virtual void MouseUp(BPoint where);
|
|
|
|
|
|
|
|
virtual BHandler* ResolveSpecifier(BMessage* message,
|
|
|
|
int32 index, BMessage* specifier,
|
|
|
|
int32 form, const char* property);
|
|
|
|
virtual status_t GetSupportedSuites(BMessage* data);
|
|
|
|
|
|
|
|
virtual void SetBorder(menu_bar_border border);
|
|
|
|
menu_bar_border Border() const;
|
2015-09-09 21:08:26 +03:00
|
|
|
void SetBorders(uint32 borders);
|
|
|
|
uint32 Borders() const;
|
|
|
|
|
2009-08-26 16:22:10 +04:00
|
|
|
virtual status_t Perform(perform_code code, void* data);
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BWindow;
|
|
|
|
friend class BMenuField;
|
|
|
|
friend class BMenu;
|
|
|
|
|
|
|
|
virtual void _ReservedMenuBar1();
|
|
|
|
virtual void _ReservedMenuBar2();
|
|
|
|
virtual void _ReservedMenuBar3();
|
|
|
|
virtual void _ReservedMenuBar4();
|
|
|
|
|
|
|
|
BMenuBar &operator=(const BMenuBar &);
|
|
|
|
|
|
|
|
// TODO: Tracker uses this function so we can't change
|
|
|
|
// its signature without breaking it
|
|
|
|
void StartMenuBar(int32 menuIndex,
|
|
|
|
bool sticky = true, bool showMenu = false,
|
|
|
|
BRect* special_rect = NULL);
|
2015-09-09 21:08:26 +03:00
|
|
|
|
2009-08-26 16:22:10 +04:00
|
|
|
static int32 _TrackTask(void *arg);
|
|
|
|
BMenuItem* _Track(int32 *action, int32 startIndex = -1,
|
|
|
|
bool showMenu = false);
|
|
|
|
void _StealFocus();
|
|
|
|
void _RestoreFocus();
|
|
|
|
void _InitData(menu_layout layout);
|
|
|
|
|
|
|
|
menu_bar_border fBorder;
|
|
|
|
thread_id fTrackingPID;
|
|
|
|
int32 fPrevFocusToken;
|
|
|
|
sem_id fMenuSem;
|
|
|
|
BRect* fLastBounds;
|
2015-09-09 21:08:26 +03:00
|
|
|
uint32 fBorders;
|
|
|
|
uint32 _reserved[1];
|
2009-08-26 16:22:10 +04:00
|
|
|
|
|
|
|
bool fTracking;
|
2002-10-23 17:54:44 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _MENU_BAR_H */
|