Category : Files from Magazines
Archive   : DDJ9406A.ZIP
Filename : GUI_DB.ASC

 
Output of file : GUI_DB.ASC contained in archive : DDJ9406A.ZIP
_DEVELOPING GUIs FOR DATABASE APPLICATIONS_
by John Rodley

Listing One

# Definition of the menu bar. Note the parameter attached to every menu item.
action bar MainMenu_AB is
enabled pulldown Activity_PD text "~Activity"
enabled choice Workout_MC text "~Workout"
parameter is "Workout"
enabled choice Sleep_MC text "~Sleep"
parameter is "Sleep"
enabled choice Meal_MC text "~Meal"
parameter is "Meal"
# the rest of the menu bar def. would be here
...
...
...

# This item class contains all the menu choices.
item class EditNewDelete_CL is
Workout_MC Sleep_MC Meal_MC Weighin_MC Injury_MC
Treatment_MC Checkup_MC Ingredient_MC Recipe_MC Diary_MC

# This is the main window definition for the application.
# It contains the menu bar MainMenu_AB.
enabled visible color 26
primary graphical region Main_GR size 475 179
at position 83 112
in desktop
window size 475 179 at position 0 0
color 27 foreground
size border
title bar "Total Health"
system menu
horizontal scroll bar scroll by 6
vertical scroll bar scroll by 2
action bar MainMenu_AB
minimize button
maximize button

# This response block is called whenever an item in
# class EditNewDelete_CL is chosen.
response to item EditNewDelete_CL
copy parameter to Thread
copy "OPEN_" Thread to OpenAction
copy "FETCH_" Thread to FetchAction
copy "CLOSE_" Thread to CloseAction
copy Thread "ListAction" to ListAction
make GenericList_DB visible
change GenericList_DB text to Thread
action FetchThemAll

# Loops over FetchAction until there are no more items in the table.
action FetchThemAll is
clear GenericList_LB in GenericList_DB
action OpenAction
while(( Esqlca.Sqlcode != END_OF_DATA ) and
(Esqlca.Sqlcode != CURSOR_CLOSED ))
loop
action FetchAction
if(( Esqlca.Sqlcode != END_OF_DATA ) and
(Esqlca.Sqlcode != CURSOR_CLOSED )) then
action ListAction
end if
end loop
action CloseAction

# This action formats a single line for the WorkoutList dialog box.
# There is an action like this one for every type of list: Meals, Injuries, ...
action WorkoutListAction is
if( Description != "" and DateTime != "" ) then
copy Description " " DateTime to TS
add to GenericList_LB in GenericList_DB
insert TS
end if

# Response to the edit button in the single, generic list dialog box. It uses
# the variable Thread that we filled in earlier from parameter of menu item.
response to Edit_PB in GenericList_DB
change GenericList_DB text to ""
make GenericList_DB invisible
copy Thread "EditAction" to LoadEditDBAction
copy Thread "_DB" to DialogBoxName
action LoadEditDBAction

# This is the action that fills in the edit item dialog box.
action WorkoutEditAction is
make DialogBoxName visible # This brings up the dialog
change Description_EF in Workout_DB text to LastName
change DateTime_EF in Workout_DB text to DateTime
change Duration_EF in Workout_DB text to Systolic
change Intensity_EF in Workout_DB text to Diastolic
change Comments in Workout_DB text to LDL



Listing Two

"The initialization code for the workout list and workout item dialog boxes."
"Some of the control definitions have been left out for brevity."

"The workout list form."
form := Form
name: #WorkoutList
rect: {22 431 2043 862}
controller: controller.
form setInitialFocusTo: #OKButton.
cItem := controller add: #OKButton
class: FormButton
rect: {511 611 350 90}
options: {#Return #Tab #Up #Down #Backtab #Left #Right}
form: form
text: '~Edit'.

".... Other control definitions would be here ..."

cItem := controller add: #ListBox
class: FormLinkedTabList
rect: {49 41 1676 469}
options: {#Return #Tab #Backtab}
form: form.
cItem setSplitPositionTo: nil.
"The following 2 lines link the TabularListBox cItem to the"
"database table #WORKOUT."
tLink := TableLink newIdentifier: #WORKOUT attribute: #ALL.
controller setLinksTo: cItem link: tLink.

temp := AcceleratorTable new.
temp at: #AltC put: #cancelList.
temp at: #Altc put: #cancelList.
temp at: #AltD put: #deleteWorkout.
temp at: #Altd put: #deleteWorkout.
temp at: #AltE put: #editItem.
temp at: #Alte put: #editItem.
form setAcceleratorTableTo: temp.

"Here is the initialization code for the edit workout item dialog box. Note"
"there is a link for every entry field to a field in the database record."
form := Form
name: #Workout
rect: {135 7 1837 851}
controller: controller.
form setGridTo: false.
form setSnapTo: false.
form setXGridResTo: 82.
form setYGridResTo: 82.
temp := IdentityDictionary newEntries: 2.
temp at: #cancelButton1 put: #cancelWorkout.
temp at: #OKButton1 put: #saveWorkout.
form setReturnActionsTo: temp.
form setInitialFocusTo: #Description.

".... All the static control definitions would be here ..."
cItem := controller add: #Description
class: FormString
rect: {514 50 420 60}
options: {#HResize #Return #Tab #Backtab #Return
#Return #Return}
form: form.
cItem setMaximumLengthTo: 20.
tLink := TableLink newIdentifier: #WORKOUT attribute: #DESCRIPTION.
controller setUpdateLinksTo: cItem link: tLink.
cItem := controller add: #DateTime
class: FormString
rect: {514 135 420 60}
options: {#HResize #Return #Tab #Backtab
#Return #Return #Return}
form: form.
cItem setMaximumLengthTo: 26.
tLink := TableLink newIdentifier: #WORKOUT attribute: #DATETIME.
controller setUpdateLinksTo: cItem link: tLink.
cItem := controller add: #Location
class: FormString
rect: {514 220 420 60}
options: {#HResize #Return #Tab #Backtab
#Return #Return #Return}
form: form.
cItem setMaximumLengthTo: 20.
tLink := TableLink newIdentifier: #WORKOUT attribute: #LOCATION.
controller setUpdateLinksTo: cItem link: tLink.
cItem := controller add: #Duration
class: FormNumber
rect: {514 305 420 60}
options: {#Return #Tab #Backtab #Return
#Return #Return}
form: form.
tLink := TableLink newIdentifier: #WORKOUT attribute: #DURATION.
controller setUpdateLinksTo: cItem link: tLink.
cItem := controller add: #Intensity
class: FormNumber
rect: {514 386 420 60}
options: {#Return #Tab #Backtab #Return
#Return #Return}
form: form.
tLink := TableLink newIdentifier: #WORKOUT attribute: #INTENSITY.
controller setUpdateLinksTo: cItem link: tLink.
cItem := controller add: #Comments
class: FormString
rect: {514 469 420 60}
options: {#HResize #Return #Tab #Backtab
#Return #Return #Return}
form: form.
tLink := TableLink newIdentifier: #WORKOUT attribute: #COMMENTS.
controller setUpdateLinksTo: cItem link: tLink.

".... The rest of the dialog control definitions would be here ..."




Listing Three

WorkplaceObject subclass: #ExecWPO
instanceVariableNames: '
FileName
SessionName
'
classVariableNames: '
'
poolDictionaries: '
' !

!ExecWPO class methods !

!"End of class methods block"

!ExecWPO methods !

open
"Override the default open method which would open the form associated with"
"this WorkPlaceObject. This call starts an external application. Must call "
" setSessionName and setFileName before opening this object!"
SessionName startSessionProgram: FileName inputs: 'new'.

!"end open "

setFileName: newFileName
"Set the filename of the executable we're going to run"
FileName := newFileName.
!"end setFilename"

setSessionName: newSessionName
"Set the title this session will have when 'opened'"
SessionName := newSessionName.
!"end setSessionName"

!"End of method block"



  3 Responses to “Category : Files from Magazines
Archive   : DDJ9406A.ZIP
Filename : GUI_DB.ASC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/