PFC Guide Titlebar
HomeFAQLinksPFCMAGExtensionsDownloadWhat's NewSearch

StatusBar Color Extension

Ver. 1.0
Contributed by Vladimir Uzlaner



What

w_statusbar
n_cst_wnsrv_statusbar

Why

PFC statusbar functions allow us to change only 'Value' and 'Border'. This example shows how extend the service, adding possibility change Text Color and Background Color of objects on the Status Bar. This extension also provides an example of how we can add new object to the Status Bar.

I made this extension for the following requirements:

- The Status Bar should display the current datawindow (u_dw control) mode (Query Mode or Edit Mode).

- The Background of the 'Indicator' object on the Status Bar should be yellow for Query Mode , and blue - for Edit Mode.

How

In the Extension Layer change w_statusbar and n_cst_wnsrv_statusbar:

n_cst_wnsrv_statusbar

First of all to add new object on the Status Bar add to the n_cst_wnsrv_statusbar object:

Instance variables:

boolean ibe_indicator	
integer iie_indicator_width = 400

New Functions:

boolean ofe_GetIndicator()

integer ofe_SetIndicator( boolean ab_switch)

integer ofe_SetIndicatorWidth( int ai_width):

Note: I used prefix ofe_ instead of of_ to show that this function are in the extension layer.

 

boolean ofe_GetIndicator():

//////////////////////////////////////////////////////////////////////////////
//
//	Function: of_GetIndicator
//
//	Access: Public
//	Arguments:	None
//	Returns: boolean
//	True if DW Status Indicator is being reported; otherwise false.
//
//	Description:
//	Reports True if DW Status Indicator is being reported; otherwise false.
//
//	Extension to the n_cst_winsrv_status_bar object
//
//////////////////////////////////////////////////////////////////////////////
Return ibe_indicator

 

integer ofe_SetIndicator( boolean ab_switch):

//////////////////////////////////////////////////////////////////////////////
//
//	Function: ofe_SetIndicator
//
//	Access: Public
//
//	Arguments:	
//	ab_switch	True to have the setting on the Status Bar.
//	
//	Returns: Integer
//	1 if it succeeds and -1 if an error occurs.
//
//	Description:
//	Sets the flag to indicate if DW Status Indicator is to be reported on the Status Bar.
//
//////////////////////////////////////////////////////////////////////////////
Integer li_rc
// Check arguments.
If IsNull( ab_switch) Then
	Return -1
End If
If ibe_indicator = ab_switch Then
	// No change.
	Return 0
End If
// Set the flag.
ibe_indicator = ab_switch
// Register or Unregister the Pre-Defined option.
If ibe_indicator Then
	li_rc = of_Register( 'pfc_indicator', 'text', 'Edit Mode', iie_indicator_width)
Else
	li_rc = of_UnRegister('pfc_indicator')
End If
Return li_rc

 

Integer ofe_SetIndicatorWidth( int ai_width):

//////////////////////////////////////////////////////////////////////////////
//
//	Function: of_SetIndicatorWidth
//
//	Access: Public
//
//	Arguments:
//	ai_width	The new Width.
//	
//	Returns: Integer
//	1 if it succeeds and -1 if an error occurs.
//
//	Description:
//	Sets a new Indicator Width value.
//
//////////////////////////////////////////////////////////////////////////////
// Check arguments.
If IsNull(ai_width) or ai_width < 0 Then
	Return -1
End If
iie_indicator_width = ai_width
Return 1

Add next function to overload the function with the same name on the upper level:

integer of_Modify( string as_id, string as_value, long ai_color , long ai_bkcolor):

//////////////////////////////////////////////////////////////////////////////
//
//	Function: of_Modify - overload by two new parameters
//
//	Access: Public
//
//	Arguments:
//	as_id	The ID of the object to be modified.
//	as_value	The value to be used on the modification of the object.
//	--------------------------------------------------------------------
// ai_color	The TextColor of new object on the StatusBar
// ai_bkcolor	The Bakground Color of new object on the StatusBar
//	
//	Returns: integer
//	1 if it succeeds and -1 if an error occurs.
//
//	Description:
//	Modifies the value of the User Defined object.
//	The object can either be a text value or a bitmap name.
Integer li_upper
Integer	li_cnt
string ls_temp
integer	li_rc =1
// Check arguments.
If IsNull(as_id) or Len(trim(as_id))= 0 or IsNull(as_value) or isNULL( ai_color) or &
isNULL( ai_bkcolor)Then
	Return -1
End If
// Check for a predefined id.
If of_IsPredefined( Trim( as_id)) Then
	// This is not a valid operation on a pre-defined ID.
	Return -1
End If
// Get the number of Items currently registered.
li_upper = UpperBound ( istr_dwobjects)
// Find the ID and Update it.
For li_cnt = 1 to li_upper
	If as_id = istr_dwobjects[li_cnt].s_id Then
		// Modify the value.
		istr_dwobjects[li_cnt].s_value = as_value
		// Notify the GUI of a new value.
		If IsValid(iw_statusbar) Then
			li_rc = iw_statusbar.of_UpdateVisuals( &
			istr_dwobjects[ li_cnt].s_id, istr_dwobjects[ li_cnt].s_type, &
			istr_dwobjects[ li_cnt].s_value, ai_color, ai_bkcolor)
		End If
		Return li_rc
	End If
Next
// The ID has not been registered.
Return -1

 

Because in the previous function you used of_UpdateVisuals() function with different arguments , you have to create new function in the w_statusbar object with the same name to overload it .

 

w_statusbar

integer of_UpdateVisuals( string as_id, string as_type, string as_value, long ai_color, long ai_bkcolor) :

//////////////////////////////////////////////////////////////////////////////
//
//	Function: of_UpdateVisuals to overload PFC function with new feature:
//	change Text Color and Background Color of Object
//
//	Access: Public
//
//	Arguments:	
//	as_id	The ID of the User Defined object which needs its value modified.
//	as_type	The Type of User Defined object. (text or bitmap)
//	as_value	The new desired value.
// ---------------------------------------------- + 
// ai_color The Text Color of Object on the Status Bar
// ai_bkcolor The Background Color of Object on the Status Bar
//	
//	Returns: Integer
//	1 if it succeeds and -1 if an error occurs.
//
//	Description:
//	Updates the User Defined object. 
//	This can either be Text or a new bitmap.
string	ls_modifyexp
string	ls_rc
// According to the Type, create the appropriate Modify statement.
If Pos(as_type, 'bitmap') > 0 Then
	ls_modifyexp = as_id+'.Expression="bitmap(~'' + as_value + '~')" '
Else
	ls_modifyexp = as_id+'.Expression=~'"'+ as_value + '"~' '	
End IF
ls_modifyexp = ls_modifyexp + '~n' + as_id + '.Color = ' + String( ai_color) + &
'~n' + as_id + '.Background.Color = ' + String( ai_bkcolor)
// Execute the Modify statment.	
ls_rc = dw_statusbar.Modify (ls_modifyexp)	
If Len(ls_rc) > 0 Then
	Return -1
End If
Return 1

That's it. Now how to use it. To activate this feature for any DataWindow object on the u_dw, I made follow changes in the u_dw object:

ue_qbe:

if isValid( this.inv_querymode) then
	if NOT this.inv_querymode.of_GetEnabled( ) then
		this.inv_querymode.of_SetResetCriteria( FALSE )	//Don't clear Query
		this.inv_querymode.of_SetEnabled( TRUE)
		//Set Indicator Window on the StatusBar to 'Edit Mode' :
		w_sheet	lw_parent
		w_frame lw_frame 
		// Get a reference to the window
		this.of_GetParentWindow (lw_parent) 
		if IsValid (lw_parent) then
			lw_frame = lw_parent.ParentWindow()
			if lw_frame.inv_statusbar.ofe_GetIndicator() then &
			lw_frame.inv_statusbar.of_Modify( "pfc_indicator", &
			"Query Mode", 0, 65535)
		end if
	Else
		this.inv_querymode.of_SetResetCriteria( TRUE )	//Clear Query
		this.inv_querymode.of_SetEnabled( TRUE)
	end if
end if

 

constructor:

//This example calls the of_SetRowManager function to enable the row management service:
this.of_SetRowManager(TRUE)
//This example calls the of_SetReqColumn function to enable the required column service:
this.of_SetReqColumn(TRUE)
//This example calls the of_SetQuerymode function to enable the querymode service:
this.of_SetQuerymode(TRUE)

 

getfocus:

this.BorderStyle = StyleShadowBox!

 

losefocus:

this.BorderStyle = StyleBox!

 

pfc_retrieve:

if NOT this.inv_querymode.of_GetEnabled() then return -1 //if not in QueryMOde then Return
this.inv_querymode.of_SetEnabled( FALSE)
//Set Indicator Window on the StatusBar to 'Edit Mode' :	Vova 09.15.97
w_sheet	lw_parent
w_frame lw_frame 
// Get a reference to the window
this.of_GetParentWindow (lw_parent) 
if IsValid (lw_parent) then
	lw_frame = lw_parent.ParentWindow()
	if lw_frame.inv_statusbar.ofe_GetIndicator() then &
	lw_frame.inv_statusbar.of_Modify( "pfc_indicator", &
	"Edit Mode", 65535, 16711680)
end if
return 0

 

3. On the w_sheet you can add the code below to reset 'Indicator' object.

Close:

//Set Indicator Window on the StatusBar to 'Edit Mode' :	Vova 09.16.97
w_frame lw_frame 
lw_frame = this.ParentWindow()
if lw_frame.inv_statusbar.ofe_GetIndicator() then &
lw_frame.inv_statusbar.of_Modify( "pfc_indicator", "Edit Mode", 0, 12632256)
return 0

 

That's all. Below is how it looks like:


Download the About the extension contributor

Interested in contributing material to this web site? Send an email to submit@pfcguide.com, but don't forget to check the contribution guidelines first.


For information or suggestions about this web site please contact webmaster@pfcguide.com

PFCGuide is sponsored by Dynamic Technology Group.
The information on this site is provided for advice only and not to be considered a contract or a liability against Dynamic Technology Group.

Last Revised: February 15, 2004 03:58 AM.