1 /* 2 * Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 6 #include "ViewLayoutItem.h" 7 8 #include <View.h> 9 10 11 // constructor 12 BViewLayoutItem::BViewLayoutItem(BView* view) 13 : fView(view) 14 { 15 } 16 17 // destructor 18 BViewLayoutItem::~BViewLayoutItem() 19 { 20 } 21 22 // MinSize 23 BSize 24 BViewLayoutItem::MinSize() 25 { 26 return fView->MinSize(); 27 } 28 29 // MaxSize 30 BSize 31 BViewLayoutItem::MaxSize() 32 { 33 return fView->MaxSize(); 34 } 35 36 // PreferredSize 37 BSize 38 BViewLayoutItem::PreferredSize() 39 { 40 return fView->PreferredSize(); 41 } 42 43 // Alignment 44 BAlignment 45 BViewLayoutItem::Alignment() 46 { 47 return fView->Alignment(); 48 } 49 50 // SetExplicitMinSize 51 void 52 BViewLayoutItem::SetExplicitMinSize(BSize size) 53 { 54 fView->SetExplicitMinSize(size); 55 } 56 57 // SetExplicitMaxSize 58 void 59 BViewLayoutItem::SetExplicitMaxSize(BSize size) 60 { 61 fView->SetExplicitMaxSize(size); 62 } 63 64 // SetExplicitPreferredSize 65 void 66 BViewLayoutItem::SetExplicitPreferredSize(BSize size) 67 { 68 fView->SetExplicitPreferredSize(size); 69 } 70 71 // SetExplicitAlignment 72 void 73 BViewLayoutItem::SetExplicitAlignment(BAlignment alignment) 74 { 75 fView->SetExplicitAlignment(alignment); 76 } 77 78 // IsVisible 79 bool 80 BViewLayoutItem::IsVisible() 81 { 82 return !fView->IsHidden(fView); 83 } 84 85 // SetVisible 86 void 87 BViewLayoutItem::SetVisible(bool visible) 88 { 89 if (visible != IsVisible()) { 90 if (visible) 91 fView->Show(); 92 else 93 fView->Hide(); 94 } 95 } 96 97 // Frame 98 BRect 99 BViewLayoutItem::Frame() 100 { 101 return fView->Frame(); 102 } 103 104 // SetFrame 105 void 106 BViewLayoutItem::SetFrame(BRect frame) 107 { 108 fView->MoveTo(frame.LeftTop()); 109 fView->ResizeTo(frame.Width(), frame.Height()); 110 } 111 112 // HasHeightForWidth 113 bool 114 BViewLayoutItem::HasHeightForWidth() 115 { 116 return fView->HasHeightForWidth(); 117 } 118 119 // GetHeightForWidth 120 void 121 BViewLayoutItem::GetHeightForWidth(float width, float* min, float* max, 122 float* preferred) 123 { 124 fView->GetHeightForWidth(width, min, max, preferred); 125 } 126 127 // View 128 BView* 129 BViewLayoutItem::View() 130 { 131 return fView; 132 } 133 134 // InvalidateLayout 135 void 136 BViewLayoutItem::InvalidateLayout() 137 { 138 fView->InvalidateLayout(); 139 } 140