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(BMessage *data); 46 virtual ~BMenuBar(); 47 static BArchivable *Instantiate(BMessage *data); 48 virtual status_t Archive(BMessage *data, bool deep = true) const; 49 50 virtual void SetBorder(menu_bar_border border); 51 menu_bar_border Border() const; 52 virtual void Draw(BRect updateRect); 53 virtual void AttachedToWindow(); 54 virtual void DetachedFromWindow(); 55 virtual void MessageReceived(BMessage *msg); 56 virtual void MouseDown(BPoint where); 57 virtual void WindowActivated(bool state); 58 virtual void MouseUp(BPoint where); 59 virtual void FrameMoved(BPoint new_position); 60 virtual void FrameResized(float new_width, float new_height); 61 62 virtual void Show(); 63 virtual void Hide(); 64 65 virtual BHandler *ResolveSpecifier(BMessage *msg, 66 int32 index, 67 BMessage *specifier, 68 int32 form, 69 const char *property); 70 virtual status_t GetSupportedSuites(BMessage *data); 71 72 virtual void ResizeToPreferred(); 73 virtual void GetPreferredSize(float *width, float *height); 74 virtual void MakeFocus(bool state = true); 75 virtual void AllAttached(); 76 virtual void AllDetached(); 77 78 79 /*----- Private or reserved -----------------------------------------*/ 80 virtual status_t Perform(perform_code d, void *arg); 81 82 private: 83 friend class BWindow; 84 friend class BMenuItem; 85 friend class BMenuField; 86 friend class BMenu; 87 88 virtual void _ReservedMenuBar1(); 89 virtual void _ReservedMenuBar2(); 90 virtual void _ReservedMenuBar3(); 91 virtual void _ReservedMenuBar4(); 92 93 BMenuBar &operator=(const BMenuBar &); 94 95 void StartMenuBar( int32 menuIndex, 96 bool sticky = true, 97 bool show_menu = false, 98 BRect *special_rect = NULL); 99 static long TrackTask(void *arg); 100 BMenuItem *Track( int32 *action, 101 int32 startIndex = -1, 102 bool showMenu = false); 103 void StealFocus(); 104 void RestoreFocus(); 105 void InitData(menu_layout layout); 106 107 menu_bar_border fBorder; 108 thread_id fTrackingPID; 109 int32 fPrevFocusToken; 110 sem_id fMenuSem; 111 BRect* fLastBounds; 112 uint32 _reserved[2]; // was 3 113 114 bool fTracking; 115 }; 116 117 /*-------------------------------------------------------------*/ 118 /*-------------------------------------------------------------*/ 119 120 #endif /* _MENU_BAR_H */ 121