Ticket #2837: 2837.diff
File 2837.diff, 5.4 KB (added by , 15 years ago) |
---|
-
src/tests/servers/app/playground/ObjectWindow.cpp
9 9 #include <Box.h> 10 10 #include <Button.h> 11 11 #include <CheckBox.h> 12 #include <ColorControl.h> 12 13 #include <ListItem.h> 13 14 #include <ListView.h> 14 15 #include <Menu.h> … … 285 286 item->SetMarked(true); 286 287 popupMenu->AddItem(item); 287 288 288 b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);289 b.OffsetBy(0, radioButton->Bounds().Height() + 10.0); 289 290 fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode", 290 291 popupMenu); 291 292 292 293 controlGroup->AddChild(fDrawingModeMF); 293 294 294 295 fDrawingModeMF->SetDivider(fDrawingModeMF->StringWidth(fDrawingModeMF->Label()) + 10.0); 295 296 // red text control 297 b.OffsetBy(0, fDrawingModeMF->Bounds().Height() + 5.0); 298 fRedTC = new BTextControl(b, "red text control", "Red", "", 299 new BMessage(MSG_SET_COLOR)); 300 controlGroup->AddChild(fRedTC); 301 302 // green text control 303 b.OffsetBy(0, fRedTC->Bounds().Height() + 5.0); 304 fGreenTC = new BTextControl(b, "green text control", "Green", "", 305 new BMessage(MSG_SET_COLOR)); 306 controlGroup->AddChild(fGreenTC); 307 308 // blue text control 309 b.OffsetBy(0, fGreenTC->Bounds().Height() + 5.0); 310 fBlueTC = new BTextControl(b, "blue text control", "Blue", "", 311 new BMessage(MSG_SET_COLOR)); 312 controlGroup->AddChild(fBlueTC); 313 296 297 // color control 298 b.OffsetBy(0, fDrawingModeMF->Bounds().Height() + 10.0); 299 fColorControl = new BColorControl(b.LeftTop(), B_CELLS_16x16, 8, "color control", 300 new BMessage(MSG_SET_COLOR)); 301 controlGroup->AddChild(fColorControl); 302 314 303 // alpha text control 315 b.OffsetBy(0, f BlueTC->Bounds().Height() + 5.0);304 b.OffsetBy(0, fColorControl-> Bounds().Height() + 5.0); 316 305 fAlphaTC = new BTextControl(b, "alpha text control", "Alpha", "", 317 306 new BMessage(MSG_SET_COLOR)); 318 307 controlGroup->AddChild(fAlphaTC); 319 308 320 309 // divide text controls the same 321 float mWidth = fDrawingModeMF->StringWidth(fDrawingModeMF->Label()); 322 float rWidth = fRedTC->StringWidth(fRedTC->Label()); 323 float gWidth = fGreenTC->StringWidth(fGreenTC->Label()); 324 float bWidth = fBlueTC->StringWidth(fBlueTC->Label()); 325 float aWidth = fAlphaTC->StringWidth(fAlphaTC->Label()); 326 327 float width = max_c(mWidth, max_c(rWidth, max_c(gWidth, max_c(bWidth, aWidth)))) + 10.0; 310 float mWidth = fDrawingModeMF->StringWidth(fDrawingModeMF->Label()); 311 float aWidth = fAlphaTC->StringWidth(fAlphaTC->Label()); 312 313 float width = max_c(mWidth, aWidth) + 20.0; 328 314 fDrawingModeMF->SetDivider(width); 329 fRedTC->SetDivider(width);330 fGreenTC->SetDivider(width);331 fBlueTC->SetDivider(width);332 315 fAlphaTC->SetDivider(width); 333 316 334 317 // fill check box … … 355 338 b.InsetBy(9.0, 7.0); 356 339 b.left = b.left + b.Width() / 2.0 + 6.0; 357 340 b.right -= B_V_SCROLL_BAR_WIDTH; 358 b.bottom = fDrawingModeMF->Frame().top - 5.0;341 b.bottom = fDrawingModeMF->Frame().top - 10.0; 359 342 360 343 fObjectLV = new ObjectListView(b, "object list", B_SINGLE_SELECTION_LIST); 361 344 fObjectLV->SetSelectionMessage(new BMessage(MSG_OBJECT_SELECTED)); … … 366 349 B_FANCY_BORDER); 367 350 controlGroup->AddChild(scrollView); 368 351 369 // add a dummy tab view370 b.top = b.bottom + 10.0;371 b.right += B_V_SCROLL_BAR_WIDTH;372 b.bottom = controlGroup->Bounds().bottom - 7.0;373 BTabView* tabView = new BTabView(b, "tab view", B_WIDTH_FROM_WIDEST,374 B_FOLLOW_ALL, B_FULL_UPDATE_ON_RESIZE |375 B_WILL_DRAW | B_NAVIGABLE_JUMP |376 B_FRAME_EVENTS | B_NAVIGABLE);377 378 BView* tabChild = new TestView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0);379 tabView->AddTab(tabChild);380 tabChild = new TestView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0);381 tabView->AddTab(tabChild);382 tabChild = new BTextControl(BRect(0, 0, 80, 40), "T", "Test", "Text", NULL);383 tabView->AddTab(tabChild);384 controlGroup->AddChild(tabView);385 386 352 // enforce some size limits 387 353 float minWidth = controlGroup->Frame().Width() + 30.0; 388 354 float minHeight = fPenSizeS->Frame().bottom + … … 520 486 rgb_color c = fObjectView->StateColor(); 521 487 char string[32]; 522 488 523 sprintf(string, "%d", c.red);524 fRedTC->SetText(string);525 526 sprintf(string, "%d", c.green);527 fGreenTC->SetText(string);528 529 sprintf(string, "%d", c.blue);530 fBlueTC->SetText(string);531 532 489 sprintf(string, "%d", c.alpha); 533 490 fAlphaTC->SetText(string); 491 492 fColorControl->SetValue(c); 534 493 } 535 494 536 495 // _GetColor … … 538 497 ObjectWindow::_GetColor() const 539 498 { 540 499 rgb_color c; 541 c.red = max_c(0, min_c(255, atoi(fRedTC->Text()))); 542 c.green = max_c(0, min_c(255, atoi(fGreenTC->Text()))); 543 c.blue = max_c(0, min_c(255, atoi(fBlueTC->Text()))); 544 c.alpha = max_c(0, min_c(255, atoi(fAlphaTC->Text()))); 545 500 501 c = fColorControl->ValueAsColor(); 502 c.alpha = max_c(0, min_c(255, atoi(fAlphaTC->Text()))); 503 546 504 return c; 547 505 } 548 506 -
src/tests/servers/app/playground/ObjectWindow.h
7 7 8 8 class BButton; 9 9 class BCheckBox; 10 class BColorControl; 10 11 class BListView; 11 12 class BMenuField; 12 13 class BTextControl; … … 37 38 38 39 BMenuField* fDrawingModeMF; 39 40 40 BTextControl* fRedTC; 41 BTextControl* fGreenTC; 42 BTextControl* fBlueTC; 41 BColorControl* fColorControl; 43 42 BTextControl* fAlphaTC; 44 43 45 44 BCheckBox* fFillCB;