Beispiel #1
0
TestWindow::TestWindow(BApplication* myApp)
	: BWindow(BRect(20,20,100,100),
	  "Code Profile", B_TITLED_WINDOW, 0)
{
	BRect frm = Bounds();

	BView* myview = new BView(BRect(),"testView",0,0);
	
	BOutlineListView* olist =
		new BOutlineListView(BRect(),"MyList",
							B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE);
	if( myview && olist ) {
		myview->AddChild(olist);
		BView* vw = olist;
		vw->SetViewColor(0xc0,0xc0,0xc0);
		vw->Invalidate();
		vw->SetLowColor(0xc0,0xc0,0xc0);
		vw->Invalidate();
		vw->SetHighColor(0x00,0x00,0x00);
		vw->Invalidate();
		vw->SetFont(be_bold_font);
		this->AddChild(myview);
		BRect frm = vw->Frame();
		vw->ResizeTo(1,1);
		vw->Draw(vw->Bounds());
		vw->ResizeToPreferred();
		float w=0,h=0;
		vw->GetPreferredSize(&w,&h);
		printf("Preferred size = %f x %f\n",w,h);
	}
	
	string = new BStringView(BRect(0,0,100,20),"String",
								"Ready to profile...");	
	
	if( string ) {
		string->SetViewColor(0xc0,0xc0,0xc0);
		this->AddChild(string);
		float w=0, h=0;
		string->GetPreferredSize(&w,&h);
		MoveTo(30,30);
		ResizeTo(w,h);
	}
	
	BMenuBar* menu = new BMenuBar(BRect(),"MainMenu",B_FOLLOW_NONE);
	if( menu ) {
		this->AddChild(menu);
		float w=0, h=0;
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_plain_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_bold_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
		menu->SetFont(be_fixed_font);
		menu->GetPreferredSize(&w,&h);
		printf("Preferred Size = (%f,%f)\n",w,h);
	}
}