1 /* 2 * Copyright 2003-2007, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _MENU_BAR_H 6 #define _MENU_BAR_H 7 8 #include <BeBuild.h> 9 #include <InterfaceDefs.h> 10 #include <Menu.h> 11 #include <OS.h> 12 13 14 enum menu_bar_border { 15 B_BORDER_FRAME, 16 B_BORDER_CONTENTS, 17 B_BORDER_EACH_ITEM 18 }; 19 20 class BMenu; 21 class BWindow; 22 class BMenuItem; 23 class BMenuField; 24 25 26 class BMenuBar : public BMenu { 27 public: 28 BMenuBar(BRect frame, const char *title, 29 uint32 resizeMask = B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, 30 menu_layout layout = B_ITEMS_IN_ROW, 31 bool resizeToFit = true); 32 BMenuBar(const char *title, menu_layout layout = B_ITEMS_IN_ROW, 33 uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS); 34 BMenuBar(BMessage *data); 35 virtual ~BMenuBar(); 36 37 static BArchivable* Instantiate(BMessage *data); 38 virtual status_t Archive(BMessage *data, bool deep = true) const; 39 40 virtual void SetBorder(menu_bar_border border); 41 menu_bar_border Border() const; 42 43 virtual void Draw(BRect updateRect); 44 virtual void AttachedToWindow(); 45 virtual void DetachedFromWindow(); 46 virtual void MessageReceived(BMessage *message); 47 virtual void MouseDown(BPoint where); 48 virtual void WindowActivated(bool state); 49 virtual void MouseUp(BPoint where); 50 virtual void FrameMoved(BPoint newPosition); 51 virtual void FrameResized(float newWidth, float newHeight); 52 53 virtual void Show(); 54 virtual void Hide(); 55 56 virtual BHandler* ResolveSpecifier(BMessage *message, int32 index, 57 BMessage *specifier, int32 form, 58 const char *property); 59 virtual status_t GetSupportedSuites(BMessage *data); 60 61 virtual void ResizeToPreferred(); 62 virtual void GetPreferredSize(float *width, float *height); 63 virtual void MakeFocus(bool state = true); 64 virtual void AllAttached(); 65 virtual void AllDetached(); 66 67 68 // layout related 69 virtual BSize MinSize(); 70 virtual BSize MaxSize(); 71 virtual BSize PreferredSize(); 72 73 virtual status_t Perform(perform_code code, void *arg); 74 75 private: 76 friend class BWindow; 77 friend class BMenuField; 78 friend class BMenu; 79 80 virtual void _ReservedMenuBar1(); 81 virtual void _ReservedMenuBar2(); 82 virtual void _ReservedMenuBar3(); 83 virtual void _ReservedMenuBar4(); 84 85 BMenuBar &operator=(const BMenuBar &); 86 87 // TODO: Tracker uses this function so we can't change 88 // its signature without breaking it 89 void StartMenuBar(int32 menuIndex, bool sticky = true, 90 bool showMenu = false, 91 BRect *special_rect = NULL); 92 93 static int32 _TrackTask(void *arg); 94 BMenuItem *_Track(int32 *action, int32 startIndex = -1, 95 bool showMenu = false); 96 void _StealFocus(); 97 void _RestoreFocus(); 98 void _InitData(menu_layout layout); 99 100 menu_bar_border fBorder; 101 thread_id fTrackingPID; 102 int32 fPrevFocusToken; 103 sem_id fMenuSem; 104 BRect* fLastBounds; 105 uint32 _reserved[2]; // was 3 106 107 bool fTracking; 108 }; 109 110 111 #endif /* _MENU_BAR_H */ 112