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 80 // layout related 81 virtual BSize MaxSize(); 82 83 /*----- Private or reserved -----------------------------------------*/ 84 virtual status_t Perform(perform_code d, void *arg); 85 86 private: 87 friend class BWindow; 88 friend class BMenuItem; 89 friend class BMenuField; 90 friend class BMenu; 91 92 virtual void _ReservedMenuBar1(); 93 virtual void _ReservedMenuBar2(); 94 virtual void _ReservedMenuBar3(); 95 virtual void _ReservedMenuBar4(); 96 97 BMenuBar &operator=(const BMenuBar &); 98 99 void StartMenuBar( int32 menuIndex, 100 bool sticky = true, 101 bool show_menu = false, 102 BRect *special_rect = NULL); 103 static long TrackTask(void *arg); 104 BMenuItem *Track( int32 *action, 105 int32 startIndex = -1, 106 bool showMenu = false); 107 void StealFocus(); 108 void RestoreFocus(); 109 void InitData(menu_layout layout); 110 111 menu_bar_border fBorder; 112 thread_id fTrackingPID; 113 int32 fPrevFocusToken; 114 sem_id fMenuSem; 115 BRect* fLastBounds; 116 uint32 _reserved[2]; // was 3 117 118 bool fTracking; 119 }; 120 121 /*-------------------------------------------------------------*/ 122 /*-------------------------------------------------------------*/ 123 124 #endif /* _MENU_BAR_H */ 125