1 #include <Application.h> 2 #include <Button.h> 3 #include <GroupLayout.h> 4 #include <GroupLayoutBuilder.h> 5 #include <ScrollView.h> 6 #include <View.h> 7 #include <Window.h> 8 9 10 class Window : public BWindow { 11 public: 12 Window() : BWindow(BRect(100, 100, 300, 300), "", B_TITLED_WINDOW, 13 B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | 14 B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE) 15 { 16 BGroupLayout* base = new BGroupLayout(B_HORIZONTAL); 17 SetLayout(base); 18 19 BView* view = new BView("", B_WILL_DRAW, NULL); 20 view->SetViewColor(255, 0, 0, 255); 21 view->SetExplicitMinSize(BSize(B_SIZE_UNSET, 200)); 22 23 fScrollView = new BScrollView("mit", view, B_NAVIGABLE_JUMP, true, 24 true, B_NO_BORDER); 25 26 BView* view2 = new BView(BRect(0, 0, 200, 200), "", B_FOLLOW_ALL, 27 B_WILL_DRAW); 28 view2->SetViewColor(255, 0, 0, 255); 29 30 fScrollView2 = new BScrollView("ohne", view2, B_FOLLOW_ALL, 31 B_NAVIGABLE_JUMP, true, true, B_NO_BORDER); 32 33 BButton* one = new BButton("No Border", new BMessage('nobd')); 34 BButton* two = new BButton("Plain Border", new BMessage('plbd')); 35 BButton* three = new BButton("Fancy Border", new BMessage('fcbd')); 36 37 base->AddView(BGroupLayoutBuilder(B_VERTICAL, 5.0) 38 .Add(fScrollView) 39 .Add(fScrollView2) 40 .AddGroup(B_HORIZONTAL, 5.0) 41 .Add(one) 42 .Add(two) 43 .Add(three) 44 .End() 45 .SetInsets(10.0, 10.0, 10.0, 10.0)); 46 47 PrintToStream(); 48 } 49 50 void MessageReceived(BMessage* message) 51 { 52 switch(message->what) { 53 case 'nobd': 54 fScrollView->SetBorder(B_NO_BORDER); 55 fScrollView2->SetBorder(B_NO_BORDER); 56 57 PrintToStream(); 58 break; 59 60 case 'plbd': 61 fScrollView->SetBorder(B_PLAIN_BORDER); 62 fScrollView2->SetBorder(B_PLAIN_BORDER); 63 64 PrintToStream(); 65 break; 66 67 case 'fcbd': 68 fScrollView->SetBorder(B_FANCY_BORDER); 69 fScrollView2->SetBorder(B_FANCY_BORDER); 70 71 PrintToStream(); 72 break; 73 74 default: 75 BWindow::MessageReceived(message); 76 break; 77 } 78 } 79 80 void PrintToStream() 81 { 82 BView* view = fScrollView->Target(); 83 BView* view2 = fScrollView2->Target(); 84 85 view->Bounds().PrintToStream(); 86 view->Frame().PrintToStream(); 87 88 view2->Bounds().PrintToStream(); 89 view2->Frame().PrintToStream(); 90 } 91 92 private: 93 BScrollView* fScrollView; 94 BScrollView* fScrollView2; 95 }; 96 97 98 class Application : public BApplication { 99 public: 100 Application() : BApplication("application/x-vnd.scrollview") {} 101 ~Application() {} 102 103 void ReadyToRun() 104 { 105 Window* win = new Window(); 106 win->Show(); 107 } 108 }; 109 110 111 int main(int argc, char* argv[]) 112 { 113 Application app; 114 return app.Run(); 115 } 116