File: w_base.srw
Size: 4276
Date: Mon, 07 Apr 2008 21:31:05 +0200
$PBExportHeader$w_base.srw
$PBExportComments$Base Window
forward
global type w_base from window
end type
end forward

shared variables

end variables

global type w_base from window
boolean visible = false
integer width = 2569
integer height = 1512
boolean titlebar = true
boolean controlmenu = true
boolean minbox = true
boolean maxbox = true
boolean resizable = true
long backcolor = 67108864
string icon = "AppIcon!"
event ke_preopen ( )
event ke_postopen ( )
event ke_changes ( )
event ke_minmax pbm_getminmaxinfo
event ke_postinit ( )
event type long ke_preclose ( )
event ke_mousemove ( dragobject drg_object,  integer xpos,  integer ypos )
event ke_show ( )
event ke_balloonnotify ( readonly icon ai_icon,  readonly string as_title )
end type
global w_base w_base

type variables
Public:
Boolean #AutoPositionWindow = TRUE, #ToolTips
integer #WindowPosition = CWindowpos.center
long #MinWidth, #MinHeight, #MaxWidth, #MaxHeight

Private:
Boolean #HasChanges
end variables

forward prototypes
public subroutine of_clearchanges ()
public function boolean of_haschanges ()
public subroutine of_setchanges (readonly boolean ab_changes)
protected subroutine of_constructcontrols ()
public subroutine of_position (window aw_parentwindow, readonly integer ai_position)
public subroutine of_position (readonly integer ai_position)
public subroutine of_scantooltips (readonly boolean ab_load)
end prototypes

event ke_preopen();//fired on open, before post
IF #Tooltips THEN
   of_ScanTooltips(TRUE)
END IF
end event

event ke_postopen();//fire construct for all controls
of_ConstructControls()
EVENT ke_postinit()
EVENT ke_show()
end event

event ke_changes();this.of_setchanges(TRUE)
end event

event ke_minmax;IF Resizable THEN
   n_svc_mgr lnv_svcman
   n_svc_window lnv_svcwin
   
   lnv_svcman.of_loadsvc(lnv_svcwin, CSvc.WINDOW)
   
   IF (#MinWidth > 0 ) OR (#MinHeight > 0) THEN
      lnv_svcwin.of_setmin(lnv_svcman, minmaxinfo, #MinWidth, #MinHeight)
   END IF
   IF (#MaxWidth > 0) OR (#MaxHeight > 0) THEN
      lnv_svcwin.of_setmax(lnv_svcman, minmaxinfo, #MaxWidth, #MaxHeight)        
   END IF
END IF

RETURN 0
end event

event ke_postinit();IF #AutoPositionWindow THEN
   window lw_parent
   lw_parent = ParentWindow()
   
   of_Position(lw_parent, #windowposition)
END IF
end event

event type long ke_preclose();RETURN CRet.NO_ACTION
end event

event ke_show();//triggered after all posts
this.Visible = TRUE
end event

event ke_balloonnotify(readonly icon ai_icon, readonly 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 subroutine of_clearchanges ();of_setchanges(FALSE)
end subroutine

public function boolean of_haschanges ();RETURN #HasChanges
end function

public subroutine of_setchanges (readonly boolean ab_changes);#HasChanges = ab_changes
end subroutine

protected 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 subroutine of_position (window aw_parentwindow, readonly integer ai_position);n_svc_mgr lnv_svcman
n_svc_window lnv_svcwin

lnv_svcman.of_loadsvc(lnv_svcwin, CSvc.WINDOW)
IF ISVALID(aw_parentwindow) THEN
   lnv_svcwin.of_position(aw_parentwindow, this, ai_position)
ELSE
   lnv_svcwin.of_position(this, ai_position)
END IF
end subroutine

public subroutine of_position (readonly integer ai_position);window lw

of_Position(lw, ai_position)
end subroutine

public subroutine of_scantooltips (readonly 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 w_base.create
end on

on w_base.destroy
end on

event open;EVENT ke_preopen()
EVENT POST ke_postopen()
end event

event close;IF #Tooltips THEN
   of_ScanTooltips(FALSE)
END IF

RETURN EVENT ke_preclose()
end event