of_resize


pfcdwsrv.pbl   >   pfc_n_cst_dwsrv_resize   >   of_resize   

Full name pfc_n_cst_dwsrv_resize.of_resize
Access protected
Extend of integer
Return value integer
Prototype protected function integer of_resize(integer,integer)

Name Datatype
No Data

Name Datatype
li_cnt integer
li_deltaheight integer
li_deltawidth integer
li_height integer
li_placeheight integer
li_placewidth integer
li_rc integer
li_upperbound integer
li_width integer
li_x integer
li_y integer
lr_move_deltax real
lr_move_deltay real
lr_ratioheight real
lr_ratiowidth real
lr_resize_deltaheight real
lr_resize_deltawidth real
ls_complexmodifyexp string
ls_control string
ls_modifyret string
ls_singlemodifyexp string
ls_type string
MINIMUM_SIZE integer

protected function integer of_resize (integer ai_newwidth, integer ai_newheight);//////////////////////////////////////////////////////////////////////////////
//
//	Function:  		of_Resize
//
//	Access:  		protected
//
//	Arguments:		
//	ai_newwidth		The new width of the parent object.
//	ai_newheight	The new height of the parent object.
//
//	Returns:  		integer
//						1 if it succeeds and -1 if an error occurs.
//
//	Description:  	Moves or resizes objects that were registered with the service.
//						Performs the actions that were requested via the
//						of_SetOrigSize() and of_Register functions.
//
//////////////////////////////////////////////////////////////////////////////
//
//	Revision History
//
//	Version
//	6.0   Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
//	Copyright © 1996-1999 Sybase, Inc. and its subsidiaries.  All rights reserved.
//	Any distribution of the PowerBuilder Foundation Classes (PFC)
//	source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
//Note: For the line control: the width and height variables are
//										used to hold EndX and EndY attributes.
//////////////////////////////////////////////////////////////////////////////

//Local variables
constant integer MINIMUM_SIZE =0

string			ls_control
string			ls_type
integer			li_upperbound
integer			li_rc
integer			li_cnt
integer			li_x, li_y, li_width, li_height
integer			li_deltawidth, li_deltaheight
real				lr_ratiowidth, lr_ratioheight
real				lr_move_deltax, lr_move_deltay
real				lr_resize_deltawidth, lr_resize_deltaheight
string			ls_singlemodifyexp, ls_complexmodifyexp
string			ls_modifyret
integer 			li_placewidth, li_placeheight

// Validate the reference.
If IsNull(idw_requestor) or Not IsValid(idw_requestor) Then
	Return -1
End If

//Confirm that the user object has already been initialized
If il_parentprevheight=-1 And il_parentprevwidth=-1 Then
	Return -1
End If

//Check the parameters
If IsNull(ai_newwidth) or IsNull(ai_newheight) Then
	return -1
End If

//Prevent the contents of the windows from resizing past the min width/height
If ai_newwidth < il_parentminimumwidth   Then ai_newwidth = il_parentminimumwidth
If ai_newheight < il_parentminimumheight Then ai_newheight = il_parentminimumheight

//Set the deltas/ratios for the width and height as compared to the previous size
li_deltawidth  = ai_newwidth  - il_parentprevwidth 
li_deltaheight = ai_newheight - il_parentprevheight
If il_parentprevwidth=0 Then il_parentprevwidth=1
If il_parentprevheight=0 Then il_parentprevheight=1	
lr_ratiowidth  = ai_newwidth  / il_parentprevwidth
lr_ratioheight = ai_newheight / il_parentprevheight

//Only continue if the size has changed
If li_deltawidth=0 And li_deltaheight=0 Then Return 1

//Set the new previous size
il_parentprevwidth = ai_newwidth
il_parentprevheight = ai_newheight

///////////////////////////////////////////////////////////////////////////////////////////////
// Loop through all registered controls - Moving and resizing as appropriate
///////////////////////////////////////////////////////////////////////////////////////////////

//Loop trough all controls
li_upperbound = UpperBound (inv_registered[])
For li_cnt = 1 to li_upperbound
	
	//Initialize variables
	li_x = 0
	li_y = 0 
	li_width = 0
	li_height = 0
	lr_move_deltax = 0	
	lr_move_deltay = 0
	lr_resize_deltawidth = 0	
	lr_resize_deltaheight = 0	
	ls_singlemodifyexp = ''
	
	If Len(inv_registered[li_cnt].s_control) > 0 Then
		li_rc = of_GetObjectInformation (inv_registered[li_cnt].s_control, ls_type, li_x, li_y, li_width, li_height)
		If li_rc < 0 then Return -1
		
		//Correct for any ii_rounding or moving/resizing of objects trough
		//any other means
		If abs(inv_registered[li_cnt].r_x - li_x) > ii_rounding Then
			inv_registered[li_cnt].r_x = li_x
		End If				
		If abs(inv_registered[li_cnt].r_y - li_y) > ii_rounding Then
			inv_registered[li_cnt].r_y = li_y
		End If		
		If abs(inv_registered[li_cnt].r_width - li_width) > ii_rounding And &
		   li_width > MINIMUM_SIZE  Then
			inv_registered[li_cnt].r_width = li_width
		End If							
		If abs(inv_registered[li_cnt].r_height - li_height) > ii_rounding And &
		   li_height > MINIMUM_SIZE  Then
			inv_registered[li_cnt].r_height = li_height
		End If			
		
		//Define the deltas for this control:  Move and Resize
		If inv_registered[li_cnt].b_scale Then
			lr_move_deltax = (inv_registered[li_cnt].r_x * lr_ratiowidth) - inv_registered[li_cnt].r_x
			lr_move_deltay = (inv_registered[li_cnt].r_y * lr_ratioheight) - inv_registered[li_cnt].r_y
			lr_resize_deltawidth = (inv_registered[li_cnt].r_width * lr_ratiowidth) - inv_registered[li_cnt].r_width
			lr_resize_deltaheight = (inv_registered[li_cnt].r_height * lr_ratioheight) - inv_registered[li_cnt].r_height
		Else
			// Prevent the weighted value from being overriden.
			If inv_registered[li_cnt].b_movex And inv_registered[li_cnt].i_movex = 0 Then
				inv_registered[li_cnt].i_movex = 100
			End If
			If inv_registered[li_cnt].b_movey And inv_registered[li_cnt].i_movey = 0 Then
				inv_registered[li_cnt].i_movey = 100
			End If
			If inv_registered[li_cnt].b_scalewidth And inv_registered[li_cnt].i_scalewidth=0 Then
				inv_registered[li_cnt].i_scalewidth = 100
			End If
			If inv_registered[li_cnt].b_scaleheight And inv_registered[li_cnt].i_scaleheight=0 Then
				inv_registered[li_cnt].i_scaleheight = 100
			End If			
			
			// Support for weighted movement and sizing of controls.
			If inv_registered[li_cnt].b_movex Then 
				lr_move_deltax = li_deltawidth * inv_registered[li_cnt].i_movex / 100
			End If
			If inv_registered[li_cnt].b_movey Then 
				lr_move_deltay = li_deltaheight * inv_registered[li_cnt].i_movey / 100
			End If
			If inv_registered[li_cnt].b_scalewidth Then 
				lr_resize_deltawidth = li_deltawidth * inv_registered[li_cnt].i_scalewidth / 100
			End If
			If inv_registered[li_cnt].b_scaleheight Then 
				lr_resize_deltaheight = li_deltaheight * inv_registered[li_cnt].i_scaleheight /100
			End If
		End If

		//If appropriate move the control along the X and Y attribute.
		If lr_move_deltax <> 0 Or lr_move_deltay <> 0 Then	
			//Save the 'exact' X and Y attributes.
			inv_registered[li_cnt].r_x = inv_registered[li_cnt].r_x + lr_move_deltax		
			inv_registered[li_cnt].r_y = inv_registered[li_cnt].r_y + lr_move_deltay
			
			If Pos(ls_type, LINE) > 0 Then
				inv_registered[li_cnt].r_width = inv_registered[li_cnt].r_width + lr_move_deltax
				inv_registered[li_cnt].r_height = inv_registered[li_cnt].r_height + lr_move_deltay
				ls_singlemodifyexp = ls_singlemodifyexp + &
									inv_registered[li_cnt].s_control+'.X1 = '+string(Integer(inv_registered[li_cnt].r_x))+' '+&
									inv_registered[li_cnt].s_control+'.X2 = '+string(Integer(inv_registered[li_cnt].r_width))+' '+&
									inv_registered[li_cnt].s_control+'.Y1 = '+string(Integer(inv_registered[li_cnt].r_y))+' '+ &
									inv_registered[li_cnt].s_control+'.Y2 = '+string(Integer(inv_registered[li_cnt].r_height))+' '
			Else
				ls_singlemodifyexp = ls_singlemodifyexp + &
									inv_registered[li_cnt].s_control+'.X = '+string(Integer(inv_registered[li_cnt].r_x))+' '+&
									inv_registered[li_cnt].s_control+'.Y = '+string(Integer(inv_registered[li_cnt].r_y))+' '					
			End If
		End If /* Move */
		
		//If appropriate Resize the Width And Height of the control.
		If lr_resize_deltawidth <> 0 Or lr_resize_deltaheight <> 0 Then		
			//Save the 'exact' Width and Height attributes.
			inv_registered[li_cnt].r_width = inv_registered[li_cnt].r_width + lr_resize_deltawidth	
			inv_registered[li_cnt].r_height = inv_registered[li_cnt].r_height + lr_resize_deltaheight		

			// Determine the placement variables.
			If inv_registered[li_cnt].r_width > MINIMUM_SIZE  Then
				li_placewidth = inv_registered[li_cnt].r_width
			Else
				li_placewidth = MINIMUM_SIZE 
			End If
			If inv_registered[li_cnt].r_height > MINIMUM_SIZE  Then
				li_placeheight = inv_registered[li_cnt].r_height
			Else
				li_placeheight = MINIMUM_SIZE 
			End If							
			
			If Pos(ls_type, LINE) > 0 Then
				ls_singlemodifyexp = ls_singlemodifyexp + &
									inv_registered[li_cnt].s_control+'.X2 = '+string(Integer(li_placewidth))+' '+ &
									inv_registered[li_cnt].s_control+'.Y2 = '+string(Integer(li_placeheight))+' '				
			Else
				ls_singlemodifyexp = ls_singlemodifyexp + &
									inv_registered[li_cnt].s_control+'.Width = '+string(Integer(li_placewidth))+' '+ &
									inv_registered[li_cnt].s_control+'.Height = '+string(Integer(li_placeheight))+' '				
			End If			
		End If /* Resize */

		// Batch all into one Large Modify expression.
		If Len(ls_singlemodifyexp) > 0 Then
			ls_complexmodifyexp += '   ' + ls_singlemodifyexp
		End If
		
	End If /* If IsValid(inv_registered[li_cnt].wo_control) Then */
Next /* For li_cnt = 1 to li_upperbound */

// Execute the one Modify expression.
If Len(ls_complexmodifyexp) > 0 Then
	ls_modifyret = idw_requestor.Modify(ls_complexmodifyexp)
	If IsNull(ls_modifyret) or Len(ls_modifyret) > 0 Then	
		Return -1
	End If				
End If

Return 1

end function

     
Name Owner
pfc_n_cst_dwsrv_resize.pfc_resize pfc_n_cst_dwsrv_resize

     
Name Owner
datawindow.modify datawindow
systemfunctions.abs systemfunctions
systemfunctions.integer systemfunctions
systemfunctions.isnull systemfunctions
systemfunctions.isvalid systemfunctions
systemfunctions.len systemfunctions
systemfunctions.pos systemfunctions
systemfunctions.string systemfunctions
systemfunctions.upperbound systemfunctions
pfc_n_cst_dwsrv_resize.of_getobjectinformation pfc_n_cst_dwsrv_resize

     
Full name
No Data

     
Name Scope
No Data