1 /* 2 * Copyright 2003-2009, 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 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* name, 29 uint32 resizingMode = B_FOLLOW_LEFT_RIGHT 30 | B_FOLLOW_TOP, 31 menu_layout layout = B_ITEMS_IN_ROW, 32 bool resizeToFit = true); 33 BMenuBar(const char* name, 34 menu_layout layout = B_ITEMS_IN_ROW, 35 uint32 flags = B_WILL_DRAW 36 | B_FRAME_EVENTS); 37 BMenuBar(BMessage* archive); 38 virtual ~BMenuBar(); 39 40 static BArchivable* Instantiate(BMessage* archive); 41 virtual status_t Archive(BMessage* archive, 42 bool deep = true) const; 43 44 virtual void AttachedToWindow(); 45 virtual void DetachedFromWindow(); 46 virtual void AllAttached(); 47 virtual void AllDetached(); 48 49 virtual void WindowActivated(bool state); 50 virtual void MakeFocus(bool state = true); 51 52 virtual void ResizeToPreferred(); 53 virtual void GetPreferredSize(float* _width, 54 float* _height); 55 virtual BSize MinSize(); 56 virtual BSize MaxSize(); 57 virtual BSize PreferredSize(); 58 virtual void FrameMoved(BPoint newPosition); 59 virtual void FrameResized(float newWidth, float newHeight); 60 61 virtual void Show(); 62 virtual void Hide(); 63 64 virtual void Draw(BRect updateRect); 65 66 virtual void MessageReceived(BMessage *message); 67 virtual void MouseDown(BPoint where); 68 virtual void MouseUp(BPoint where); 69 70 virtual BHandler* ResolveSpecifier(BMessage* message, 71 int32 index, BMessage* specifier, 72 int32 form, const char* property); 73 virtual status_t GetSupportedSuites(BMessage* data); 74 75 virtual void SetBorder(menu_bar_border border); 76 menu_bar_border Border() const; 77 78 virtual status_t Perform(perform_code code, void* data); 79 80 private: 81 friend class BWindow; 82 friend class BMenuField; 83 friend class BMenu; 84 85 virtual void _ReservedMenuBar1(); 86 virtual void _ReservedMenuBar2(); 87 virtual void _ReservedMenuBar3(); 88 virtual void _ReservedMenuBar4(); 89 90 BMenuBar &operator=(const BMenuBar &); 91 92 // TODO: Tracker uses this function so we can't change 93 // its signature without breaking it 94 void StartMenuBar(int32 menuIndex, 95 bool sticky = true, bool showMenu = false, 96 BRect* special_rect = NULL); 97 98 static int32 _TrackTask(void *arg); 99 BMenuItem* _Track(int32 *action, int32 startIndex = -1, 100 bool showMenu = false); 101 void _StealFocus(); 102 void _RestoreFocus(); 103 void _InitData(menu_layout layout); 104 105 menu_bar_border fBorder; 106 thread_id fTrackingPID; 107 int32 fPrevFocusToken; 108 sem_id fMenuSem; 109 BRect* fLastBounds; 110 uint32 _reserved[2]; 111 112 bool fTracking; 113 }; 114 115 116 #endif /* _MENU_BAR_H */ 117