SophiaFramework UNIVERSE 5.3 |
Example 12.48. Display the list
SFXRectangle rectangle(30, 50, 120, 150); SFXGraphicsPtr graphics = SFXGraphics::GetInstance(); // draw frame: set color using SFXRGBColor graphics->DrawRectangle(rectangle, SFXRGBColor(0x00, 0x00, 0x00, 0x00)); // shrink top, bottom, left and right of frame each by 1 pixel rectangle.Deflate(1, 1); // set height of rectangle to font-height rectangle.SetHeight(graphics->GetFontHeight()); // strings for list SFXAnsiString stringArray[] = {"C++", "java", "perl", "ruby", "python", "haskell"}; SInt32 i; for (i = 0; i < lengthof(stringArray); ++i) { if (i % 2 == 0) { // at odd lines // fill rectangle with (0xFF, 0xAA, 0xBB, 0x00) color graphics->FillRectangle(rectangle, SFXRGBColor(0xFF, 0xAA, 0xBB, 0x00)); } else { // at even line // fill rectangle with (0xDD, 0xDD, 0xFF, 0x00) color graphics->FillRectangle(rectangle, SFXRGBColor(0xDD, 0xDD, 0xFF, 0x00)); } // draw text in rectangle graphics->DrawText(stringArray[i], rectangle, SFXRGBColor(0x00, 0x00, 0x00, 0x00)); // move rectangle down rectangle.AddY(rectangle.GetHeight() + 2); }
Repeat drawing | |
---|---|
By using the SFXRectangle::AddY function in the for statement , drawing several rectangles of same size are simply written. |
Example 12.49. Locate the Responder
SFXRectangle rectangle(20, 40, 100, 0); // set height of rectangle to font-height rectangle.SetHeight(SFXGraphics::GetFontHeight(AEE_FONT_NORMAL)); // create button new SFRButtonControl(this, rectangle, "button1"); // move 30 pixels right and 40 pixels down rectangle.Offset(30, 40); // create label new SFRLabelControl(this, rectangle, "label1"); // move 30 pixels right and 40 pixels down rectangle.Offset(-30, 40); // create button new SFRButtonControl(this, rectangle, "button2"); // extend by 30 pixels width, add 40 to the Y value, extend up and down regarding Y-axis direction each by 5 pixels rectangle.AddWidth(30).AddY(40).Inflate(0, 5); // create editbox new SFREditboxControl(this, rectangle, "textbox");
Note | |
---|---|
The Responder instance can be located, moved, shrinked and extended by using the member functions of SFXRectangle class. |
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |