Ticket #3161: tabview_layouted.2.diff
File tabview_layouted.2.diff, 5.0 KB (added by , 16 years ago) |
---|
-
headers/os/interface/TabView.h
106 106 class BTabView : public BView 107 107 { 108 108 public: 109 BTabView(const char *name, 110 button_width width = B_WIDTH_AS_USUAL, 111 uint32 flags = B_FULL_UPDATE_ON_RESIZE | 112 B_WILL_DRAW | B_NAVIGABLE_JUMP | 113 B_FRAME_EVENTS | B_NAVIGABLE); 109 114 BTabView(BRect frame, const char *name, 110 115 button_width width = B_WIDTH_AS_USUAL, 111 116 uint32 resizingMode = B_FOLLOW_ALL, 112 117 uint32 flags = B_FULL_UPDATE_ON_RESIZE | 113 B_WILL_DRAW | B_NAVIGABLE_JUMP |114 B_FRAME_EVENTS | B_NAVIGABLE);118 B_WILL_DRAW | B_NAVIGABLE_JUMP | 119 B_FRAME_EVENTS | B_NAVIGABLE); 115 120 ~BTabView(); 116 121 117 122 BTabView(BMessage *archive); … … 150 155 virtual void SetFlags(uint32 flags); 151 156 virtual void SetResizingMode(uint32 mode); 152 157 153 virtual void GetPreferredSize(float *width, float *height);154 virtual void ResizeToPreferred();158 virtual void ResizeToPreferred(); 159 virtual void GetPreferredSize(float* _width, float* _height); 155 160 161 virtual BSize MinSize(); 162 virtual BSize MaxSize(); 163 virtual BSize PreferredSize(); 164 156 165 virtual BHandler *ResolveSpecifier(BMessage *message, int32 index, 157 166 BMessage *specifier, int32 what, const char *property); 158 167 virtual status_t GetSupportedSuites(BMessage *message); … … 174 183 BView *ViewForTab(int32 tabIndex) const; 175 184 176 185 private: 177 void _InitObject( );186 void _InitObject(bool layouted = false); 178 187 179 188 virtual void _ReservedTabView1(); 180 189 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; … … 141 144 void 142 145 BTab::Deselect() 143 146 { 144 if (View()) 145 View()->RemoveSelf(); 146 147 if (View()) { 148 bool removeView = false; 149 BView* container = View()->Parent(); 150 if (container) 151 removeView = 152 dynamic_cast<BCardLayout*>(container->GetLayout()) == NULL; 153 if (removeView) 154 View()->RemoveSelf(); 155 } 156 147 157 fSelected = false; 148 158 } 149 159 … … 329 339 330 340 // #pragma mark - 331 341 342 BTabView::BTabView(const char *name, button_width width, uint32 flags) 343 : BView(name, flags) 344 { 345 SetFont(be_bold_font); 346 347 _InitObject(true); 348 349 fTabWidthSetting = width; 350 } 332 351 352 333 353 BTabView::BTabView(BRect frame, const char *name, button_width width, 334 354 uint32 resizingMode, uint32 flags) 335 355 : BView(frame, name, resizingMode, flags) … … 669 689 index = Selection(); 670 690 671 691 BTab *tab = TabAt(Selection()); 692 693 bool layouted = fContainerView->GetLayout() ? true : false; 694 672 695 if (tab) 673 696 tab->Deselect(); 674 697 … … 678 701 fTabOffset = 0.0f; 679 702 tab->Select(ContainerView()); 680 703 fSelection = index; 704 705 if (layouted) { 706 BCardLayout* layout = 707 dynamic_cast<BCardLayout*>(fContainerView->GetLayout()); 708 if (layout) 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 1038 bool layouted = fContainerView->GetLayout() ? true : false; 1039 975 1040 tab->Deselect(); 976 1041 977 1042 if (index <= fSelection && fSelection != 0) … … 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 if (layout) 1162 fContainerView->SetLayout(layout); 1163 } 1164 1091 1165 fContainerView->SetViewColor(color); 1092 1166 fContainerView->SetLowColor(color); 1093 1167