1 /******************************************************************************* 2 / 3 / File: Menubar.h 4 / 5 / Description: BMenuBar is a menu that's at the root of a menu hierarchy. 6 / 7 / Copyright 1994-98, Be Incorporated, All Rights Reserved 8 / 9 *******************************************************************************/ 10 11 #ifndef _MENU_BAR_H 12 #define _MENU_BAR_H 13 14 #include <BeBuild.h> 15 #include <InterfaceDefs.h> 16 #include <Menu.h> 17 #include <OS.h> 18 19 /*----------------------------------------------------------------*/ 20 /*----- BmenuBar declarations ------------------------------------*/ 21 22 enum menu_bar_border { 23 B_BORDER_FRAME, 24 B_BORDER_CONTENTS, 25 B_BORDER_EACH_ITEM 26 }; 27 28 class BMenu; 29 class BWindow; 30 class BMenuItem; 31 class BMenuField; 32 33 /*----------------------------------------------------------------*/ 34 /*----- BMenuBar class -------------------------------------------*/ 35 36 class BMenuBar : public BMenu 37 { 38 public: 39 BMenuBar(BRect frame, 40 const char *title, 41 uint32 resizeMask = 42 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, 43 menu_layout layout = B_ITEMS_IN_ROW, 44 bool resizeToFit = true); 45 BMenuBar(const char *title, 46 menu_layout layout = B_ITEMS_IN_ROW, 47 uint32 flags = B_WILL_DRAW | B_FRAME_EVENTS); 48 BMenuBar(BMessage *data); 49 virtual ~BMenuBar(); 50 static BArchivable *Instantiate(BMessage *data); 51 virtual status_t Archive(BMessage *data, bool deep = true) const; 52 53 virtual void SetBorder(menu_bar_border border); 54 menu_bar_border Border() const; 55 virtual void Draw(BRect updateRect); 56 virtual void AttachedToWindow(); 57 virtual void DetachedFromWindow(); 58 virtual void MessageReceived(BMessage *msg); 59 virtual void MouseDown(BPoint where); 60 virtual void WindowActivated(bool state); 61 virtual void MouseUp(BPoint where); 62 virtual void FrameMoved(BPoint new_position); 63 virtual void FrameResized(float new_width, float new_height); 64 65 virtual void Show(); 66 virtual void Hide(); 67 68 virtual BHandler *ResolveSpecifier(BMessage *msg, 69 int32 index, 70 BMessage *specifier, 71 int32 form, 72 const char *property); 73 virtual status_t GetSupportedSuites(BMessage *data); 74 75 virtual void ResizeToPreferred(); 76 virtual void GetPreferredSize(float *width, float *height); 77 virtual void MakeFocus(bool state = true); 78 virtual void AllAttached(); 79 virtual void AllDetached(); 80 81 82 83 // layout related 84 virtual BSize MinSize(); 85 virtual BSize MaxSize(); 86 virtual BSize PreferredSize(); 87 88 /*----- Private or reserved -----------------------------------------*/ 89 virtual status_t Perform(perform_code d, void *arg); 90 91 private: 92 friend class BWindow; 93 friend class BMenuItem; 94 friend class BMenuField; 95 friend class BMenu; 96 97 virtual void _ReservedMenuBar1(); 98 virtual void _ReservedMenuBar2(); 99 virtual void _ReservedMenuBar3(); 100 virtual void _ReservedMenuBar4(); 101 102 BMenuBar &operator=(const BMenuBar &); 103 104 void StartMenuBar( int32 menuIndex, 105 bool sticky = true, 106 bool show_menu = false, 107 BRect *special_rect = NULL); 108 static long TrackTask(void *arg); 109 BMenuItem *Track( int32 *action, 110 int32 startIndex = -1, 111 bool showMenu = false); 112 void StealFocus(); 113 void RestoreFocus(); 114 void InitData(menu_layout layout); 115 116 menu_bar_border fBorder; 117 thread_id fTrackingPID; 118 int32 fPrevFocusToken; 119 sem_id fMenuSem; 120 BRect* fLastBounds; 121 uint32 _reserved[2]; // was 3 122 123 bool fTracking; 124 }; 125 126 /*-------------------------------------------------------------*/ 127 /*-------------------------------------------------------------*/ 128 129 #endif /* _MENU_BAR_H */ 130