![]() ![]() ![]()
|
SophiaFramework UNIVERSE 5.1 |
Cooperation between container and scroll bar control is described here.
A container can scroll in cooperation with a scroll bar control.
Example 9.51. Declaration
SFMTYPEDEFRESPONDER(USRWindow)
class USRWindow: public SFZWindow {
SFMSEALRESPONDER(USRWindow)
SFMRESPONDERINSTANTIATEFOUR(USRWindow, SFZWindow, SFYContainer, SFYWidget, SFYResponder)
private:
SFZContainerSmp _container;
SFZContainerScrollBarControlSmp _bar;
// ...
private:
SFCError Make(Void);
};
Example 9.52. Implementation
SFCError USRWindow::Make(Void)
{
SFXRectangle rectangle;
SFCError error(SFERR_NO_ERROR);
// make container
if ((_container = SFZContainer::NewInstance(&error)) != null) {
// set USRWindow to container's parent responder
error = _container->SetParent(GetThis());
if (error == SFERR_NO_ERROR) {
// set container's background color to light red color
// * container's background is automatically drawn by SFYWidget
_container->SetBackgroundColor(SFXRGBColor(0xFF, 0xCC, 0xCC, 0x00));
// set container's real region(narrow right side by scroll bar's width)
rectangle.Set(GetLocalBound().Deflate(10, 10));
rectangle.SubWidth(9);
_container->SetRealBound(rectangle);
// set container's virtual region to region obtained by expanding container's virtual region down by 100 pixels
_container->SetVirtualBound(SFXRectangle(_container->GetVirtualBound()).AddBottom(100));
// set container's state to "visible" + "active" + "enable" + "focus" together
_container->SetState(true, true, true, true);
// make scroll bar control for container
if ((_bar = SFZContainerScrollBarControl::NewInstance(&error)) != null) {
// set scroll bar control's parent responder to USRWindow
error = _bar->SetParent(GetThis());
if (error == SFERR_NO_ERROR) {
_bar->SetState(true, true, false, false);
// set scroll bar control's real region
rectangle.Set(_container->GetRealBound());
rectangle.SetLeft(rectangle.GetRight());
rectangle.SetWidth(9);
_bar->SetRealBound(rectangle);
// bind scroll bar control with container
_bar->Bind(_container);
}
}
}
}
return error;
}
|
Copyright(c) 2002 - 2010 Sophia Cradle Incorporated All Rights Reserved. |
![]() ![]() ![]()
|