In the next set of posts I’ll be converting my Action! libraries Gadget routines. Gadgets are what I refer to as the widgets used in conjunction with the windowing library to create form based input. Think of a gadget as an input mechanism like a button (OK, Cancel, etc), a radio button (where only 1 over several choices can be selected), a checkbox, etc. The first one I converted is not so much as an input control, but a way to show progress to a user during a slow operation. This is the GProg() function.
This function is called with the placement location within an already opened window handle, and the value (0 to 100) to display.
Here is the code that demonstrates:
// ------------------------------------------------------------
// Program: gprog.c
// Desc...: A8 Library Progress Gadget Test
// Author.: Ripdubski
// Date...: 202208
// Notes..: cl65 -v [-O] -t atarixl gprog.c -o gprog.xex
// ------------------------------------------------------------
// Pull in include files
#include <stdio.h>
#include <conio.h>
#include <unistd.h>
#include <string.h>
#include <atari.h>
#include "a8defines.h"
#include "a8defwin.h"
#include "a8libmisc.c"
#include "a8libstr.c"
#include "a8libwin.c"
#include "a8libgadg.c"
#include "a8libmenu.c"
// ------------------------------------------------------------
// Func...: void DoProg(void)
// Desc...: Displays progress bar demo
// ------------------------------------------------------------
void DoProg(void)
{
byte bL, bW;
// Open window
bW = WOpen(9, 10, 22, 4, WOFF);
WOrn(bW, WPTOP, WPLFT, "Progress");
// Loop through progress
for (bL=1; bL <= 100; bL+=5)
{
// Display the progress bar and wait 1 second
GProg(bW, 1, 2, bL);
sleep(1);
}
// Close window
WClose(bW);
return;
}
// ------------------------------------------------------------
// Func...: void main(void)
// Desc...: Main routine
// ------------------------------------------------------------
void main(void)
{
// Variables
byte bW1, bW2, bC, bD;
unsigned char *pcM[7] = { " Alert ", " Progress ", " Buttons ", " Checkboxes ", " Radio Button ", " Quit " };
// Setup screen
WInit();
WBack(14);
// Open windows
bW1 = WOpen(0, 0, 40, 3, WON);
WPrint(bW1, WPCNT, 1, WOFF, "CC65 A8 Library Test");
bW2 = WOpen(12, 6, 16, 10, WOFF);
WOrn(bW2, WPTOP, WPCNT, "Menu");
// Set done to false
bD = FALSE;
// Loop until done (Quit selected)
while (! bD) {
// Call menu
bC = MenuV(bW2, 1, 2, WON, 1, 6, pcM);
// Process choice
switch (bC)
{
case 1: GAlert("Alert! menu option 1 selected!");
break;
case 2: DoProg();
break;
case 3: GAlert("Alert! menu option 3 selected!");
break;
case 4: GAlert("Alert! menu option 4 selected!");
break;
case 5: GAlert("Alert! menu option 5 selected!");
break;
case 6: bD = TRUE;
break;
}
}
// Wait for a keypress
while (! kbhit()) { };
// Close windows
WClose(bW2);
WClose(bW1);
// Exit
return;
}
Here is a screenshot showing what it looks like.
