SophiaFramework UNIVERSE 5.3 |
There are three types of Window classes that inherit from the SFRWindow class.
Table 10.3. Window Types
Class Name | Description |
---|---|
SFRPlainWindow | Responder which represents a plain window without title and frame. |
SFRFrameWindow | Responder which represents a window with a frame. |
SFRTitleWindow | Responder which represents a window with a title. |
In general, the Window class can be defined by inheriting from one among the above three types of Window classes.
Figure 10.11. Window (SFRPlainWindow, SFRFrameWindow, SFRTitleWindow )
Reference: Development with SFR GUI Framework: Window
Create the instance(PlainWindow) of MyWindow class that inherits from the SFRPlainWindow class.
Example 10.11. Define, Implement, and Create the PlainWindow (1)
// PlainWindow with coordinates: (20, 20), width: 200, height: 250 SFMTYPEDEFCLASS(MyWindow) class MyWindow : public SFRPlainWindow { SFMSEALCOPY(MyWindow) public: MyWindow(Void); virtual ~MyWindow(Void); }; // Constructor // 1st arg: pointer to Application instance, 2nd arg: position and size of Window MyWindow::MyWindow(Void) : SFRPlainWindow(SFRApplication::GetInstance(), SFXRectangle(20, 20, 200, 250)) { return; } // create PlainWindow MyWindowPtr window; window = new MyWindow();
Note | |
---|---|
For the PlainWindow without neither title nor frame, it seems not to be displayed. |
Using the SFXGraphics instance, draw the string "Hello Window" on the instance(PlainWindow) of MyWindow class that inherits from the SFRPlainWindow class.
Example 10.12. Define, Implement, and Create the PlainWindow (2)
SFMTYPEDEFCLASS(MyWindow) class MyWindow : public SFRPlainWindow { SFMSEALCOPY(MyWindow) public: MyWindow(Void) static_throws; virtual ~MyWindow(Void); // declare drawing handler HANDLER_DECLARE_VOIDRENDER(OnRenderContent) }; // Constructor MyWindow::MyWindow(Void) : SFRPlainWindow(SFRApplication::GetInstance(), SFXRectangle(20, 20, 200, 250)) { // register drawing handler RegisterHandler(SREVT_RESPONDER_RENDER, SRP16_RENDER_CONTENT, HANDLER_BEFORE, HANDLER_FUNCTION(OnRenderContent)); return; } // Drawing handler // 1st argument: class it belongs to, 2nd argument : handler name, 3rd argument: SFXGraphics instance HANDLER_IMPLEMENT_VOIDRENDER(MyWindow, OnRenderContent, graphics) { // draw using SFXGraphics instance // set inside of window to light blue // GetContentWorld() returns a rectangle (SFXRectangle) represents drawing area inside window // SFXRGBColor(0xCE, 0xFF, 0xFF, 0x00) defines light blue graphics->FillRectangle(GetContentWorld(), SFXRGBColor(0xCE, 0xFF, 0xFF, 0x00)); // display "Hello Window" // SFXRGBColor(0x00, 0x00, 0x00, 0x00) defines black graphics->DrawText("Hello Window", GetContentWorld(), SFXRGBColor(0x00, 0x00, 0x00, 0x00)); return; } // create PlainWindow MyWindowPtr window; window = new MyWindow();
Create the instance(FrameWindow) of MyWindow class that inherits from the SFRFrameWindow class.
Example 10.13. Define, Implement, and Create the FrameWindow (1)
// FrameWindow with coordinates: (20, 20), width: 200, height: 250 SFMTYPEDEFCLASS(MyWindow) class MyWindow : public SFRFrameWindow { SFMSEALCOPY(MyWindow) public: MyWindow(Void); virtual ~MyWindow(Void); }; // Constructor // 1st arg: pointer to Application instance, 2nd arg: position and size of Window MyWindow::MyWindow(Void) : SFRFrameWindow(SFRApplication::GetInstance(), SFXRectangle(20, 20, 200, 250)) { return; } // create FrameWindow MyWindowPtr window; window = new MyWindow();
Using the SFXGraphics instance, draw the string "Hello Window" on the instance(FrameWindow) of MyWindow class that inherits from the SFRFrameWindow class.
Example 10.14. Define, Implement, and Create the FrameWindow (2)
SFMTYPEDEFCLASS(MyWindow) class MyWindow : public SFRFrameWindow { SFMSEALCOPY(MyWindow) public: MyWindow(Void) static_throws; virtual ~MyWindow(Void); // declare drawing handler HANDLER_DECLARE_VOIDRENDER(OnRenderContent) }; // Constructor MyWindow::MyWindow(Void) : SFRFrameWindow(SFRApplication::GetInstance(), SFXRectangle(20, 20, 200, 250)) { // register drawing handler RegisterHandler(SREVT_RESPONDER_RENDER, SRP16_RENDER_CONTENT, HANDLER_BEFORE, HANDLER_FUNCTION(OnRenderContent)); return; } // Drawing handler // 1st argument: class it belongs to, 2nd argument: handler name, 3rd argument: SFXGraphics instance HANDLER_IMPLEMENT_VOIDRENDER(MyWindow, OnRenderContent, graphics) { // draw using SFXGraphics instance // set inside of window to light blue // GetContentWorld() returns a rectangle (SFXRectangle) represents drawing area inside window // SFXRGBColor(0xCE, 0xFF, 0xFF, 0x00) defines light blue graphics->FillRectangle(GetContentWorld(), SFXRGBColor(0xCE, 0xFF, 0xFF, 0x00)); // display "Hello Window" // SFXRGBColor(0x00, 0x00, 0x00, 0x00) defines black graphics->DrawText("Hello Window", GetContentWorld(), SFXRGBColor(0x00, 0x00, 0x00, 0x00)); return; } // create FrameWindow MyWindowPtr window; window = new MyWindow();
Create the instance(TitleWindow) of MyWindow class that inherits from the SFRTitleWindow class.
Example 10.15. Define, Implement, and Create the TitleWindow (1)
// TitleWindow coordinates: (20, 20), width: 200, height: 250, title: "my window" SFMTYPEDEFCLASS(MyWindow) class MyWindow : public SFRTitleWindow { SFMSEALCOPY(MyWindow) public: MyWindow(Void); virtual ~MyWindow(Void); }; // Constructor // 1st arg: pointer to Application instance, 2nd arg: position and size of Window, 3rd arg: window title MyWindow::MyWindow(Void) : SFRTitleWindow(SFRApplication::GetInstance(), SFXRectangle(20, 20, 200, 250), "my window") { return; } // create TitleWindow MyWindowPtr window; window = new MyWindow();
Using the SFXGraphics instance, draw the string "Hello Window" on the instance(TitleWindow) of MyWindow class that inherits from the SFRTitleWindow class.
Example 10.16. Define, Implement, and Create the TitleWindow (2)
SFMTYPEDEFCLASS(MyWindow) class MyWindow : public SFRTitleWindow { SFMSEALCOPY(MyWindow) public: MyWindow(Void) static_throws; virtual ~MyWindow(Void); // Declare drawing handler HANDLER_DECLARE_VOIDRENDER(OnRenderContent) }; // Constructor MyWindow::MyWindow(Void) : SFRTitleWindow(SFRApplication::GetInstance(), SFXRectangle(20, 20, 200, 250), "my window") { // register drawing handler RegisterHandler(SREVT_RESPONDER_RENDER, SRP16_RENDER_CONTENT, HANDLER_BEFORE, HANDLER_FUNCTION(OnRenderContent)); return; } // Drawing handler // 1st arg: class it belongs to, 2nd arg: handler name, 3rd arg: SFXGraphics instance HANDLER_IMPLEMENT_VOIDRENDER(MyWindow, OnRenderContent, graphics) { // draw using SFXGraphics instance // set inside of window to light blue // GetContentWorld() returns a rectangle (SFXRectangle) represents drawing area inside window // SFXRGBColor(0xCE, 0xFF, 0xFF, 0x00) defines light blue graphics->FillRectangle(GetContentWorld(), SFXRGBColor(0xCE, 0xFF, 0xFF, 0x00)); // display "Hello Window" // SFXRGBColor(0x00, 0x00, 0x00, 0x00) defines black graphics->DrawText("Hello Window", GetContentWorld(), SFXRGBColor(0x00, 0x00, 0x00, 0x00)); return; } // create TitleWindow MyWindowPtr window; window = new MyWindow();
The topleft of drawing area is (0,0) that can be obtained by using GetContentWorld function.
The number of Window instances to be created is not limited. When there are more than one Window instances, event handling depends upon the event type. For example, a key event is dispatched to the topmost Window instance with the Control instance focused. Suspend and resume events are dispatched to all the Window instances.
To make a window to be topmost, use the Select function.
A window can be disabled to be selected or be invisible. When a window is invalidated, all the controls in within become invalidated, too.
Table 10.4. Functions for setting / getting the Responder status
Function Name | Description |
---|---|
SetStatusEnable | Set the "enable/disable" status of Responder instance.(true: enable, false: disable) |
GetStatusEnable | Get the "enable/disable" status of Responder instance.(true: enable, false: disable) |
SetStatusVisible | Set the "visible/invisible" status of Responder instance. (true: visible, false: invisible) |
GetStatusVisible | Get the "visible/invisible" status of Responder instance.(true: visible, false: invisible) |
Method to Make the Window Disable
// _window is SFRWindowPtr type
_window->SetStatusEnable(false);
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |