Commit 582c57aa authored by ASCP's avatar ASCP

Initial commit

parents
# Ignore the build and lib dirs
src/build
lib/*
# Ignore any executables
src/bin/*
# Ignore Mac specific files
.DS_Store
# Ignore FS-Uae files
*.uaem
# Ignore temp files
*.swp
# Ignore object files
*.o
# Changelog
All notable changes to this project will be documented in this file.
The format is based on http://keepachangelog.com/en/1.0.0/[Keep a Changelog]
and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioning].
## [1.0.1] - 2018-05-13
### Added
- Initial project
# CGLE
**Description**: A gadtools layout library
**Technology stack**: C, 68k, SAS/C 6.5x, Devpac
**Project Status**: https://gitlab.com/amigasourcecodepreservation/cgle/blob/master/CHANGELOG.adoc[CHANGELOG]
It is used by a few projects we have, but due to the unknown history and license status of this code, we can not encourage you to use it in your new projects. If you know more about this code, please enlighten us. We tried to find any framework from where it originated but failed. It is considered public domain.
## Dependencies
* Amiga OS Classic
* SAS/C 6.5x or compatible C-compiler
* Devpac or compatible assembler compiler
* http://aminet.net/package/util/cli/DoVer|DoVer
## Installation
* Put gle.lib in your path
## Getting help
If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.
## Getting involved
Contact your old amiga friends and tell them about our project, and ask them to dig out their source code or floppies and send them to us for preservation.
Clean up our hosted archives, and make the source code buildable with standard compilers like devpac, asmone, gcc 2.9x/Beppo 6.x, sas/c ,vbcc and friends.
Cheers!
....
_____ ___ _ __ __ _ __ __ ___ ___ _
|_ _| __| /_\ | \/ | /_\ | \/ |_ _/ __| /_\
| | | _| / _ \| |\/| | / _ \| |\/| || | (_ |/ _ \
_|_| |___/_/ \_\_|_ |_|_/_/_\_\_|__|_|___\___/_/_\_\
/ __|/ _ \| | | | _ \/ __| __| / __/ _ \| \| __|
\__ \ (_) | |_| | / (__| _| | (_| (_) | |) | _|
|___/\___/_\___/|_|_\\___|___|__\___\___/|___/|___|_
| _ \ _ \ __/ __| __| _ \ \ / /_\_ _|_ _/ _ \| \| |
| _/ / _|\__ \ _|| /\ V / _ \| | | | (_) | .` |
|_| |_|_\___|___/___|_|_\ \_/_/ \_\_| |___\___/|_|\_|
....
https://twitter.com/AmigaSourcePres[Twitter]
https://gitlab.com/amigasourcecodepreservation[Gitlab]
https://amigasourcepres.gitlab.io/[WWW]
## Licensing
cgle is distributed under unknown license. We consider it public domain until proven that it is not.
## Credits and references
The unknown author of this code.
DEBUG=FULL
DATA=FAR
CODE=FAR
MATH=STANDARD
PARAMETERS=REGISTERS
ANSI
NOSTACKCHECK
STRINGMERGE
NOCHECKABORT
COMMENTNEST
NOMULTIPLEINCLUDES
OPTIMIZE
OPTIMIZERSIZE
SAVEDS
SMALLCODE
SMALLDATA
STRIPDEBUG
OPTIMIZERSCHEDULER
NOVERSION
STRICT
UTILITYLIBRARY
NOICONS
MEMORYSIZE=MEDIUM
COMMON
OPTIMIZERALIAS
NOERRORLISTING
IGNORE=51
IGNORE=108
PUBSCREEN=Workbench
;
; macro definitions
;
GAD_MAXIMUM: equ 100 ; Maximum allowed gadgets
VERTICAL: equ 1 ; Initial window alignments
HORIZONTAL: equ 0
WARN: equ 1 ; Runtime non-fatal
ERROR: equ 2 ; Runtime fatal
BUG: equ 3 ; Error in programming
;
; structure offsets
;
RSRESET
PAN_Win: rs.l 1 ;Window for this panel
PAN_GList: rs.l 1 ;Gadget list
PAN_Title: rs.l 1 ;Window title string
PAN_WinX: rs.l 1 ;Window coords
PAN_WinY: rs.l 1
PAN_Width: rs.l 1 ;Window size
PAN_Height: rs.l 1
PAN_SIZEOF: equ __RS
RSRESET
XG_Gad: rs.l 1 ;Pointer to gadget structure
XG_Label: rs.l 1 ;Gadget label
rs.w 1
XG_x: rs.w 1 ;Gadget position and size
rs.w 1
XG_y: rs.w 1
rs.w 1
XG_Width: rs.w 1
rs.w 1
XG_Height: rs.w 1
XG_Disabled: rs.b 1 ;0=enabled 1=disabled
rs.b 1
XG_SIZEOF: equ __RS
This diff is collapsed.
SECTION calcblank,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcBlank
;
; Imported variables/functions
;
XREF init_xgad
XREF _LabelPixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; a0=text for gadget
; Exit: Blank gadget calculated
_CalcBlank:
movem.l d0-1/a0-1,-(a7)
jsr init_xgad ;Init x,y,height
clr.l XG_Label(a1)
moveq #0,d1 ;Width=LabelPixLength(Label)
bsr _LabelPixLength
move.w d0,XG_Width(a1)
movem.l (a7)+,d0-1/a0-1
rts
SECTION calcbutton,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcButton
;
; Imported variables/functions
;
XREF init_xgad
XREF calc_xlength
XREF _LabelPixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; a0=text for gadget
; Exit: Button gadget calculated
_CalcButton:
movem.l d0-1/a0-1,-(a7)
jsr init_xgad ;Init x,y,height
move.l a0,XG_Label(a1)
;Width = LabelPixLength (Label) + PixLength ("xx", 0);
moveq #0,d1
bsr _LabelPixLength
move.w d0,XG_Width(a1)
moveq #2,d0
jsr calc_xlength
add.w d0,XG_Width(a1)
movem.l (a7)+,d0-1/a0-1
rts
SECTION calccheckbox,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcCheckbox
;
; Imported variables/functions
;
XREF init_xgad
XREF calc_xlength
XREF _PixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; Exit: Checkbox gadget calculated
_CalcCheckbox:
movem.l d0-1/a0-1,-(a7)
jsr init_xgad ;Init x,y,height
moveq #3,d0 ;Set width to "xxx"
jsr calc_xlength
move.w d0,XG_Width(a1)
movem.l (a7)+,d0-1/a0-1
rts
SECTION measurestr,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcCycle
;
; Imported variables/functions
;
XREF init_xgad
XREF calc_xlength
XREF measure_strarray
XREF _PixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; a0=pointer to array of pointers to cycle values
; Exit: Cycle gadget calculated
_CalcCycle:
movem.l d0-1/a0-1,-(a7)
jsr init_xgad ;Init x,y,height
;Set width to width of longest cycle string + "xxxx"
bsr measure_strarray ;d1=width of widest gadget text
moveq #4,d0 ;Add "xxxx" width to widest
jsr calc_xlength
add.w d1,d0
move.w d0,XG_Width(a1)
movem.l (a7)+,d0-1/a0-1
rts
SECTION calchslider,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcHSlider
;
; Imported variables/functions
;
XREF init_xgad
XREF _PixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; a0=text for gadget
; Exit: HSlider gadget calculated
_CalcHSlider:
movem.l d0-1/a0-1,-(a7)
jsr init_xgad ;Init x,y,height
;Width = PixLength (Text)
moveq #0,d1
bsr _PixLength
move.w d0,XG_Width(a1)
movem.l (a7)+,d0-1/a0-1
rts
SECTION calclabel,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcLabel
;
; Imported variables/functions
;
XREF init_xgad
XREF _LabelPixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; a0=text for gadget
; Exit: Label gadget calculated
_CalcLabel:
movem.l d0-1/a0-1,-(a7)
jsr init_xgad ;Init x,y,height
move.l a0,XG_Label(a1)
moveq #0,d1 ;Width=LabelPixLength(Label)
bsr _LabelPixLength
move.w d0,XG_Width(a1)
movem.l (a7)+,d0-1/a0-1
rts
SECTION measurestr,CODE
INCDIR INCLUDE:
INCLUDE exec/lists.i
INCLUDE libraries/gadtools.i
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcList
;
; Imported variables/functions
;
XREF init_xgad
XREF calc_xlength
XREF _PixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; d1=number of visible lines
; a0=pointer to list of items
; Exit: List gadget calculated
_CalcList:
movem.l d0-1/a0-2,-(a7)
jsr init_xgad ;Init x,y,height
clr.l XG_Label(a1)
;Set height = (FontY + 4 + INTERHEIGHT) * Lines - INTERHEIGHT;
move.w XG_Height(a1),d0 ;d0=FontY
add.w #4+INTERHEIGHT,d0 ;d0=FontY + 4 + INTERHEIGHT
mulu d1,d0
sub.w #INTERHEIGHT,d0
move.w d0,XG_Height(a1)
;Get width of widest item string
moveq #0,d1 ;d1=width
move.l LH_HEAD(a0),d0 ;d0=first node in item list
beq.s .cl_gotwidth ;Handle empty list
.cl_widthloop:
move.l d0,a2
move.l LN_NAME(a2),a0 ;Get width of current string
bsr _PixLength
move.l d0,d1 ;d1=MAX(width, widestsofar)
move.l LN_SUCC(a2),d0 ;d0=next node
bne.s .cl_widthloop
.cl_gotwidth:
moveq #4,d0 ;Add "xxxx" width to widest
jsr calc_xlength
add.w d1,d0
move.w d0,XG_Width(a1)
movem.l (a7)+,d0-1/a0-2
rts
SECTION measurestr,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcNumber
;
; Imported variables/functions
;
XREF init_xgad
XREF calc_xlength
XREF _PixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; d1=value for number gadget
; Exit: Number gadget calculated
_CalcNumber:
movem.l d0-1/a0-1,-(a7)
sub.l #20,a7
jsr init_xgad ;Init x,y,height
;Build a string of "8"'s as long as the number of
;digits in the number in d1.
move.l a7,a0
tst.l d1 ;<= 0 ?
bpl.s .cn_loop ;Skip if >0
move.b #"-",(a0)+ ;Insert "-" to string
neg.l d1
.cn_loop: move.b #"8",(a0)+
divu #10,d1
ext.l d1
tst.l d1 ;Any digits left?
bne.s .cn_loop ;Loop back if yes
clr.b (a0)
moveq #0,d1 ;Width=PixLength(number)
move.l a7,a0
bsr _PixLength
move.w d0,XG_Width(a1)
add.l #20,a7
movem.l (a7)+,d0-1/a0-1
rts
SECTION calctext,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcText
XDEF _CalcString
;
; Imported variables/functions
;
XREF init_xgad
XREF calc_xlength
XREF _PixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; a0=text for gadget
; Exit: Text gadget calculated
_CalcText:
_CalcString:
movem.l d0-1/a0-1,-(a7)
jsr init_xgad ;Init x,y,height
;Width = PixLength (Text) + PixLength ("xx")
moveq #0,d1
bsr _PixLength
move.w d0,XG_Width(a1)
moveq #2,d0
jsr calc_xlength
add.w d0,XG_Width(a1)
movem.l (a7)+,d0-1/a0-1
rts
SECTION measurestr,CODE
INCDIR INCLUDE:
INCLUDE exec/lists.i
INCLUDE libraries/gadtools.i
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF _CalcVRadio
;
; Imported variables/functions
;
XREF init_xgad
XREF calc_xlength
XREF measure_strarray
XREF _PixLength
;--------------------------------------------------------------
; Entry: d0=gadget index
; a0=pointer to array of gadget text pointers
; Exit: VRadio gadget calculated
_CalcVRadio:
movem.l d0-2/a0-2,-(a7)
jsr init_xgad ;Init x,y,height
clr.l XG_Label(a1)
jsr measure_strarray ;d1=width of widest gadget text
move.l d0,d2 ;d2=number of strings
moveq #3,d0 ;Add "xxx" width of widest
jsr calc_xlength
add.l d1,d0
move.w d0,XG_Width(a1)
;Set height = (FontY + 4 + INTERHEIGHT) * numstrings - INTERHEIGHT;
move.w XG_Height(a1),d0 ;d0=FontY
add.w #4+INTERHEIGHT,d0 ;d0=FontY + 4 + INTERHEIGHT
mulu d2,d0
sub.w #INTERHEIGHT,d0
move.w d0,XG_Height(a1)
movem.l (a7)+,d0-2/a0-2
rts
SECTION calcxlength,CODE
INCLUDE "asmgle.i"
;
; Exported functions
;
XDEF calc_xlength
;
; Imported variables/functions
;
XREF.l _PixLength
;--------------------------------------------------------------
; Get the width of a number of "x" characters
; Entry: d0=number of "x"s to measure (0-7)
; Exit: d0.w=width of x's
calc_xlength:
movem.l d1/a0-1,-(a7)
move.l d0,d1 ;d1=scratch x count
lea .cx_cache(pc,d0.w),a1 ;d0=value from cache
move.b (a1),d0
bpl.s .cx_done ;Exit if already calc'd
subq.l #8,a7 ;Create "x" string on stack
subq.l #1,d1
move.l a7,a0
.cx_initstr:
move.b #"x",(a0)+
dbf d1,.cx_initstr
clr.b (a0)
move.l a7,a0 ;Get length of x string
moveq #0,d1
jsr _PixLength
move.b d0,(a1) ;Store length in cache
addq.l #8,a7
.cx_done: movem.l (a7)+,d1/a0-1
ext.w d0
rts
.cx_cache:
dc.b 0 ;Width of 0 x's (always 0!)
dc.b -1 ;Width of 1 x
dc.b -1 ; " " 2 x
dc.b -1 ; " " 3 x
dc.b -1 ; " " 4 x
dc.b -1 ; " " 5 x
dc.b -1 ; " " 6 x
dc.b -1 ; " " 7 x
EVEN
/*
* gle.c main file
*/
#define INTUI_V36_NAMES_ONLY
#include <clib/alib_protos.h>
#include <clib/asl_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/icon_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/wb_protos.h>
#include <pragmas/asl_pragmas.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/gadtools_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/icon_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/wb_pragmas.h>
#include <dos.h>
#include <exec/lists.h>
#include <exec/memory.h>
#include <exec/nodes.h>
#include <exec/types.h>
#include <intuition/gadgetclass.h>
#include <stdio.h>
#include <string.h>
#include "gle.h"
static char Version[] = "$VER: Gadtools Layout Library v1.01 (" __DATE__ " " __TIME__ ")";
/***** GLOBAL VARIABLES *****/
struct EXT_GADGET AllGads [GAD_MAXIMUM] = {NULL};
struct NewGadget NGad = {0};
struct PANEL Panel = {0};
struct Screen *StdScreen = NULL;
APTR VisualInfo = NULL;
BYTE LBWidth=0;
BYTE RBWidth=0;
BYTE TBWidth=0;
BYTE BBWidth=0;
WORD FontY=0;
// For the window layout engine
struct EXT_GADGET ExtGadStack [20] = {NULL};
LONG ExtGadPtr = 0;
UBYTE CurOrientation = 0;
LONG MaxWidth = 0;
/***** EXTERNAL VARIABLES *****/
extern struct Library *IntuitionBase;
extern struct Library *GadToolsBase;
extern struct Library *GfxBase;
/* This function frees all screen-related system structures.
*/
void WindowDestructor (void)
{
/* Close our window and free the gadgets
*/
CloseControlPanel();
if (Panel.GList)
{
FreeGadgets (Panel.GList);
Panel.GList = NULL;
}
if (VisualInfo)
{
FreeVisualInfo (VisualInfo);
VisualInfo = NULL;
}
if (StdScreen)
{