File: u_base.sru
Size: 4903
Date: Mon, 07 Apr 2008 21:30:55 +0200
$PBExportHeader$u_base.sru
$PBExportComments$Base Visual Userobject
forward
global type u_base from userobject
end type
end forward

global type u_base from userobject
integer width = 571
integer height = 600
long backcolor = 67108864
string text = "none"
long tabtextcolor = 33554432
long picturemaskcolor = 536870912
event ke_preopen ( )
event ke_postopen ( )
event ke_changes ( )
event ke_constructor ( )
event ke_constructcomplete ( )
event ke_balloonnotify ( icon ai_icon,  string as_title )
end type
global u_base u_base

type variables
Public:
//tooltip
boolean #Tooltips
//Size Order
Long #SizeOrder
//Anchoring
Boolean #AnchorTop
Boolean #AnchorLeft
Boolean #AnchorRight
Boolean #AnchorBottom
//Docking
Boolean #Dock
//Dock Padding
Long #DockType, #DockPadTop, #DockPadLeft, #DockPadRight, #DockPadBottom
//Dock control reference
String #Dock_Control_Top, #Dock_Control_Left, #Dock_Control_Right, #Dock_Control_Bottom
Private:
str_resize istr_resize
end variables

forward prototypes
public function str_resize of_getresizeattrib ()
public subroutine of_setresizeattrib (readonly str_resize astr)
public subroutine of_constructcontrols ()
public function window of_getparentwindow (readonly boolean ab_topmost)
public function window of_getparentwindow ()
public subroutine of_scantooltips (boolean ab_load)
end prototypes

event ke_preopen();//pre-open
end event

event ke_postopen();//postopen
EVENT ke_constructcomplete()
end event

event ke_changes();//bubble up event
IF ISVALID(Parent) THEN Parent.TriggerEvent(Ckevents.CHANGES)
end event

event ke_constructor();//custom constructor, fired after posts
//this prevents PB bugs from creeping-in
//since UO's are created when a window's
//invisible contructor is fired prior to open, most
//constructor code messes up the execution especially
//with post funcs/events
//as a rule, there should be 
//NO CODE in the constructor, move them HERE

//fire construct for all controls
of_ConstructControls()
EVENT ke_preopen()
EVENT ke_postopen()
end event

event ke_constructcomplete();//fired after event chain of ke_constructor
//all control services should have executed by this event
IF #Tooltips THEN
   of_ScanTooltips(TRUE)
END IF
end event

event ke_balloonnotify(icon ai_icon, string as_title);IF #Tooltips THEN
   n_svc_mgr lnv_svc
   n_svc_tooltip lnv_tip
   
   lnv_svc.of_LoadSvc(lnv_tip, CSvc.TOOLTIP)
   lnv_tip.of_SetBalloontitle(lnv_svc, as_title, ai_icon)
END IF
end event

public function str_resize of_getresizeattrib ();istr_resize.Control = this
istr_resize.ControlName = ClassName(this)
istr_resize.SizeOrder = #SizeOrder
istr_resize.SizeOrder = #SizeOrder
istr_resize.Dock = #Dock
istr_resize.DockType = #DockType
istr_resize.DockPadTop = #DockPadTop
istr_resize.DockPadLeft = #DockPadLeft
istr_resize.DockPadRight = #DockPadRight
istr_resize.DockPadBottom = #DockPadBottom
istr_resize.AnchorTop = #AnchorTop
istr_resize.AnchorLeft = #AnchorLeft
istr_resize.AnchorRight = #Anchorright
istr_resize.AnchorBottom = #Anchorbottom
istr_resize.reftop = #Dock_Control_top
istr_resize.refleft = #Dock_Control_left
istr_resize.refright = #Dock_Control_right
istr_resize.refbottom = #Dock_Control_bottom
istr_resize.bounds.left = X
istr_resize.bounds.top = Y
istr_resize.bounds.right = width
istr_resize.bounds.bottom = height

RETURN istr_resize
end function

public subroutine of_setresizeattrib (readonly str_resize astr);istr_resize = astr

//update parent
n_svc_powerbuilder lnv_pb
n_svc_mgr lnv_svc

lnv_svc.of_LoadSvc(lnv_pb, CSvc.POWERBUILDER)
IF (NOT lnv_pb.of_isdescendant(CFbase.WindowMain, parent.ClassDefinition)) AND (NOT lnv_pb.of_isdescendant(CFbase.UOContainer, parent.ClassDefinition)) THEN RETURN

parent.DYNAMIC of_SetControlResizeAttrib(this, istr_resize)
end subroutine

public subroutine of_constructcontrols ();long ll_count, n
any la

ll_count = UPPERBOUND(this.Control)
FOR n = 1 to ll_count
   //if the object does not contain 
   //the ke_constructor() event, this call
   // will fail silently (See PB Help on DYNAMIC calls)
   la = Control[n].EVENT DYNAMIC ke_constructor()
NEXT
end subroutine

public function window of_getparentwindow (readonly boolean ab_topmost);n_svc_mgr lnv_svc
n_svc_window lnv_w
window lw

lnv_svc.of_LoadSvc(lnv_w, CSvc.WINDOW)
lw = lnv_w.of_getparentwindow(this, NOT ab_topmost)

RETURN lw
end function

public function window of_getparentwindow ();RETURN of_getparentwindow(FALSE)
end function

public subroutine of_scantooltips (boolean ab_load);n_svc_mgr lnv_svc
n_svc_tooltip lnv_t

lnv_svc.of_LoadSvc(lnv_t, CSvc.TOOLTIP)
lnv_t.of_scantooltips(lnv_svc, this, ab_load)

end subroutine

on u_base.create
end on

on u_base.destroy
end on

event destructor;IF #Tooltips THEN
   of_ScanTooltips(FALSE)
END IF
end event