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 61*d5233162SStephan Aßmus BMenu* menu = new BMenu("File"); 6278c1c29bSStephan Aßmus menuBar->AddItem(menu); 6378c1c29bSStephan Aßmus 64590fdd3fSStephan Aßmus BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 65*d5233162SStephan Aßmus 'Q'); 6678c1c29bSStephan Aßmus menu->AddItem(menuItem); 6778c1c29bSStephan Aßmus 6878c1c29bSStephan Aßmus b = Bounds(); 6978c1c29bSStephan Aßmus b.top = menuBar->Bounds().bottom + 1; 7078c1c29bSStephan Aßmus BBox* bg = new BBox(b, "bg box", B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER); 7178c1c29bSStephan Aßmus 7278c1c29bSStephan Aßmus AddChild(bg); 7378c1c29bSStephan Aßmus bg->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 7478c1c29bSStephan Aßmus 7578c1c29bSStephan Aßmus b = bg->Bounds(); 7678c1c29bSStephan Aßmus // object views occupies the right side of the window 7778c1c29bSStephan 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); 7878c1c29bSStephan Aßmus fObjectView = new ObjectView(b, "object view", B_FOLLOW_ALL, 7978c1c29bSStephan Aßmus B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); 8078c1c29bSStephan Aßmus 8178c1c29bSStephan Aßmus bg->AddChild(fObjectView); 8278c1c29bSStephan Aßmus 8378c1c29bSStephan Aßmus b = bg->Bounds(); 8478c1c29bSStephan Aßmus // controls occupy the left side of the window 8578c1c29bSStephan 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); 8678c1c29bSStephan Aßmus BBox* controlGroup = new BBox(b, "controls box", B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, 8778c1c29bSStephan Aßmus B_WILL_DRAW, B_FANCY_BORDER); 8878c1c29bSStephan Aßmus 8978c1c29bSStephan Aßmus controlGroup->SetLabel("Controls"); 9078c1c29bSStephan Aßmus bg->AddChild(controlGroup); 9178c1c29bSStephan Aßmus 9278c1c29bSStephan Aßmus b = controlGroup->Bounds(); 9378c1c29bSStephan Aßmus b.top += 10.0; 9478c1c29bSStephan Aßmus b.bottom = b.top + 25.0; 9578c1c29bSStephan Aßmus b.InsetBy(5.0, 5.0); 9678c1c29bSStephan Aßmus 9778c1c29bSStephan Aßmus // new button 9878c1c29bSStephan Aßmus fNewB = new BButton(b, "new button", "New Object", new BMessage(MSG_NEW_OBJECT)); 9978c1c29bSStephan Aßmus controlGroup->AddChild(fNewB); 10078c1c29bSStephan Aßmus 10178c1c29bSStephan Aßmus // clear button 10278c1c29bSStephan Aßmus b.OffsetBy(0, fNewB->Bounds().Height() + 5.0); 10378c1c29bSStephan Aßmus fClearB = new BButton(b, "clear button", "Clear", new BMessage(MSG_CLEAR)); 10478c1c29bSStephan Aßmus controlGroup->AddChild(fClearB); 10578c1c29bSStephan Aßmus 10678c1c29bSStephan Aßmus // object type radio buttons 10778c1c29bSStephan Aßmus BMessage* message; 10878c1c29bSStephan Aßmus BRadioButton* radioButton; 10978c1c29bSStephan Aßmus 11078c1c29bSStephan Aßmus b.OffsetBy(0, fClearB->Bounds().Height() + 5.0); 11178c1c29bSStephan Aßmus message = new BMessage(MSG_SET_OBJECT_TYPE); 11278c1c29bSStephan Aßmus message->AddInt32("type", OBJECT_LINE); 11378c1c29bSStephan Aßmus radioButton = new BRadioButton(b, "radio 1", "Line", message); 11478c1c29bSStephan Aßmus controlGroup->AddChild(radioButton); 11578c1c29bSStephan Aßmus 11678c1c29bSStephan Aßmus radioButton->SetValue(B_CONTROL_ON); 11778c1c29bSStephan Aßmus 11878c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 11978c1c29bSStephan Aßmus message = new BMessage(MSG_SET_OBJECT_TYPE); 12078c1c29bSStephan Aßmus message->AddInt32("type", OBJECT_RECT); 12178c1c29bSStephan Aßmus radioButton = new BRadioButton(b, "radio 2", "Rect", message); 12278c1c29bSStephan Aßmus controlGroup->AddChild(radioButton); 12378c1c29bSStephan Aßmus 12478c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 12578c1c29bSStephan Aßmus message = new BMessage(MSG_SET_OBJECT_TYPE); 12678c1c29bSStephan Aßmus message->AddInt32("type", OBJECT_ROUND_RECT); 12778c1c29bSStephan Aßmus radioButton = new BRadioButton(b, "radio 3", "Round Rect", message); 12878c1c29bSStephan Aßmus controlGroup->AddChild(radioButton); 12978c1c29bSStephan Aßmus 13078c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 13178c1c29bSStephan Aßmus message = new BMessage(MSG_SET_OBJECT_TYPE); 13278c1c29bSStephan Aßmus message->AddInt32("type", OBJECT_ELLIPSE); 13378c1c29bSStephan Aßmus radioButton = new BRadioButton(b, "radio 4", "Ellipse", message); 13478c1c29bSStephan Aßmus controlGroup->AddChild(radioButton); 13578c1c29bSStephan Aßmus 13681cc749fSStephan Aßmus // drawing mode 13781cc749fSStephan Aßmus /* BPopUpMenu* popupMenu = new BPopUpMenu("<pick>"); 13881cc749fSStephan Aßmus 13981cc749fSStephan Aßmus message = new BMessage(MSG_SET_DRAWING_MODE); 14081cc749fSStephan Aßmus message->AddInt32("mode", B_OP_COPY); 14181cc749fSStephan Aßmus popupMenu->AddItem(new BMenuItem("B_OP_COPY", message)); 14281cc749fSStephan Aßmus 14381cc749fSStephan Aßmus message = new BMessage(MSG_SET_DRAWING_MODE); 14481cc749fSStephan Aßmus message->AddInt32("mode", B_OP_OVER); 14581cc749fSStephan Aßmus popupMenu->AddItem(new BMenuItem("B_OP_OVER", message)); 14681cc749fSStephan Aßmus 14781cc749fSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 14881cc749fSStephan Aßmus fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode", 14981cc749fSStephan Aßmus popupMenu); 15081cc749fSStephan Aßmus 15181cc749fSStephan Aßmus controlGroup->AddChild(fDrawingModeMF); 15281cc749fSStephan Aßmus 15381cc749fSStephan Aßmus fDrawingModeMF->SetDivider(fDrawingModeMF->StringWidth(fDrawingModeMF->Label()) + 10.0); 15481cc749fSStephan Aßmus */ 15578c1c29bSStephan Aßmus // red text control 15678c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 15778c1c29bSStephan Aßmus fRedTC = new BTextControl(b, "red text control", "Red", "", 15878c1c29bSStephan Aßmus new BMessage(MSG_SET_COLOR)); 15978c1c29bSStephan Aßmus controlGroup->AddChild(fRedTC); 16078c1c29bSStephan Aßmus 16178c1c29bSStephan Aßmus // green text control 16278c1c29bSStephan Aßmus b.OffsetBy(0, fRedTC->Bounds().Height() + 5.0); 16378c1c29bSStephan Aßmus fGreenTC = new BTextControl(b, "green text control", "Green", "", 16478c1c29bSStephan Aßmus new BMessage(MSG_SET_COLOR)); 16578c1c29bSStephan Aßmus controlGroup->AddChild(fGreenTC); 16678c1c29bSStephan Aßmus 16778c1c29bSStephan Aßmus // blue text control 16878c1c29bSStephan Aßmus b.OffsetBy(0, fGreenTC->Bounds().Height() + 5.0); 16978c1c29bSStephan Aßmus fBlueTC = new BTextControl(b, "blue text control", "Blue", "", 17078c1c29bSStephan Aßmus new BMessage(MSG_SET_COLOR)); 17178c1c29bSStephan Aßmus controlGroup->AddChild(fBlueTC); 17278c1c29bSStephan Aßmus 17378c1c29bSStephan Aßmus // alpha text control 17478c1c29bSStephan Aßmus b.OffsetBy(0, fBlueTC->Bounds().Height() + 5.0); 17578c1c29bSStephan Aßmus fAlphaTC = new BTextControl(b, "alpha text control", "Alpha", "", 17678c1c29bSStephan Aßmus new BMessage(MSG_SET_COLOR)); 17778c1c29bSStephan Aßmus controlGroup->AddChild(fAlphaTC); 17878c1c29bSStephan Aßmus /* 17978c1c29bSStephan Aßmus // TODO: while this block of code works in the Haiku app_server running under R5, 18078c1c29bSStephan Aßmus // it crashes pretty badly under Haiku. I have no idea why this happens, because 18178c1c29bSStephan Aßmus // I was doing the same thing before at other places. 18278c1c29bSStephan Aßmus // divide text controls the same 18378c1c29bSStephan Aßmus float rWidth = fRedTC->StringWidth(fRedTC->Label()); 18478c1c29bSStephan Aßmus float gWidth = fGreenTC->StringWidth(fGreenTC->Label()); 18578c1c29bSStephan Aßmus float bWidth = fBlueTC->StringWidth(fBlueTC->Label()); 18678c1c29bSStephan Aßmus float aWidth = fAlphaTC->StringWidth(fAlphaTC->Label()); 18778c1c29bSStephan Aßmus 18878c1c29bSStephan Aßmus float width = max_c(rWidth, max_c(gWidth, max_c(bWidth, aWidth))) + 10.0; 18978c1c29bSStephan Aßmus fRedTC->SetDivider(width); 19078c1c29bSStephan Aßmus fGreenTC->SetDivider(width); 19178c1c29bSStephan Aßmus fBlueTC->SetDivider(width); 19278c1c29bSStephan Aßmus fAlphaTC->SetDivider(width);*/ 19378c1c29bSStephan Aßmus 19478c1c29bSStephan Aßmus // fill check box 19578c1c29bSStephan Aßmus b.OffsetBy(0, fAlphaTC->Bounds().Height() + 5.0); 19678c1c29bSStephan Aßmus fFillCB = new BCheckBox(b, "fill check box", "Fill", 19778c1c29bSStephan Aßmus new BMessage(MSG_SET_FILL_OR_STROKE)); 19878c1c29bSStephan Aßmus controlGroup->AddChild(fFillCB); 19978c1c29bSStephan Aßmus 20078c1c29bSStephan Aßmus // pen size text control 20178c1c29bSStephan Aßmus b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); 202b7f478e2SStephan Aßmus b.bottom = b.top + 10.0;//35; 203b7f478e2SStephan Aßmus fPenSizeS = new BSlider(b, "width slider", "Width", 204b7f478e2SStephan Aßmus NULL, 1, 100, B_TRIANGLE_THUMB); 205b7f478e2SStephan Aßmus fPenSizeS->SetLimitLabels("1", "100"); 206b7f478e2SStephan Aßmus fPenSizeS->SetModificationMessage(new BMessage(MSG_SET_PEN_SIZE)); 207b7f478e2SStephan Aßmus fPenSizeS->SetHashMarks(B_HASH_MARKS_BOTTOM); 208b7f478e2SStephan Aßmus fPenSizeS->SetHashMarkCount(10); 209b7f478e2SStephan Aßmus 210b7f478e2SStephan Aßmus controlGroup->AddChild(fPenSizeS); 211b7f478e2SStephan Aßmus 212b7f478e2SStephan Aßmus // enforce some size limits 213b7f478e2SStephan Aßmus float minWidth = controlGroup->Frame().Width() + 30.0; 214b7f478e2SStephan Aßmus float minHeight = fPenSizeS->Frame().bottom + 215b7f478e2SStephan Aßmus menuBar->Bounds().Height() + 15.0; 216b7f478e2SStephan Aßmus float maxWidth = minWidth * 4.0; 217b7f478e2SStephan Aßmus float maxHeight = minHeight; 218b7f478e2SStephan Aßmus SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight); 21978c1c29bSStephan Aßmus 220e4bcf6e0SStephan Aßmus ResizeTo(max_c(frame.Width(), minWidth), max_c(frame.Height(), minHeight)); 221e4bcf6e0SStephan Aßmus 22278c1c29bSStephan Aßmus _UpdateControls(); 22378c1c29bSStephan Aßmus } 22478c1c29bSStephan Aßmus 22578c1c29bSStephan Aßmus // destructor 22678c1c29bSStephan Aßmus ObjectWindow::~ObjectWindow() 22778c1c29bSStephan Aßmus { 22878c1c29bSStephan Aßmus } 22978c1c29bSStephan Aßmus 23078c1c29bSStephan Aßmus // QuitRequested 23178c1c29bSStephan Aßmus bool 23278c1c29bSStephan Aßmus ObjectWindow::QuitRequested() 23378c1c29bSStephan Aßmus { 23478c1c29bSStephan Aßmus be_app->PostMessage(B_QUIT_REQUESTED); 23578c1c29bSStephan Aßmus return true; 23678c1c29bSStephan Aßmus } 23778c1c29bSStephan Aßmus 23878c1c29bSStephan Aßmus // MessageReceived 23978c1c29bSStephan Aßmus void 24078c1c29bSStephan Aßmus ObjectWindow::MessageReceived(BMessage* message) 24178c1c29bSStephan Aßmus { 24278c1c29bSStephan Aßmus switch (message->what) { 24378c1c29bSStephan Aßmus case MSG_SET_OBJECT_TYPE: { 24478c1c29bSStephan Aßmus int32 type; 24578c1c29bSStephan Aßmus if (message->FindInt32("type", &type) >= B_OK) { 24678c1c29bSStephan Aßmus fObjectView->SetObjectType(type); 24778c1c29bSStephan Aßmus fFillCB->SetEnabled(type != OBJECT_LINE); 248e803c97cSStephan Aßmus if (!fFillCB->IsEnabled()) 249b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(true); 250e803c97cSStephan Aßmus else 251b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(fFillCB->Value() == B_CONTROL_OFF); 25278c1c29bSStephan Aßmus } 25378c1c29bSStephan Aßmus break; 25478c1c29bSStephan Aßmus } 25578c1c29bSStephan Aßmus case MSG_SET_FILL_OR_STROKE: { 25678c1c29bSStephan Aßmus int32 value; 25778c1c29bSStephan Aßmus if (message->FindInt32("be:value", &value) >= B_OK) { 25878c1c29bSStephan Aßmus fObjectView->SetStateFill(value); 259b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(value == B_CONTROL_OFF); 26078c1c29bSStephan Aßmus } 26178c1c29bSStephan Aßmus break; 26278c1c29bSStephan Aßmus } 26378c1c29bSStephan Aßmus case MSG_SET_COLOR: 26478c1c29bSStephan Aßmus fObjectView->SetStateColor(_GetColor()); 26581cc749fSStephan Aßmus _UpdateColorControls(); 26678c1c29bSStephan Aßmus break; 26778c1c29bSStephan Aßmus case MSG_OBJECT_COUNT_CHANGED: 26878c1c29bSStephan Aßmus fClearB->SetEnabled(fObjectView->CountObjects() > 0); 26978c1c29bSStephan Aßmus break; 27078c1c29bSStephan Aßmus case MSG_NEW_OBJECT: 27178c1c29bSStephan Aßmus fObjectView->SetState(NULL); 27278c1c29bSStephan Aßmus break; 2734dfc2afbSAxel Dörfler case MSG_CLEAR: { 274590fdd3fSStephan Aßmus BAlert *alert = new BAlert("Playground", "Do you really want to clear all drawing objects?", "No", "Yes"); 275590fdd3fSStephan Aßmus if (alert->Go() == 1) { 27678c1c29bSStephan Aßmus fObjectView->MakeEmpty(); 277590fdd3fSStephan Aßmus } 27878c1c29bSStephan Aßmus break; 2794dfc2afbSAxel Dörfler } 28078c1c29bSStephan Aßmus case MSG_SET_PEN_SIZE: 281b7f478e2SStephan Aßmus fObjectView->SetStatePenSize((float)fPenSizeS->Value()); 28278c1c29bSStephan Aßmus break; 28378c1c29bSStephan Aßmus default: 28478c1c29bSStephan Aßmus BWindow::MessageReceived(message); 28578c1c29bSStephan Aßmus } 28678c1c29bSStephan Aßmus } 28778c1c29bSStephan Aßmus 28878c1c29bSStephan Aßmus // _UpdateControls 28978c1c29bSStephan Aßmus void 29078c1c29bSStephan Aßmus ObjectWindow::_UpdateControls() const 29178c1c29bSStephan Aßmus { 29281cc749fSStephan Aßmus _UpdateColorControls(); 29381cc749fSStephan Aßmus 29481cc749fSStephan Aßmus // update buttons 29581cc749fSStephan Aßmus fClearB->SetEnabled(fObjectView->CountObjects() > 0); 29681cc749fSStephan Aßmus 29781cc749fSStephan Aßmus fFillCB->SetEnabled(fObjectView->ObjectType() != OBJECT_LINE); 29881cc749fSStephan Aßmus 29981cc749fSStephan Aßmus // pen size 300b7f478e2SStephan Aßmus fPenSizeS->SetValue((int32)fObjectView->StatePenSize()); 30181cc749fSStephan Aßmus 30281cc749fSStephan Aßmus // disable penSize if fill is on 30381cc749fSStephan Aßmus if (!fFillCB->IsEnabled()) 304b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(true); 30581cc749fSStephan Aßmus else 306b7f478e2SStephan Aßmus fPenSizeS->SetEnabled(fFillCB->Value() == B_CONTROL_OFF); 30781cc749fSStephan Aßmus } 30881cc749fSStephan Aßmus 30981cc749fSStephan Aßmus // _UpdateColorControls 31081cc749fSStephan Aßmus void 31181cc749fSStephan Aßmus ObjectWindow::_UpdateColorControls() const 31281cc749fSStephan Aßmus { 31378c1c29bSStephan Aßmus // update color 31478c1c29bSStephan Aßmus rgb_color c = fObjectView->StateColor(); 31578c1c29bSStephan Aßmus char string[32]; 31678c1c29bSStephan Aßmus 31778c1c29bSStephan Aßmus sprintf(string, "%d", c.red); 31878c1c29bSStephan Aßmus fRedTC->SetText(string); 31978c1c29bSStephan Aßmus 32078c1c29bSStephan Aßmus sprintf(string, "%d", c.green); 32178c1c29bSStephan Aßmus fGreenTC->SetText(string); 32278c1c29bSStephan Aßmus 32378c1c29bSStephan Aßmus sprintf(string, "%d", c.blue); 32478c1c29bSStephan Aßmus fBlueTC->SetText(string); 32578c1c29bSStephan Aßmus 32678c1c29bSStephan Aßmus sprintf(string, "%d", c.alpha); 32778c1c29bSStephan Aßmus fAlphaTC->SetText(string); 32878c1c29bSStephan Aßmus } 32978c1c29bSStephan Aßmus 33078c1c29bSStephan Aßmus // _GetColor 33178c1c29bSStephan Aßmus rgb_color 33278c1c29bSStephan Aßmus ObjectWindow::_GetColor() const 33378c1c29bSStephan Aßmus { 33478c1c29bSStephan Aßmus rgb_color c; 33578c1c29bSStephan Aßmus c.red = max_c(0, min_c(255, atoi(fRedTC->Text()))); 33678c1c29bSStephan Aßmus c.green = max_c(0, min_c(255, atoi(fGreenTC->Text()))); 33778c1c29bSStephan Aßmus c.blue = max_c(0, min_c(255, atoi(fBlueTC->Text()))); 33878c1c29bSStephan Aßmus c.alpha = max_c(0, min_c(255, atoi(fAlphaTC->Text()))); 33978c1c29bSStephan Aßmus 34078c1c29bSStephan Aßmus return c; 34178c1c29bSStephan Aßmus } 34278c1c29bSStephan Aßmus 343