File: w_main.srw
Size: 5481
Date: Mon, 07 Apr 2008 21:31:05 +0200
$PBExportHeader$w_main.srw
forward
global type w_main from w_base
end type
end forward

global type w_main from w_base
integer width = 2642
integer height = 1720
event ke_resize ( readonly long newwidth,  readonly long newheight )
end type
global w_main w_main

type variables
Public:
Boolean #ResizeObjects = TRUE, #TriggerDefaultCancelButtons
string #DefaultButton, #CancelButton
Private:
str_resize istr_controls[]
long il_oldwidth, il_oldheight
rect istr_workspace
boolean ib_suspend_sizing

end variables

forward prototypes
public subroutine of_setworkspace (readonly long al_x, readonly long al_y, readonly long al_w, readonly long al_h)
public subroutine of_resizeobjects (readonly boolean ab_resize)
public subroutine of_suspendresize ()
public subroutine of_resumeresize ()
public subroutine of_resizeobjects ()
public function rect of_getworkspace ()
public function integer of_getcontrolresizeattrib (readonly string as_controlname, ref str_resize astr)
public function integer of_getcontrolresizeattrib (readonly windowobject awo, ref str_resize astr)
public function integer of_setcontrolresizeattrib (readonly string as_controlname, readonly str_resize astr)
public function integer of_setcontrolresizeattrib (readonly windowobject awo, readonly str_resize astr)
public function boolean of_validaterequiredfields ()
public subroutine of_triggerbutton (readonly string as_buttonname)
end prototypes

event ke_resize(readonly long newwidth, readonly long newheight);n_svc_mgr lnv_svcman
n_svc_resize lnv_r

//skip if resize is suspended
IF ib_suspend_sizing THEN RETURN

lnv_svcman.of_loadsvc(lnv_r, CSvc.RESIZE)

//ensure values
IF il_oldwidth = 0 THEN il_oldwidth = newwidth
IF il_oldheight = 0 THEN il_oldheight = newheight

//skip if zero width or height
IF newwidth <= 0 OR newheight <= 0 THEN RETURN

lnv_r.of_resize(this, CFbase.WindowMain, istr_controls, il_oldwidth, il_oldheight, newwidth, newheight)

il_oldwidth = newwidth
il_oldheight = newheight

//set workspace
istr_workspace.right = newwidth
istr_workspace.bottom = newheight
end event

public subroutine of_setworkspace (readonly long al_x, readonly long al_y, readonly long al_w, readonly long al_h);istr_workspace.left = al_x
istr_workspace.top = al_y
istr_workspace.right = al_w
istr_workspace.bottom = al_h
end subroutine

public subroutine of_resizeobjects (readonly boolean ab_resize);n_svc_mgr lnv_svcman
n_svc_resize lnv_r

#ResizeObjects = ab_resize

lnv_svcman.of_loadsvc(lnv_r, CSvc.RESIZE)

IF ab_resize THEN
   lnv_r.of_initresize(lnv_svcman, this, istr_controls)
END IF

this.TriggerEvent("resize")
end subroutine

public subroutine of_suspendresize ();IF #ResizeObjects THEN ib_suspend_sizing = TRUE
end subroutine

public subroutine of_resumeresize ();IF #ResizeObjects THEN 
   ib_suspend_sizing = FALSE
   TriggerEvent("resize")
END IF
end subroutine

public subroutine of_resizeobjects ();of_resizeobjects(FALSE)
end subroutine

public function rect of_getworkspace ();RETURN istr_workspace
end function

public function integer of_getcontrolresizeattrib (readonly string as_controlname, ref str_resize astr);long ll_count, n

ll_count = UPPERBOUND(istr_controls)

FOR n = 1 to ll_count
   IF lower(istr_controls[n].Controlname) = as_controlname THEN
      astr = istr_controls[n]
      RETURN n
   END IF
NEXT

RETURN CRet.FAILURE
end function

public function integer of_getcontrolresizeattrib (readonly windowobject awo, ref str_resize astr);long ll_count, n

ll_count = UPPERBOUND(istr_controls)

FOR n = 1 to ll_count
   IF istr_controls[n].Control = awo THEN
      astr = istr_controls[n]
      RETURN n
   END IF
NEXT

RETURN CRet.FAILURE
end function

public function integer of_setcontrolresizeattrib (readonly string as_controlname, readonly str_resize astr);long ll_count, n

ll_count = UPPERBOUND(istr_controls)

FOR n = 1 to ll_count
   IF lower(istr_controls[n].Controlname) = as_controlname THEN
      istr_controls[n] = astr
      RETURN n
   END IF
NEXT

RETURN CRet.FAILURE
end function

public function integer of_setcontrolresizeattrib (readonly windowobject awo, readonly str_resize astr);long ll_count, n

ll_count = UPPERBOUND(istr_controls)

FOR n = 1 to ll_count
   IF istr_controls[n].Control = awo THEN
      istr_controls[n] = astr
      RETURN n
   END IF
NEXT

RETURN CRet.FAILURE
end function

public function boolean of_validaterequiredfields ();n_svc_mgr lnv_svc
n_svc_requirededit lnv_r

lnv_svc.of_LoadSvc(lnv_r, CSvc.REQUIRED_EDIT)
RETURN lnv_r.of_ValidateRequiredFields(lnv_svc, this)
end function

public subroutine of_triggerbutton (readonly string as_buttonname);n_svc_mgr lnv_svc
n_svc_window lnv_w

lnv_svc.of_LoadSvc(lnv_w, CSvc.WINDOW)
lnv_w.of_TriggerButton(lnv_svc, this, as_buttonname)
end subroutine

on w_main.create
call super::create
end on

on w_main.destroy
call super::destroy
end on

event resize;call super::resize;IF #ResizeObjects THEN 
   //skip minimizing
   IF sizetype = 1 THEN RETURN
   EVENT ke_resize(WorkSpaceWidth(), WorkSpaceHeight())
END IF
end event

event ke_postinit;call super::ke_postinit;//init resize
this.of_resizeobjects(#Resizeobjects)
end event

event key;call super::key;IF #TriggerDefaultCancelButtons THEN
   CHOOSE CASE key
      CASE KeyEnter!
         of_TriggerButton(#DefaultButton)
      CASE KeyEscape!
         of_TriggerButton(#CancelButton)
   END CHOOSE
END IF
end event