Reusable Part S_155RST: Reusable Status Bar

LANSA

Reusable Part S_155RST: Reusable Status Bar
Name: S_155RST

Description: The following RDMLX reusable part is part of the BASE_xxxx series of examples that have been designed to provide you with base examples of common layout and functionality that you may choose to reuse when constructing your own applications.
* ===================================================================
*
* Component : S_155RST
* Type : Form
* Ancestor : PRIM_FORM
*
* Description : Standardized Status Bar
* The following RDMLX reusable part is part of the S_155xxx series of examples that
* have been designed to provide you with base examples of common layout and
* functionality that you may choose to reuse when constructing your own applications.
*
*
* Disclaimer : The following material is supplied as sample material
* only. No warranty concerning this material or its use
* in any way whatsoever is expressed or implied.
*
* ===================================================================


* ============================================================

* This component is a base for a compound status bar component.

* It has the following properties:

* uBusy
* -----
* Set to true or false when starting and ending a long running
* activity. Setting to false also closes any visible progress bar.

* uPercentageComplete
* -------------------
* Set to a number in the range 1 to 100 to update the status
* bar. Set to 0 to close the progress bar

* uShowDate
* ---------
* Set to true or false to indicate whether the current
* date should appear in the status bar.

* uShowTime
* ---------
* Set to true or false to indicate whether the current
* time should appear in the status bar.

* uStatusText
* -----------
* Sets a text value to show a small piece of text (in addition
* to any status message). Set to blanks to make the status
* text field disappear from the status bar.


* uStatusNumber
* -------------
* Sets a numeric value to show a number (in addition to
* any status message). Set to 0 to make the status number
* field disappear from the status bar.

* ============================================================

FUNCTION OPTIONS(*DIRECT)
BEGIN_COM DISPLAYPOSITION(1) HEIGHT(16) LAYOUTMANAGER(#FWLM_1) LEFT(0) TABPOSITION(1) TOP(0) VISUALSTYLEOFPARENT(False) WIDTH(417)
DEFINE_COM CLASS(#DATE.Visual) NAME(#BARDATE) DISPLAYALIGNMENT(Center) DISPLAYPOSITION(4) HEIGHT(16) LEFT(190) MARGINLEFT(0) PARENT(#COM_OWNER) READONLY(True) TABPOSITION(1) TABSTOP(False) VISUALSTYLE(#VS_NOREAD) WIDTH(59)
DEFINE_COM CLASS(#TIME.Visual) NAME(#BARTIME) DISPLAYALIGNMENT(Center) DISPLAYPOSITION(5) HEIGHT(16) LEFT(250) MARGINLEFT(0) PARENT(#COM_OWNER) READONLY(True) TABPOSITION(3) TABSTOP(False) VISUALSTYLE(#VS_NOREAD) WIDTH(54)
DEFINE_COM CLASS(#PRIM_PGBR) NAME(#PROGBAR) DISPLAYPOSITION(6) HEIGHT(16) LEFT(305) MAXIMUMVALUE(100) MINIMUMVALUE(0) PARENT(#COM_OWNER) TABPOSITION(4) TABSTOP(False) TOP(0) VISIBLE(False) VISUALSTYLE(#VS_NOREAD) WIDTH(80)
DEFINE_COM CLASS(#PRIM_IMGE) NAME(#IMG_STOP) DISPLAYPOSITION(7) HEIGHT(16) LEFT(386) PARENT(#COM_OWNER) TABPOSITION(5) TABSTOP(False) TOP(0) VISIBLE(False) VISUALSTYLE(#VS_NORM) VISUALSTYLEOFPARENT(False) WIDTH(15)
DEFINE_COM CLASS(#PRIM_IMGE) NAME(#IMG_GO) DISPLAYPOSITION(8) HEIGHT(16) LEFT(402) PARENT(#COM_OWNER) TABPOSITION(2) TABSTOP(False) TOP(0) VISIBLE(False) WIDTH(15)
DEFINE_COM CLASS(#PRIM_TIMR) NAME(#BARTIMER) INTERVAL(0)
DEFINE_COM CLASS(#STD_TEXTS.Visual) NAME(#STATUSTEXT) DISPLAYALIGNMENT(Center) DISPLAYPOSITION(1) HEIGHT(16) MARGINLEFT(0) PARENT(#COM_OWNER) READONLY(True) TABPOSITION(6) TABSTOP(False) VISUALSTYLE(#VS_NOREAD) WIDTH(62)
DEFINE_COM CLASS(#STD_NUM.Visual) NAME(#STATUSNUMBER) DISPLAYALIGNMENT(Center) DISPLAYPOSITION(2) HEIGHT(16) LEFT(63) MARGINLEFT(0) PARENT(#COM_OWNER) READONLY(True) TABPOSITION(7) TABSTOP(False) VISUALSTYLE(#VS_NOREAD) WIDTH(30)
DEFINE_COM CLASS(#USER.Visual) NAME(#USER) DISPLAYALIGNMENT(Center) DISPLAYPOSITION(3) HEIGHT(16) LEFT(94) MARGINLEFT(0) PARENT(#COM_OWNER) READONLY(True) TABPOSITION(8) TABSTOP(False) VISUALSTYLE(#VS_NOREAD) WIDTH(95)

DEFINE_COM CLASS(#PRIM_FWLM) NAME(#FWLM_1) FLOWOPERATIONHOR(Decrease) FLOWOPERATIONVER(Decrease) SPACING(1) SPACINGITEMS(1)
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_1) MANAGE(#BARDATE) PARENT(#FWLM_1)
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_2) MANAGE(#BARTIME) PARENT(#FWLM_1)
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_3) MANAGE(#PROGBAR) PARENT(#FWLM_1)
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_4) MANAGE(#IMG_STOP) PARENT(#FWLM_1)
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_5) MANAGE(#IMG_GO) PARENT(#FWLM_1)
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_6) MANAGE(#STATUSTEXT) PARENT(#FWLM_1)
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_7) MANAGE(#STATUSNUMBER) PARENT(#FWLM_1)
DEFINE_COM CLASS(#PRIM_FWLI) NAME(#FWLI_8) MANAGE(#USER) PARENT(#FWLM_1)



Define #StopImage RefFld(#Std_Texts) Default('stopligh.bmp')
Define #GoImage RefFld(#Std_Texts) Default('golight.bmp')
Define #TimeIntvl RefFld(#Std_Num) Default(10000)


Define_Pty uBusy Set(SetBusy)
Define_Pty uPercentageComplete Set(SetComplete)
Define_Pty uShowDate Set(SetDate)
Define_Pty uShowTime Set(SetTime)
Define_Pty uStatusText Set(SetStatusText)
Define_Pty uStatusNumber Set(SetStatusNumber)

Define #TmpChar20 *char 20


* ========================
* Handle Instance Creation
* ========================


EVTROUTINE HANDLING(#Com_Owner.CreateInstance) OPTIONS(*NOCLEARERRORS *NOCLEARMESSAGES)

Use Tconcat (*part_dir_execute #StopImage) (#sysvar$av)
Set #Img_Stop Visible(False) Filename(#sysvar$av)
Use Tconcat (*part_dir_execute #GoImage) (#sysvar$av)
Set #Img_Go Visible(False) Filename(#sysvar$av)

Set #BarTime Value(*Time)
Set #BarDate Value(*Date)
Use Convertdate (*datec A Q) (#TmpChar20)
Set #BarDate Hint(#TmpChar20)

Set #BarTimer Interval(#TimeIntvl)

Set (#StatusText #StatusNumber #ProgBar) Visible(False)

EndRoutine

* ================================
* Handle changes to uBusy property
* ================================


PtyRoutine SetBusy
Define_Map *Input #Std_Bool #Prop001

Use UpperCase (#Prop001) (#Std_Bool)

if '#Std_Bool = True'
set #img_go visible(False)
set #img_stop visible(True)
Set #Com_Owner uStatusText('Busy')
Else
set #img_stop visible(False)
set #img_go visible(True)
Set #Com_Owner uPercentageComplete(0)
Set #Com_Owner uStatusText('Ready')
Endif

Invoke #Com_Owner.UpdateDisplay

EndRoutine

* =============================
* Handle changes to uStatusText
* =============================

PtyRoutine SetStatusText
Define_Map *Input #Std_TextS #Prop006

if '#Prop006.Value = *blanks'
Set #StatusText Value(' ') Visible(False)
Else
Set #StatusText Value(#Prop006.Value) Visible(True)
Endif

Invoke #Com_Owner.UpdateDisplay

EndRoutine

* ===============================
* Handle changes to uStatusNumber
* ===============================

PtyRoutine SetStatusNumber
Define_Map *Input #Std_Num #Prop007

if '#Prop007.Value = 0'
Set #StatusNumber Value(0) Visible(False)
Else
Set #StatusNumber Value(#Prop007.Value) Visible(True)
Endif

Invoke #Com_Owner.UpdateDisplay

EndRoutine


* ====================================
* Handle changes to uShowDate property
* ====================================

PtyRoutine SetDate
Define_Map *Input #Std_Bool #Prop003

Use UpperCase (#Prop003) (#Std_Bool)

Set #BarDate Visible(#Std_Bool)

Invoke #Com_Owner.UpdateDisplay

EndRoutine

* ====================================
* Handle changes to uShowTime property
* ====================================

PtyRoutine SetTime
Define_Map *Input #Std_Bool #Prop004

Use UpperCase (#Prop004) (#Std_Bool)

if '#Std_Bool = True'
Set #BarTime Visible(True)
If '#BarTimer.Interval = 0'
Set #BarTimer Interval(#TimeIntvl)
Endif
Else
Set #BarTime Visible(False)
Set #BarTimer Interval(0)
Endif

Invoke #Com_Owner.UpdateDisplay

EndRoutine


* ==============================================
* Handle changes to uPercentageComplete property
* ==============================================

PtyRoutine SetComplete
Define_Map *Input #Std_Num #Prop002

Change #Std_Num #Prop002.Value

Case #Std_Num
When '<= 0'
Set #ProgBar Visible(False) Value(0)
Return
When '> 100'
Change #Std_Num 100
OtherWise
EndCase

Set #ProgBar Visible(True) Value(#Std_Num)

EndRoutine


* ========================
* Handle tick of the timer
* ========================

EVTROUTINE HANDLING(#BarTIMER.Tick) OPTIONS(*NOCLEARMESSAGES *NOCLEARERRORS)
Define #CurDate RefFld(#Date)

Change #BarTime *Time
Change #CurDate *Date

if '#CurDate *ne #BarDate'
Change #BarDate #CurDate
Use Convertdate (*datec A Q) (#TmpChar20)
Set #BarDate Hint(#TmpChar20)
Endif

ENDROUTINE

END_COM