178c1c29bSStephan Aßmus // main.cpp 278c1c29bSStephan Aßmus 378c1c29bSStephan Aßmus #include <stdio.h> 478c1c29bSStephan Aßmus #include <stdlib.h> 578c1c29bSStephan Aßmus 678c1c29bSStephan Aßmus #include <Application.h> 74dfc2afbSAxel Dörfler #include <Alert.h> 878c1c29bSStephan Aßmus #include <Box.h> 978c1c29bSStephan Aßmus #include <Button.h> 1078c1c29bSStephan Aßmus #include <CheckBox.h> 1178c1c29bSStephan Aßmus #include <Menu.h> 1278c1c29bSStephan Aßmus #include <MenuBar.h> 1381cc749fSStephan Aßmus #include <MenuField.h> 1478c1c29bSStephan Aßmus #include <MenuItem.h> 1581cc749fSStephan Aßmus #include <PopUpMenu.h> 16b7f478e2SStephan Aßmus #include <Slider.h> 1778c1c29bSStephan Aßmus #include <String.h> 1878c1c29bSStephan Aßmus #include <RadioButton.h> 1978c1c29bSStephan Aßmus #include <TextControl.h> 2078c1c29bSStephan Aßmus #include <TextView.h> 2178c1c29bSStephan Aßmus 2278c1c29bSStephan Aßmus #include "ObjectView.h" 2378c1c29bSStephan Aßmus #include "States.h" 2478c1c29bSStephan Aßmus 2578c1c29bSStephan Aßmus #include "ObjectWindow.h" 2678c1c29bSStephan Aßmus 2778c1c29bSStephan Aßmus enum { 2878c1c29bSStephan Aßmus MSG_SET_OBJECT_TYPE = 'stot', 2978c1c29bSStephan Aßmus MSG_SET_FILL_OR_STROKE = 'stfs', 3078c1c29bSStephan Aßmus MSG_SET_COLOR = 'stcl', 3178c1c29bSStephan Aßmus MSG_SET_PEN_SIZE = 'stps', 3281cc749fSStephan Aßmus MSG_SET_DRAWING_MODE = 'stdm', 3378c1c29bSStephan Aßmus 3478c1c29bSStephan Aßmus MSG_NEW_OBJECT = 'nobj', 3578c1c29bSStephan Aßmus 3678c1c29bSStephan Aßmus MSG_UNDO = 'undo', 3778c1c29bSStephan Aßmus MSG_REDO = 'redo', 3878c1c29bSStephan Aßmus 3978c1c29bSStephan Aßmus MSG_CLEAR = 'clir', 4078c1c29bSStephan Aßmus }; 4178c1c29bSStephan Aßmus 4278c1c29bSStephan Aßmus // constructor 4378c1c29bSStephan Aßmus ObjectWindow::ObjectWindow(BRect frame, const char* name) 44b7f478e2SStephan Aßmus : BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 45b7f478e2SStephan Aßmus B_ASYNCHRONOUS_CONTROLS) 46b7f478e2SStephan Aßmus // : BWindow(frame, name, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 47b7f478e2SStephan Aßmus // B_ASYNCHRONOUS_CONTROLS) 48b7f478e2SStephan Aßmus // : BWindow(frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 49b7f478e2SStephan Aßmus // B_ASYNCHRONOUS_CONTROLS) 50b7f478e2SStephan Aßmus // : BWindow(frame, name, B_BORDERED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 51b7f478e2SStephan Aßmus // B_ASYNCHRONOUS_CONTROLS) 52b7f478e2SStephan Aßmus // : BWindow(frame, name, B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, 53b7f478e2SStephan Aßmus // B_ASYNCHRONOUS_CONTROLS) 5478c1c29bSStephan Aßmus { 5578c1c29bSStephan Aßmus BRect b(Bounds()); 5678c1c29bSStephan Aßmus 5778c1c29bSStephan Aßmus b.bottom = b.top + 8; 5878c1c29bSStephan Aßmus BMenuBar* menuBar = new BMenuBar(b, "menu bar"); 5978c1c29bSStephan Aßmus AddChild(menuBar); 6078c1c29bSStephan Aßmus 6178c1c29bSStephan Aßmus BMenu* menu = new BMenu("Menus"); 6278c1c29bSStephan Aßmus menuBar->AddItem(menu); 6378c1c29bSStephan Aßmus 64*590fdd3fSStephan Aßmus BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 65*590fdd3fSStephan Aßmus 'T'); 6678c1c29bSStephan Aßmus menu->AddItem(menuItem); 6778c1c29bSStephan Aßmus 6878c1c29bSStephan Aßmus menuBar->AddItem(new BMenu("don't")); 6978c1c29bSStephan Aßmus menuBar->AddItem(new BMenu("work!")); 7078c1c29bSStephan Aßmus menuBar->AddItem(new BMenu("(yet)")); 7178c1c29bSStephan Aßmus 7278c1c29bSStephan Aßmus b = Bounds(); 7378c1c29bSStephan Aßmus b.top = menuBar->Bounds().bottom + 1; 7478c1c29bSStephan Aßmus BBox* bg = new BBox(b, "bg box", B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER); 7578c1c29bSStephan Aßmus 7678c1c29bSStephan Aßmus AddChild(bg); 7778c1c29bSStephan Aßmus bg->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 7878c1c29bSStephan Aßmus 7978c1c29bSStephan Aßmus b = bg->Bounds(); 8078c1c29bSStephan Aßmus // object views occupies the right side of the window 8178c1c29bSStephan Aßmus b.Set(ceilf((b.left + b.right) / 3.0) + 3.0, b.top + 5.0, b.right - 5.0, b.bottom - 5.0); 8278c1c29bSStephan Aßmus fObjectView = new ObjectView(b, "object view", B_FOLLOW_ALL, 8378c1c29bSStephan Aßmus B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); 8478c1c29bSStephan Aßmus 8578c1c29bSStephan Aßmus bg->AddChild(fObjectView); 8678c1c29bSStephan Aßmus 8778c1c29bSStephan Aßmus b = bg->Bounds(); 8878c1c29bSStephan Aßmus // controls occupy the left side of the window 8978c1c29bSStephan Aßmus b.Set(b.left + 5.0, b.top + 5.0, ceilf((b.left + b.right) / 3.0) - 2.0, b.bottom - 5.0); 9078c1c29bSStephan Aßmus BBox* controlGroup = new BBox(b, "controls box", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, 9178c1c29bSStephan Aßmus B_WILL_DRAW, B_FANCY_BORDER); 9278c1c29bSStephan Aßmus 9378c1c29bSStephan Aßmus controlGroup->SetLabel("Controls"); 9478c1c29bSStephan Aßmus bg->AddChild(controlGroup); 9578c1c29bSStephan Aßmus 9678c1c29bSStephan Aßmus b = controlGroup->Bounds(); 9778c1c29bSStephan Aßmus b.top += 10.0; 9878c1c29bSStephan Aßmus b.bottom = b.top + 25.0; 9978c1c29bSStephan Aßmus b.InsetBy(5.0, 5.0); 10078c1c29bSStephan Aßmus 10178c1c29bSStephan Aßmus // new button 10278c1c29bSStephan Aßmus fNewB = new BButton(b, "new button", "New Object", new BMessage(MSG_NEW_OBJECT)); 10378c1c29bSStephan Aßmus controlGroup->AddChild(fNewB); 10478c1c29bSStephan Aßmus 10578c1c29bSStephan Aßmus // clear button 10678c1c29bSStephan Aßmus b.OffsetBy(0, fNewB->Bounds().Height() + 5.0); 10778c1c29bSStephan Aßmus fClearB = new BButton(b, "clear button", "Clear", new BMessage(MSG_CLEAR)); 10878c1c29bSStephan Aßmus controlGroup->AddChild(fClearB); 10978c1c29bSStephan Aßmus 11078c1c29bSStephan Aßmus // object type radio buttons 11178c1c29bSStephan Aßmus BMessage* message; 11278c1c29bSStephan Aßmus BRadioButton* radioButton; 11378c1c29bSStephan Aßmus 11478c1c29bSStephan Aßmus b.OffsetBy(0, fClearB->Bounds().Height() + 5.0); 11578c1c29bSStephan Aßmus message = new BMessage(MSG_SET_OBJECT_TYPE); 11678c1c29bSStephan Aßmus message->AddInt32("type", OBJECT_LINE); 11778c1c29bSStephan Aßmus radioButton = new BRadioButton(b, "radio 1", "Line", message); 11878c1c29bSStephan Aßmus controlGroup->AddChild(radioButton); 11978c1c29bSStephan Aßmus 12078c1c29bSStephan Aßmus radioButton->SetValue(B_CONTROL_ON); 12178c1c29bSStephan Aßmus 12278c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 12378c1c29bSStephan Aßmus message = new BMessage(MSG_SET_OBJECT_TYPE); 12478c1c29bSStephan Aßmus message->AddInt32("type", OBJECT_RECT); 12578c1c29bSStephan Aßmus radioButton = new BRadioButton(b, "radio 2", "Rect", message); 12678c1c29bSStephan Aßmus controlGroup->AddChild(radioButton); 12778c1c29bSStephan Aßmus 12878c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 12978c1c29bSStephan Aßmus message = new BMessage(MSG_SET_OBJECT_TYPE); 13078c1c29bSStephan Aßmus message->AddInt32("type", OBJECT_ROUND_RECT); 13178c1c29bSStephan Aßmus radioButton = new BRadioButton(b, "radio 3", "Round Rect", message); 13278c1c29bSStephan Aßmus controlGroup->AddChild(radioButton); 13378c1c29bSStephan Aßmus 13478c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 13578c1c29bSStephan Aßmus message = new BMessage(MSG_SET_OBJECT_TYPE); 13678c1c29bSStephan Aßmus message->AddInt32("type", OBJECT_ELLIPSE); 13778c1c29bSStephan Aßmus radioButton = new BRadioButton(b, "radio 4", "Ellipse", message); 13878c1c29bSStephan Aßmus controlGroup->AddChild(radioButton); 13978c1c29bSStephan Aßmus 14081cc749fSStephan Aßmus // drawing mode 14181cc749fSStephan Aßmus /* BPopUpMenu* popupMenu = new BPopUpMenu("<pick>"); 14281cc749fSStephan Aßmus 14381cc749fSStephan Aßmus message = new BMessage(MSG_SET_DRAWING_MODE); 14481cc749fSStephan Aßmus message->AddInt32("mode", B_OP_COPY); 14581cc749fSStephan Aßmus popupMenu->AddItem(new BMenuItem("B_OP_COPY", message)); 14681cc749fSStephan Aßmus 14781cc749fSStephan Aßmus message = new BMessage(MSG_SET_DRAWING_MODE); 14881cc749fSStephan Aßmus message->AddInt32("mode", B_OP_OVER); 14981cc749fSStephan Aßmus popupMenu->AddItem(new BMenuItem("B_OP_OVER", message)); 15081cc749fSStephan Aßmus 15181cc749fSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 15281cc749fSStephan Aßmus fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode", 15381cc749fSStephan Aßmus popupMenu); 15481cc749fSStephan Aßmus 15581cc749fSStephan Aßmus controlGroup->AddChild(fDrawingModeMF); 15681cc749fSStephan Aßmus 15781cc749fSStephan Aßmus fDrawingModeMF->SetDivider(fDrawingModeMF->StringWidth(fDrawingModeMF->Label()) + 10.0); 15881cc749fSStephan Aßmus */ 15978c1c29bSStephan Aßmus // red text control 16078c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 16178c1c29bSStephan Aßmus fRedTC = new BTextControl(b, "red text control", "Red", "", 16278c1c29bSStephan Aßmus new BMessage(MSG_SET_COLOR)); 16378c1c29bSStephan Aßmus controlGroup->AddChild(fRedTC); 16478c1c29bSStephan Aßmus 16578c1c29bSStephan Aßmus // green text control 16678c1c29bSStephan Aßmus b.OffsetBy(0, fRedTC->Bounds().Height() + 5.0); 16778c1c29bSStephan Aßmus fGreenTC = new BTextControl(b, "green text control", "Green", "", 16878c1c29bSStephan Aßmus new BMessage(MSG_SET_COLOR)); 16978c1c29bSStephan Aßmus controlGroup->AddChild(fGreenTC); 17078c1c29bSStephan Aßmus 17178c1c29bSStephan Aßmus // blue text control 17278c1c29bSStephan Aßmus b.OffsetBy(0, fGreenTC->Bounds().Height() + 5.0); 17378c1c29bSStephan Aßmus fBlueTC = new BTextControl(b, "blue text control", "Blue", "", 17478c1c29bSStephan Aßmus new BMessage(MSG_SET_COLOR)); 17578c1c29bSStephan Aßmus controlGroup->AddChild(fBlueTC); 17678c1c29bSStephan Aßmus 17778c1c29bSStephan Aßmus // alpha text control 17878c1c29bSStephan Aßmus b.OffsetBy(0, fBlueTC->Bounds().Height() + 5.0); 17978c1c29bSStephan Aßmus fAlphaTC = new BTextControl(b, "alpha text control", "Alpha", "", 18078c1c29bSStephan Aßmus new BMessage(MSG_SET_COLOR)); 18178c1c29bSStephan Aßmus controlGroup->AddChild(fAlphaTC); 18278c1c29bSStephan Aßmus /* 18378c1c29bSStephan Aßmus // TODO: while this block of code works in the Haiku app_server running under R5, 18478c1c29bSStephan Aßmus // it crashes pretty badly under Haiku. I have no idea why this happens, because 18578c1c29bSStephan Aßmus // I was doing the same thing before at other places. 18678c1c29bSStephan Aßmus // divide text controls the same 18778c1c29bSStephan Aßmus float rWidth = fRedTC->StringWidth(fRedTC->Label()); 18878c1c29bSStephan Aßmus float gWidth = fGreenTC->StringWidth(fGreenTC->Label()); 18978c1c29bSStephan Aßmus float bWidth = fBlueTC->StringWidth(fBlueTC->Label()); 19078c1c29bSStephan Aßmus float aWidth = fAlphaTC->StringWidth(fAlphaTC->Label()); 19178c1c29bSStephan Aßmus 19278c1c29bSStephan Aßmus float width = max_c(rWidth, max_c(gWidth, max_c(bWidth, aWidth))) + 10.0; 19378c1c29bSStephan Aßmus fRedTC->SetDivider(width); 19478c1c29bSStephan Aßmus fGreenTC->SetDivider(width); 19578c1c29bSStephan Aßmus fBlueTC->SetDivider(width); 19678c1c29bSStephan Aßmus fAlphaTC->SetDivider(width);*/ 19778c1c29bSStephan Aßmus 19878c1c29bSStephan Aßmus // fill check box 19978c1c29bSStephan Aßmus b.OffsetBy(0, fAlphaTC->Bounds().Height() + 5.0); 20078c1c29bSStephan Aßmus fFillCB = new BCheckBox(b, "fill check box", "Fill", 20178c1c29bSStephan Aßmus new BMessage(MSG_SET_FILL_OR_STROKE)); 20278c1c29bSStephan Aßmus controlGroup->AddChild(fFillCB); 20378c1c29bSStephan Aßmus 20478c1c29bSStephan Aßmus // pen size text control 20578c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 206b7f478e2SStephan Aßmus b.bottom = b.top + 10.0;//35; 207b7f478e2SStephan Aßmus fPenSizeS = new BSlider(b, "width slider", "Width", 208b7f478e2SStephan Aßmus NULL, 1, 100, B_TRIANGLE_THUMB); 209b7f478e2SStephan Aßmus fPenSizeS->SetLimitLabels("1", "100"); 210b7f478e2SStephan Aßmus fPenSizeS->SetModificationMessage(new BMessage(MSG_SET_PEN_SIZE)); 211b7f478e2SStephan Aßmus fPenSizeS->SetHashMarks(B_HASH_MARKS_BOTTOM); 212b7f478e2SStephan Aßmus fPenSizeS->SetHashMarkCount(10); 213b7f478e2SStephan Aßmus 214b7f478e2SStephan Aßmus controlGroup->AddChild(fPenSizeS); 215b7f478e2SStephan Aßmus 216b7f478e2SStephan Aßmus // enforce some size limits 217b7f478e2SStephan Aßmus float minWidth = controlGroup->Frame().Width() + 30.0; 218b7f478e2SStephan Aßmus float minHeight = fPenSizeS->Frame().bottom + 219b7f478e2SStephan Aßmus menuBar->Bounds().Height() + 15.0; 220b7f478e2SStephan Aßmus float maxWidth = minWidth * 4.0; 221b7f478e2SStephan Aßmus float maxHeight = minHeight; 222b7f478e2SStephan Aßmus SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight); 22378c1c29bSStephan Aßmus 224e4bcf6e0SStephan Aßmus ResizeTo(max_c(frame.Width(), minWidth), max_c(frame.Height(), minHeight)); 225e4bcf6e0SStephan Aßmus 22678c1c29bSStephan Aßmus _UpdateControls(); 22778c1c29bSStephan Aßmus } 22878c1c29bSStephan Aßmus 22978c1c29bSStephan Aßmus // destructor 23078c1c29bSStephan Aßmus ObjectWindow::~ObjectWindow() 23178c1c29bSStephan Aßmus { 23278c1c29bSStephan Aßmus } 23378c1c29bSStephan Aßmus 23478c1c29bSStephan Aßmus // QuitRequested 23578c1c29bSStephan Aßmus bool 23678c1c29bSStephan Aßmus ObjectWindow::QuitRequested() 23778c1c29bSStephan Aßmus { 23878c1c29bSStephan Aßmus be_app->PostMessage(B_QUIT_REQUESTED); 23978c1c29bSStephan Aßmus return true; 24078c1c29bSStephan Aßmus } 24178c1c29bSStephan Aßmus 24278c1c29bSStephan Aßmus // MessageReceived 24378c1c29bSStephan Aßmus void 24478c1c29bSStephan Aßmus ObjectWindow::MessageReceived(BMessage* message) 24578c1c29bSStephan Aßmus { 24678c1c29bSStephan Aßmus switch (message->what) { 24778c1c29bSStephan Aßmus case MSG_SET_OBJECT_TYPE: { 24878c1c29bSStephan Aßmus int32 type; 24978c1c29bSStephan Aßmus if (message->FindInt32("type", &type) >= B_OK) { 25078c1c29bSStephan Aßmus fObjectView->SetObjectType(type); 25178c1c29bSStephan Aßmus fFillCB->SetEnabled(type != OBJECT_LINE); 252e803c97cSStephan Aßmus if (!fFillCB->IsEnabled()) 253b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(true); 254e803c97cSStephan Aßmus else 255b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(fFillCB->Value() == B_CONTROL_OFF); 25678c1c29bSStephan Aßmus } 25778c1c29bSStephan Aßmus break; 25878c1c29bSStephan Aßmus } 25978c1c29bSStephan Aßmus case MSG_SET_FILL_OR_STROKE: { 26078c1c29bSStephan Aßmus int32 value; 26178c1c29bSStephan Aßmus if (message->FindInt32("be:value", &value) >= B_OK) { 26278c1c29bSStephan Aßmus fObjectView->SetStateFill(value); 263b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(value == B_CONTROL_OFF); 26478c1c29bSStephan Aßmus } 26578c1c29bSStephan Aßmus break; 26678c1c29bSStephan Aßmus } 26778c1c29bSStephan Aßmus case MSG_SET_COLOR: 26878c1c29bSStephan Aßmus fObjectView->SetStateColor(_GetColor()); 26981cc749fSStephan Aßmus _UpdateColorControls(); 27078c1c29bSStephan Aßmus break; 27178c1c29bSStephan Aßmus case MSG_OBJECT_COUNT_CHANGED: 27278c1c29bSStephan Aßmus fClearB->SetEnabled(fObjectView->CountObjects() > 0); 27378c1c29bSStephan Aßmus break; 27478c1c29bSStephan Aßmus case MSG_NEW_OBJECT: 27578c1c29bSStephan Aßmus fObjectView->SetState(NULL); 27678c1c29bSStephan Aßmus break; 2774dfc2afbSAxel Dörfler case MSG_CLEAR: { 278*590fdd3fSStephan Aßmus BAlert *alert = new BAlert("Playground", "Do you really want to clear all drawing objects?", "No", "Yes"); 279*590fdd3fSStephan Aßmus if (alert->Go() == 1) { 280*590fdd3fSStephan Aßmus printf("calling make empty\n"); 28178c1c29bSStephan Aßmus fObjectView->MakeEmpty(); 282*590fdd3fSStephan Aßmus } 283*590fdd3fSStephan Aßmus printf("done\n"); 28478c1c29bSStephan Aßmus break; 2854dfc2afbSAxel Dörfler } 28678c1c29bSStephan Aßmus case MSG_SET_PEN_SIZE: 287b7f478e2SStephan Aßmus fObjectView->SetStatePenSize((float)fPenSizeS->Value()); 28878c1c29bSStephan Aßmus break; 28978c1c29bSStephan Aßmus default: 29078c1c29bSStephan Aßmus BWindow::MessageReceived(message); 29178c1c29bSStephan Aßmus } 29278c1c29bSStephan Aßmus } 29378c1c29bSStephan Aßmus 29478c1c29bSStephan Aßmus // _UpdateControls 29578c1c29bSStephan Aßmus void 29678c1c29bSStephan Aßmus ObjectWindow::_UpdateControls() const 29778c1c29bSStephan Aßmus { 29881cc749fSStephan Aßmus _UpdateColorControls(); 29981cc749fSStephan Aßmus 30081cc749fSStephan Aßmus // update buttons 30181cc749fSStephan Aßmus fClearB->SetEnabled(fObjectView->CountObjects() > 0); 30281cc749fSStephan Aßmus 30381cc749fSStephan Aßmus fFillCB->SetEnabled(fObjectView->ObjectType() != OBJECT_LINE); 30481cc749fSStephan Aßmus 30581cc749fSStephan Aßmus // pen size 306b7f478e2SStephan Aßmus fPenSizeS->SetValue((int32)fObjectView->StatePenSize()); 30781cc749fSStephan Aßmus 30881cc749fSStephan Aßmus // disable penSize if fill is on 30981cc749fSStephan Aßmus if (!fFillCB->IsEnabled()) 310b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(true); 31181cc749fSStephan Aßmus else 312b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(fFillCB->Value() == B_CONTROL_OFF); 31381cc749fSStephan Aßmus } 31481cc749fSStephan Aßmus 31581cc749fSStephan Aßmus // _UpdateColorControls 31681cc749fSStephan Aßmus void 31781cc749fSStephan Aßmus ObjectWindow::_UpdateColorControls() const 31881cc749fSStephan Aßmus { 31978c1c29bSStephan Aßmus // update color 32078c1c29bSStephan Aßmus rgb_color c = fObjectView->StateColor(); 32178c1c29bSStephan Aßmus char string[32]; 32278c1c29bSStephan Aßmus 32378c1c29bSStephan Aßmus sprintf(string, "%d", c.red); 32478c1c29bSStephan Aßmus fRedTC->SetText(string); 32578c1c29bSStephan Aßmus 32678c1c29bSStephan Aßmus sprintf(string, "%d", c.green); 32778c1c29bSStephan Aßmus fGreenTC->SetText(string); 32878c1c29bSStephan Aßmus 32978c1c29bSStephan Aßmus sprintf(string, "%d", c.blue); 33078c1c29bSStephan Aßmus fBlueTC->SetText(string); 33178c1c29bSStephan Aßmus 33278c1c29bSStephan Aßmus sprintf(string, "%d", c.alpha); 33378c1c29bSStephan Aßmus fAlphaTC->SetText(string); 33478c1c29bSStephan Aßmus } 33578c1c29bSStephan Aßmus 33678c1c29bSStephan Aßmus // _GetColor 33778c1c29bSStephan Aßmus rgb_color 33878c1c29bSStephan Aßmus ObjectWindow::_GetColor() const 33978c1c29bSStephan Aßmus { 34078c1c29bSStephan Aßmus rgb_color c; 34178c1c29bSStephan Aßmus c.red = max_c(0, min_c(255, atoi(fRedTC->Text()))); 34278c1c29bSStephan Aßmus c.green = max_c(0, min_c(255, atoi(fGreenTC->Text()))); 34378c1c29bSStephan Aßmus c.blue = max_c(0, min_c(255, atoi(fBlueTC->Text()))); 34478c1c29bSStephan Aßmus c.alpha = max_c(0, min_c(255, atoi(fAlphaTC->Text()))); 34578c1c29bSStephan Aßmus 34678c1c29bSStephan Aßmus return c; 34778c1c29bSStephan Aßmus } 34878c1c29bSStephan Aßmus 349