1 /* 2 Open Tracker License 3 4 Terms and Conditions 5 6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 8 Permission is hereby granted, free of charge, to any person obtaining a copy of 9 this software and associated documentation files (the "Software"), to deal in 10 the Software without restriction, including without limitation the rights to 11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 of the Software, and to permit persons to whom the Software is furnished to do 13 so, subject to the following conditions: 14 15 The above copyright notice and this permission notice applies to all licensees 16 and shall be included in all copies or substantial portions of the Software. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25 Except as contained in this notice, the name of Be Incorporated shall not be 26 used in advertising or otherwise to promote the sale, use or other dealings in 27 this Software without prior written authorization from Be Incorporated. 28 29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks 30 of Be Incorporated in the United States and other countries. Other brand product 31 names are registered trademarks or trademarks of their respective holders. 32 All rights reserved. 33 */ 34 35 #ifndef _DIALOG_PANE_ 36 #define _DIALOG_PANE_ 37 38 #include <Control.h> 39 40 #include "ObjectList.h" 41 42 namespace BPrivate { 43 44 class ViewList : public BObjectList<BView> { 45 public: 46 ViewList() 47 : BObjectList<BView>(5, true) 48 {} 49 50 void RemoveAll(BView *fromParent); 51 void AddAll(BView *toParent); 52 }; 53 54 class DialogPane : public BView { 55 // dialog with collapsible panes 56 public: 57 DialogPane(BRect mode1Frame, BRect mode2Frame, int32 initialMode, 58 const char *name, uint32 followFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, 59 uint32 flags = B_WILL_DRAW); 60 DialogPane(BRect mode1Frame, BRect mode2Frame, BRect mode3Frame, 61 int32 initialMode, const char *name, 62 uint32 followFlags = B_FOLLOW_LEFT | B_FOLLOW_TOP, 63 uint32 flags = B_WILL_DRAW); 64 65 virtual ~DialogPane(); 66 67 BRect FrameForMode(int32); 68 BRect BoundsForMode(int32); 69 70 int32 Mode() const; 71 virtual void SetMode(int32, bool initialSetup = false); 72 73 void AddItem(BView *, int32 toMode); 74 75 void SetSwitch(BControl *); 76 77 virtual void AttachedToWindow(); 78 79 protected: 80 void ResizeParentWindow(int32 from, int32 to); 81 static BRect FrameForMode(int32, BRect, BRect, BRect); 82 // called only by the constructor 83 84 virtual void MessageReceived(BMessage *); 85 86 private: 87 int32 fMode; 88 89 BRect fMode1Frame; 90 BRect fMode2Frame; 91 BRect fMode3Frame; 92 93 ViewList fMode2Items; 94 ViewList fMode3Items; 95 BControl *fLatch; 96 97 typedef BView _inherited; 98 }; 99 100 inline int32 101 DialogPane::Mode() const 102 { 103 return fMode; 104 } 105 106 class PaneSwitch : public BControl { 107 108 public: 109 PaneSwitch(BRect frame, const char *name, bool leftAligned = true, 110 uint32 resizeMask = B_FOLLOW_LEFT | B_FOLLOW_TOP, 111 uint32 flags = B_WILL_DRAW | B_NAVIGABLE); 112 113 virtual void Draw(BRect ); 114 virtual void MouseDown(BPoint ); 115 protected: 116 117 void DoneTracking(BPoint ); 118 void Track(BPoint, uint32); 119 120 enum State { 121 kCollapsed, 122 kPressed, 123 kExpanded 124 }; 125 126 virtual void DrawInState(PaneSwitch::State state); 127 128 bool fLeftAligned; 129 bool fPressing; 130 }; 131 132 } // namespace BPrivate 133 134 using namespace BPrivate; 135 136 #endif 137