Ticket #3161: tabview_layouted.diff
File tabview_layouted.diff, 5.3 KB (added by , 16 years ago) |
---|
-
headers/os/interface/TabView.h
60 60 61 61 bool IsSelected() const; 62 62 virtual void Select(BView *owner); 63 virtual void Deselect(bool layouted); 63 64 virtual void Deselect(); 64 65 65 66 virtual void SetEnabled(bool enabled); … … 106 107 class BTabView : public BView 107 108 { 108 109 public: 110 BTabView(const char *name, 111 button_width width = B_WIDTH_AS_USUAL, 112 uint32 flags = B_FULL_UPDATE_ON_RESIZE | 113 B_WILL_DRAW | B_NAVIGABLE_JUMP | 114 B_FRAME_EVENTS | B_NAVIGABLE); 109 115 BTabView(BRect frame, const char *name, 110 116 button_width width = B_WIDTH_AS_USUAL, 111 117 uint32 resizingMode = B_FOLLOW_ALL, 112 118 uint32 flags = B_FULL_UPDATE_ON_RESIZE | 113 B_WILL_DRAW | B_NAVIGABLE_JUMP |114 B_FRAME_EVENTS | B_NAVIGABLE);119 B_WILL_DRAW | B_NAVIGABLE_JUMP | 120 B_FRAME_EVENTS | B_NAVIGABLE); 115 121 ~BTabView(); 116 122 117 123 BTabView(BMessage *archive); … … 150 156 virtual void SetFlags(uint32 flags); 151 157 virtual void SetResizingMode(uint32 mode); 152 158 153 virtual void GetPreferredSize(float *width, float *height);154 virtual void ResizeToPreferred();159 virtual void ResizeToPreferred(); 160 virtual void GetPreferredSize(float* _width, float* _height); 155 161 162 virtual BSize MinSize(); 163 virtual BSize MaxSize(); 164 virtual BSize PreferredSize(); 165 156 166 virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, 157 167 BMessage *specifier, int32 what, const char *property); 158 168 virtual status_t GetSupportedSuites(BMessage *message); … … 174 184 BView *ViewForTab(int32 tabIndex) const; 175 185 176 186 private: 177 void _InitObject( );187 void _InitObject(bool layouted = false); 178 188 179 189 virtual void _ReservedTabView1(); 180 190 virtual void _ReservedTabView2(); -
src/kits/interface/TabView.cpp
10 10 11 11 #include <string.h> 12 12 13 #include <CardLayout.h> 14 #include <LayoutUtils.h> 13 15 #include <List.h> 14 16 #include <Message.h> 15 17 #include <PropertyInfo.h> … … 131 133 if (!owner || !View() || !owner->Window()) 132 134 return; 133 135 134 owner->AddChild(fView); 136 if (!owner->GetLayout()) 137 owner->AddChild(fView); 135 138 //fView->Show(); 136 139 137 140 fSelected = true; … … 139 142 140 143 141 144 void 142 BTab::Deselect( )143 { 144 if (View() )145 BTab::Deselect(bool layouted) 146 { 147 if (View() && !layouted) { 145 148 View()->RemoveSelf(); 149 } 146 150 147 151 fSelected = false; 148 152 } 149 153 150 154 151 155 void 156 BTab::Deselect() 157 { 158 Deselect(false); 159 } 160 161 162 void 152 163 BTab::SetEnabled(bool enabled) 153 164 { 154 165 fEnabled = enabled; … … 329 340 330 341 // #pragma mark - 331 342 343 BTabView::BTabView(const char *name, button_width width, uint32 flags) 344 : BView(name, flags) 345 { 346 SetFont(be_bold_font); 347 348 _InitObject(true); 349 350 fTabWidthSetting = width; 351 } 332 352 353 333 354 BTabView::BTabView(BRect frame, const char *name, button_width width, 334 355 uint32 resizingMode, uint32 flags) 335 356 : BView(frame, name, resizingMode, flags) … … 669 690 index = Selection(); 670 691 671 692 BTab *tab = TabAt(Selection()); 693 694 bool layouted = fContainerView->GetLayout() ? true : false; 695 672 696 if (tab) 673 tab->Deselect( );697 tab->Deselect(layouted); 674 698 675 699 tab = TabAt(index); 676 700 if (tab && ContainerView()) { … … 678 702 fTabOffset = 0.0f; 679 703 tab->Select(ContainerView()); 680 704 fSelection = index; 705 706 if (layouted) { 707 BCardLayout* layout = 708 dynamic_cast<BCardLayout*>(fContainerView->GetLayout()); 709 layout->SetVisibleItem(index); 710 } 681 711 } 682 712 683 713 Invalidate(); … … 917 947 } 918 948 919 949 950 BSize 951 BTabView::MinSize() 952 { 953 BSize size = fContainerView->MinSize(); 954 size.height += TabHeight() + 6.0f; 955 size.width += 6.0f; 956 return BLayoutUtils::ComposeSize(ExplicitMinSize(), size); 957 } 958 959 960 BSize 961 BTabView::MaxSize() 962 { 963 BSize size = fContainerView->MaxSize(); 964 size.height += TabHeight() + 6.0f; 965 size.width += 6.0f; 966 return BLayoutUtils::ComposeSize(ExplicitMaxSize(), size); 967 } 968 969 970 BSize 971 BTabView::PreferredSize() 972 { 973 BSize size = fContainerView->PreferredSize(); 974 size.height += TabHeight() + 6.0f; 975 size.width += 6.0f; 976 return BLayoutUtils::ComposeSize(ExplicitPreferredSize(), size); 977 } 978 979 920 980 void 921 981 BTabView::ResizeToPreferred() 922 982 { … … 957 1017 tab = new BTab(target); 958 1018 else 959 1019 tab->SetView(target); 1020 1021 if (fContainerView->GetLayout()) 1022 fContainerView->GetLayout()->AddView(CountTabs(), target); 960 1023 961 1024 fTabList->AddItem(tab); 962 1025 } … … 972 1035 if (tab == NULL) 973 1036 return NULL; 974 1037 975 tab->Deselect(); 1038 bool layouted = fContainerView->GetLayout() ? true : false; 1039 1040 tab->Deselect(layouted); 976 1041 977 1042 if (index <= fSelection && fSelection != 0) 978 1043 fSelection--; … … 987 1052 else 988 1053 SetFocusTab(fFocus, true); 989 1054 1055 if (layouted) 1056 fContainerView->GetLayout()->RemoveItem(index); 1057 990 1058 return tab; 991 1059 } 992 1060 … … 1062 1130 1063 1131 1064 1132 void 1065 BTabView::_InitObject( )1133 BTabView::_InitObject(bool layouted) 1066 1134 { 1067 1135 fTabList = new BList; 1068 1136 … … 1088 1156 fContainerView = new BView(bounds, "view container", B_FOLLOW_ALL, 1089 1157 B_WILL_DRAW); 1090 1158 1159 if (layouted) { 1160 BCardLayout* layout = new BCardLayout(); 1161 fContainerView->SetLayout(layout); 1162 } 1163 1091 1164 fContainerView->SetViewColor(color); 1092 1165 fContainerView->SetLowColor(color); 1093 1166