SophiaFramework UNIVERSE 5.3 |
The responder inheriting from SFYFrame is called as "Frame".
By attaching a frame to a responder with the SFYResponder::SetFrame function, it is possible to display the responder's frame such as a border and/or a title.
Three kinds of the target responders to which a frame will be attached are as follows:
There are 3 types of frames as follows:
Note | |
---|---|
Each frame can have a header with a title. |
How to Use a Frame
Note | |
---|---|
At this time, the frame which is attached to the responder is called as the "attachment-frame". On the other hand, the responder to which the frame is attached is called as the "content-responder". |
Tip | |
---|---|
The real region of the other side will be automatically calculated using the frame margin region of the attachment-frame and set. Inside the SFYResponder::SetFrame function, the processing that the real region of the attachment-frame will be set to the region obtained by inflating that of the content-responder by the frame margin. Therefore, the setting of the content-responder's real region can be performed before calling the SFYResponder::SetFrame function. |
Tip | |
---|---|
The properties related with the attached responder should not be defined in the user-defined frame class. The frame class defined as such can be attached to a variety of responders. |
Note | |
---|---|
For more details on the attachment-frame and the content-responder, see this. |
Kinds of the Frame Classes
All frames inherit from the SFYFrame class, which provides functions to calculate the size of frame margin, set the frame with a border and/or a title, and draw itself.
The concrete frame is the part class which can be used as it is in the applet development. On the other hand, the abstract frame is the base class to define and implement the user-defined frame.
Table 9.20. Type of concrete frame
Class name | Description |
---|---|
SFZPlainFrame | Plain frame. |
SFZFlatFrame | Flat frame. |
SFZBevelFrame | Bevel frame. |
SFZTitlePlainFrame | Plain frame with a title. |
SFZTitleFlatFrame | Flat frame with a title. |
SFZTitleBevelFrame | Bevel frame with a title. |
IMPORTANT | |||||
---|---|---|---|---|---|
In the concrete frame, the SFYResponder::SetState function must be always called. In general, all the states of "visible", "active", "enable", and "focus" will be set to "true". Other functions are optionally called. It is highly recommended to attach a frame to a responder with the SFYResponder::SetFrame function. If the SFYResponder::SetRealBound function of the content-responder is called, the real region of the corresponding attachment-frame will be automatically set. On the other hand, if the SFYResponder::SetRealBound function of the the attachment-frame is called, the real region of the corresponding content-responder will be automatically set.
|
Table 9.21. Type of abstract frame
Class name | Description |
---|---|
SFYFrame | Abstract class which represents a frame. |
SFYPlainFrame | Abstract class which represents a plain frame. |
SFYFlatFrame | Abstract class which represents a flat frame. |
SFYBevelFrame | Abstract class which represents a bevel frame. |
Example 9.82. Declaration
SFMTYPEDEFCLASS(USRApplication) class USRApplication: public SFYApplication { SFMSEALCOPY(USRApplication) private: SFZTitleBevelFrameSmp _frame; SFZMessageDialogSmp _dialog; // ... private: SFCError MakeFrame(Void); SFCError MakeDialog(Void); // result handler XANDLER_DECLARE_VOIDRESULT(OnResult) };
Example 9.83. Implementation
// make the frame SFCError USRApplication::MakeFrame(Void) { SFCError error(SFERR_NO_ERROR); // create the bevel frame with title(each frame has different design) // other types of frames can be set to a window or a dialog in the same way if ((_frame = SFZTitleBevelFrame::NewInstance(&error)) != null) { // In general, the frame's state is set to "visible" + "active" + "enable" + "focus". _frame->SetState(true, true, true, true); // set the other attributes of the frame // ... } if ( error == SFERR_NO_ERROR) { // make the dialog to which the frame will be attached error = MakeDialog(); } return error; } // make the dialog to which the frame will be attached SFCError USRApplication::MakeDialog(Void) { SFXRectangle rectangle; SFXMargin margin; SFCError error(SFERR_NO_ERROR); // create the dialog if ((_dialog = SFZMessageDialog::NewInstance(&error)) != null) { // set the dialog's parent responder to the application class(root) error = _dialog->SetParent(GetThis()); if (error == SFERR_NO_ERROR) { // attach the frame to the dialog error = _dialog->SetFrame(_frame); if (error == SFERR_NO_ERROR) { // register the result handler into the dialog error = _dialog->RegisterHandler( SFXEventRange(SFEVT_RESPONDER_RESULT, SFEVT_RESPONDER_RESULT, SFP16_BEGIN, SFP16_END), XANDLER_INTERNAL(OnResult) ); if (error == SFERR_NO_ERROR) { // set the dialog's message error = _dialog->SetMessageText("in\nSFZTitleBevelFrame\n\nThis is a notification message."); if (error == SFERR_NO_ERROR) { // set the dialog's OK button text error = _dialog->SetButtonText("OK"); if (error == SFERR_NO_ERROR) { // set the frame title error = _frame->SetText("SFZTitleBevelFrame"); if (error == SFERR_NO_ERROR) { // Calculate the suitable region of the frame within the hint region obtained by deflating the screen device region by (10, 10), // which will be aligned at the center and the middle of the hint region. // Set the frame's real region to it // * Automatically, the dialog's real region will be set to the region obtained by deflating it by the frame margin. _frame->SetRealBound(_frame->GetSuitableBound(GetLocalBound().Deflate(10, 10), SFYResponder::HORIZONTAL_CENTER, SFYResponder::VERTICAL_MIDDLE)); // set the dialog's state to "visible" + "active" + "enable" + "focus" together _dialog->SetState(true, true, true, true); // move the dialog foremost // * automatically, the frame will be moved foremost together _dialog->ToFront(); } } } } } } } return error; } // result handler XANDLER_IMPLEMENT_VOIDRESULT(USRApplication, OnResult, invoker, reason, result) { // the dialog will be passed via the invoker argument // the P16 value of the result event will be passed via the reason argument // "0" will be passed via the result argument switch (reason) { case SFP16_RESULT_OK: // when the OK button or the operation key is pressed break; case SFP16_RESULT_ESCAPE: // when the ESCAPE key is pressed or the time scheduled with ScheduleTimer() elapses ... break; } // close the dialog only // * automatically, the frame will be detached from the dialog and become invisible invoker->Terminate(); return; }
Tip | |
---|---|
If a content-responder is closed with the SFYResponder::Terminate function, the corresponding attachment-frame will be detached from it, become invisible, and restore to the normal frame which can be attached to other responder. There is no need to close the corresponding attachment-frame. |
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |