Initial commit

This commit is contained in:
Gwen Gourevich
2021-10-27 10:34:18 +02:00
parent 43ad18eb04
commit c5f4f6ba25
199 changed files with 73169 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
.386P
.model SMALL, SYSCALL
;----------------------------------------------------------------------------
.data
;----------------------------------------------------------------------------
public NoLanguage MySortCompFunc
strcmp proto SYSCALL
.code
;//-------------------------------------------------------------------------
MySortCompFunc proc uses ebx ecx edx esi edi ebp,\
ptra:DWORD, ptrb:DWORD
mov eax, ptrb
mov ecx, ptra
push [eax]
push [ecx]
call strcmp
add esp, 8
ret
MySortCompFunc endp
;----------------------------------------------------------------------------
; The
End

13
LIB386/LIB_MENU/BUILD.BAT Normal file
View File

@@ -0,0 +1,13 @@
call watcom10
pkunzip -o obj >NUL
wmake
pkzip -m obj *.obj >NUL
call watcom9
pkunzip -o obj9 >NUL
wmake WATCOM9=yes
pkzip -m obj9 *.obj >NUL
call watcom10

157
LIB386/LIB_MENU/LIB_MENU.H Normal file
View File

@@ -0,0 +1,157 @@
#ifdef WATCOM9
#pragma library ("f:\projet\lib386\lib_menu\lb9_menu.lib");
#else
#pragma library ("f:\projet\lib386\lib_menu\lib_menu.lib");
#endif
#define SELECT_NO_FLAG 0
#define SELECT_SHOW_EXT 1
#define SELECT_TEST_EXIST 2
#define SELECT_TEST_OVERWRITE 4
#define SELECT_KEEP_POS 8
#define NO_FLAG 0
#define FLAG_PUSHED 0x0001
#define FLAG_RED 0x0002
#define FLAG_NO_PUSH 0x0004
#define FLAG_CENTRE 0x0100
#define FLAG_CONTOUR 0x0200
#define FLAG_FILENAME 0x0400
#define TYPE_TEXT 0x0001
#define TYPE_BUTTON 0x0002
#define TYPE_WINDOW 0x0004
#define TYPE_SWITCH 0x0008
#define TYPE_CHANGE_VALUE 0x0010
#define TYPE_DEC_VALUE 0x0020
#define TYPE_INC_VALUE 0x0040
extern UBYTE SelectorPathname[] ;
typedef struct { WORD X1 ; /* size/pos pixel box */
WORD Y1 ;
WORD X2 ;
WORD Y2 ;
WORD Type ;
WORD Flags ; /* texte centr... */
WORD Handle ; /* info retourne si != -1 */
UBYTE *PtrString ;
WORD *PtrVar ; /* info switch */
WORD Mask ;
} T_CLICK_BOX ;
typedef struct { WORD NbBox ;
WORD LastClicked ;
T_CLICK_BOX *PtrMallocList ;
WORD Largeur ; /* en caractere */
WORD Hauteur ;
WORD X1 ;
WORD Y1 ;
WORD X2 ;
WORD Y2 ;
WORD Flags ;
WORD Repeat ;
} T_MENU ;
typedef struct { WORD WindowX1 ;
WORD WindowY1 ;
WORD WindowX2 ;
WORD WindowY2 ;
WORD WindowLig ;
WORD WindowCol ;
WORD WindowTab ;
WORD WindowNbIndex ;
UBYTE **WindowArray ;
} T_WINLIST ;
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
#define B_GRIS 1
#define B_ROUGE 4
#define BLEU 9
#define VERT 10
#define CYAN 11
#define ROUGE 12
#define MAGENTA 13
#define JAUNE 14
#define BLANC 15
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/* asm_sort.asm */
extern int MySortCompFunc( char**, char** ) ;
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/* menu.c */
extern void SetMenuAutoPal(short );
extern void InitPalMenu(void);
extern void CopyPalMenu(unsigned char *);
extern void DrawWindow(long ,long ,long ,long ,long );
extern void OpenWindow(T_WINLIST *,short ,short ,short ,short );
extern void GetWindowButton(T_MENU *,short ,T_WINLIST *);
extern void WinText(T_WINLIST *,unsigned char *,long );
extern void WinList(T_WINLIST *,unsigned char **,short ,short );
extern void WinSelect(T_WINLIST *,short ,short );
extern void WinSepar(T_WINLIST *);
extern void FlipWindow(T_WINLIST *);
extern short GetIndexWinList(T_WINLIST *);
extern void DrawBox(T_MENU *,short ,short ,short );
extern T_CLICK_BOX *AddHeaderButton(T_MENU *,short ,short ,short ,short );
extern void GetCoorButton(T_MENU *,short ,long *,long *,long *,long *);
extern void AddButton(T_MENU *,short ,short ,short ,short ,short ,short ,unsigned char *);
extern void AddChangeValue(T_MENU *,short ,short ,short ,short ,short ,short ,unsigned char *,short *,short ,short ,short );
extern void AddSwitch(T_MENU *,short ,short ,short ,short ,short ,short ,unsigned char *,short *,short );
extern void AddText(T_MENU *,short ,short ,short ,short ,short ,unsigned char *);
extern void AddWindow(T_MENU *,short ,short ,short ,short ,short ,short );
extern short GetOptimalSize(short );
extern short OpenMenu(T_MENU *,short ,short );
extern void CloseMenu(T_MENU *);
extern short DrawMenu(T_MENU *,short ,short );
extern void ClearMenu(T_MENU *);
extern short ScanListClick(T_MENU *);
extern long GereMenu(T_MENU *);
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
/* menufunc.c */
extern T_CLICK_BOX *GetPtrLcb(T_MENU *,short );
extern void OrButtonFlagIfTrue(T_MENU *,short ,short ,short );
extern void SwitchButton(T_MENU *,short );
extern void ChangeButtonFlags(T_MENU *,short ,short ,short );
extern void ChangeButtonString(T_MENU *,short ,unsigned char *,short );
extern void InputString(T_MENU *,short ,short );
extern void Message(unsigned char *,long );
extern long Confirm(unsigned char *,unsigned char *,unsigned char *);
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
/* selector.c */
extern void CutFileName(unsigned char *);
extern void DrawListFiles(short );
extern void ScanFiles(unsigned char *,long );
extern short ThereIsFiles(unsigned char *);
extern void ScanDirs(unsigned char *);
extern void ScanDrives(void);
extern long NumDrive(unsigned char *);
extern short FileSelector(unsigned char *,unsigned char *,unsigned char *,long );
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/

61
LIB386/LIB_MENU/MAKEFILE Normal file
View File

@@ -0,0 +1,61 @@
# name the compiler
!ifdef %HOME
!ifeq WATCOM9 yes
CC = c:\compil\watcom\bin\wcc386p
WL = c:\compil\watcom\binb\wlib
!else
CC = c:\compil\watcom10\binb\wcc386
WL = c:\compil\watcom10\binb\wlib
!endif
!else
!ifeq WATCOM9 yes
CC = f:\compil\watcom\bin\wcc386p
WL = f:\compil\watcom\binb\wlib
!else
CC = f:\compil\watcom10\binb\wcc386
WL = f:\compil\watcom10\binb\wlib
!endif
!endif
ASM = ml
!ifeq WATCOM9 yes
CFLAGS = /oeaxt /zp2 /4s /zq /s /DWATCOM9
!else
CFLAGS = /oeaxt /zp2 /5s /zq /s
!endif
LFLAGS = /c /q /b /n
#AFLAGS = /m2 /mx /z /zi /t /jMASM51 /jQUIRKS
AFLAGS = /Cx /Zm /c /W0 /Sa /DNoLanguage=SYSCALL /Djumps=;
OBJETS1 = menu.obj selector.obj menufunc.obj
OBJETS2 = asm_sort.obj
OBJETS3 =
OBJETS4 =
!ifeq WATCOM9 yes
LIB = LB9_MENU
!else
LIB = LIB_MENU
!endif
$(LIB).LIB: $(OBJETS1) $(OBJETS2) $(OBJETS3) $(OBJETS4)
@echo $(OBJETS1) > clibmak.rsp
@echo $(OBJETS2) >> clibmak.rsp
# @echo $(OBJETS3) >> clibmak.rsp
# @echo $(OBJETS4) >> clibmak.rsp
@$(WL) $(LIBFLAGS) $(LIB) @clibmak.rsp
@del clibmak.rsp
@prntitre M "$(LIB) OK"
.asm.obj:
@PRNTITRE M "$*.ASM"
@$(ASM) $(AFLAGS) $*.ASM
.c.obj:
@PRNTITRE M "$*.C"
@$(CC) $(CFLAGS) $*

1056
LIB386/LIB_MENU/MENU.C Normal file

File diff suppressed because it is too large Load Diff

489
LIB386/LIB_MENU/MENUFUNC.C Normal file
View File

@@ -0,0 +1,489 @@
#include "\projet\lib386\lib_sys\adeline.h"
#include "\projet\lib386\lib_sys\lib_sys.h"
#include "\projet\lib386\lib_svga\lib_svga.h"
#include "lib_menu.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <dos.h>
#ifndef WATCOM9
#include <mem.h>
#endif
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
T_CLICK_BOX *GetPtrLcb( T_MENU *ptrmenu, WORD handle )
{
WORD n, nblcb ;
T_CLICK_BOX *ptrlcb ;
nblcb = ptrmenu->NbBox ;
ptrlcb = ptrmenu->PtrMallocList ;
for( n=0; n<nblcb; n++ )
{
if( ptrlcb->Handle == handle )
{
return ptrlcb ;
}
ptrlcb++ ;
}
return 0L ;
}
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
void OrButtonFlagIfTrue( T_MENU *ptrmenu, WORD handle, WORD flags, WORD test )
{
WORD n, nblcb ;
T_CLICK_BOX *ptrlcb ;
if( test != 0 )
{
nblcb = ptrmenu->NbBox ;
ptrlcb = ptrmenu->PtrMallocList ;
for( n=0; n<nblcb; n++ )
{
if( ptrlcb->Handle == handle )
{
ptrlcb->Flags |= flags ;
return ;
}
ptrlcb++ ;
}
}
}
void SwitchButton( T_MENU *ptrmenu, WORD handle )
{
WORD n, nblcb ;
T_CLICK_BOX *ptrlcb ;
nblcb = ptrmenu->NbBox ;
ptrlcb = ptrmenu->PtrMallocList ;
for( n=0; n<nblcb; n++ )
{
if( ptrlcb->Handle == handle )
{
ptrlcb->Flags ^= FLAG_PUSHED ;
/* if( flagaff )
{
DrawBox( ptrmenu, n, NO_FLAG, TRUE ) ;
}
*/
return ;
}
ptrlcb++ ;
}
}
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
void ChangeButtonFlags( T_MENU *ptrmenu, WORD handle, WORD flags, WORD flagaff )
{
WORD n, nblcb ;
T_CLICK_BOX *ptrlcb ;
nblcb = ptrmenu->NbBox ;
ptrlcb = ptrmenu->PtrMallocList ;
for( n=0; n<nblcb; n++ )
{
if( ptrlcb->Handle == handle )
{
ptrlcb->Flags = flags ;
if( flagaff )
{
DrawBox( ptrmenu, n, NO_FLAG, TRUE ) ;
}
return ;
}
ptrlcb++ ;
}
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
/*
WORD GetButtonFlags( T_MENU *ptrmenu, WORD handle )
{
WORD n, nblcb ;
T_CLICK_BOX *ptrlcb ;
nblcb = ptrmenu->NbBox ;
ptrlcb = ptrmenu->PtrMallocList ;
for( n=0; n<nblcb; n++ )
{
if( ptrlcb->Handle == handle )
{
return ptrlcb->Flags ;
}
ptrlcb++ ;
}
return 0 ;
}
*/
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
void ChangeButtonString( T_MENU *ptrmenu, WORD handle, UBYTE *string, WORD flagaff )
{
WORD n, nblcb ;
T_CLICK_BOX *ptrlcb ;
nblcb = ptrmenu->NbBox ;
ptrlcb = ptrmenu->PtrMallocList ;
for( n=0; n<nblcb; n++ )
{
if( ptrlcb->Handle == handle )
{
ptrlcb->PtrString = string ;
if( flagaff )
{
DrawBox( ptrmenu, n, NO_FLAG, TRUE ) ;
}
return ;
}
ptrlcb++ ;
}
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
/*
UBYTE* GetButtonString( T_MENU *ptrmenu, WORD handle )
{
WORD n, nblcb ;
T_CLICK_BOX *ptrlcb ;
nblcb = ptrmenu->NbBox ;
ptrlcb = ptrmenu->PtrMallocList ;
for( n=0; n<nblcb; n++ )
{
if( ptrlcb->Handle == handle )
{
return ptrlcb->PtrString ;
}
ptrlcb++ ;
}
return 0L ;
}
*/
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
void InputString( T_MENU *ptrmenu, WORD handle, WORD maxcar )
{
WORD n, nblcb, numlcb ;
WORD coul,x,y ;
LONG x1,y1,x2,y2 ;
WORD start,pc ;
WORD exit ;
WORD len ;
WORD nbaffcar ;
WORD carsizex ;
WORD myclick, mykey ;
WORD memoasciimode ;
UBYTE car ;
UBYTE string[256] ;
T_CLICK_BOX *ptrlcb ;
nblcb = ptrmenu->NbBox ;
ptrlcb = ptrmenu->PtrMallocList ;
for( n=0; n<nblcb; n++ )
{
if( ptrlcb->Handle == handle ) break ;
ptrlcb++ ;
}
if( n==nblcb ) return ;
numlcb = n ;
strcpy( string, ptrlcb->PtrString ) ;
pc = -1 ; /* pos curseur (-1 no cursor) */
start = 0 ;
x1 = ptrlcb->X1+3 ;
y1 = ptrlcb->Y1+3 ;
x2 = ptrlcb->X2-3 ;
y2 = ptrlcb->Y2-3 ;
nbaffcar = (carsizex=((x2 - x1)+1)/SizeCar) * (((y2-y1)+1)/SizeCar) ;
if( ptrlcb->Flags & FLAG_RED ) coul = B_ROUGE+1 ;
else coul = B_GRIS+1 ;
memoasciimode = AsciiMode ;
AsciiMode = TRUE ;
CoulText( BLANC,-1 ) ;
ShowMouse( 0 ) ;
while( Click ) ;
exit = FALSE ;
while( !exit )
{
/* affichage */
/* DrawInputString( string, nbffcar, start, pc, */
len = strlen( string ) ;
if( pc-start >= nbaffcar ) start = pc - nbaffcar + 1 ;
if( pc < start ) start = pc ;
Vsync() ;
if( pc == -1 )
{
x = x1+(len*SizeCar) ;
if( x>x2 ) x = x2 ;
Box( x1,y1,x,y2, 9 ) ;
}
else
{
Box( x1,y1,x2,y2, coul ) ;
}
x = x1 ;
y = y1 ;
for( n=0; n<=len; n++ )
{
if( n < start ) continue ;
if( n == pc )
{
Box(x,y,x+SizeCar-2,y+SizeCar-1,BLANC ) ;
x += SizeCar ;
if( x > x2-SizeCar-1 )
{
if( y > y2-SizeCar-1 )
{
break ;
}
else
{
y += SizeCar ;
x = x1 ;
}
}
}
Text( x,y, "%c", string[n] ) ;
x += SizeCar ;
if( x > x2-SizeCar-1 )
{
y += SizeCar ;
if( y > y2-SizeCar-1 )
{
break ;
}
else
{
x = x1 ;
}
}
}
CopyBlockPhys( ptrlcb->X1, ptrlcb->Y1, ptrlcb->X2, ptrlcb->Y2 ) ;
/* input */
while( !(mykey=GetAscii()) AND (!(myclick=Click)) ) ;
if( myclick )
{
exit = TRUE ;
break ;
}
car = mykey & 255 ;
if( (car >= 32) AND (car < 255) )
{
if( pc == -1 )
{
pc = 1 ;
string[0] = car ;
string[1] = 0 ;
}
else
{
if( len < maxcar )
{ /* insert */
memmove( &string[pc+1],&string[pc],strlen(&string[pc])+1 ) ;
string[pc] = car ;
pc++ ;
if( pc > len ) string[pc] = 0 ;
}
}
}
else
{
switch( mykey )
{
case A_ESC:
exit = TRUE ;
break ;
case A_RETURN:
exit = TRUE ;
break ;
case A_END:
pc = len ;
break ;
case A_HOME:
pc = 0 ;
break ;
case A_BACKSPACE:
if( pc == -1 ) pc = len ;
if( pc > 0 )
{
pc-- ;
memmove( &string[pc],&string[pc+1],strlen(&string[pc+1])+1 ) ;
}
break ;
case A_SUPPR:
if( pc == -1 ) pc = len ;
if( pc < len )
{
memmove( &string[pc],&string[pc+1],strlen(&string[pc+1])+1 ) ;
}
break ;
case A_LEFT:
if( pc == -1 ) pc = len-1 ;
else
if( pc > 0 ) pc-- ;
break ;
case A_RIGHT:
if( pc == -1 ) pc = 1 ;
else
if( pc < len ) pc++ ;
break ;
case A_DOWN:
if( pc == -1 )
{
if( carsizex < len )
pc = carsizex ;
else
pc = 0 ;
}
else
if( pc+carsizex < len )
pc += carsizex ;
break ;
case A_UP:
if( pc == -1 ) pc = 0 ;
else
if( pc-carsizex >= 0 )
pc -= carsizex ;
break ;
}
}
}
if( (mykey==A_RETURN) OR (myclick) )
{
strcpy( ptrlcb->PtrString, string ) ;
}
DrawBox( ptrmenu, numlcb, NO_FLAG, TRUE ) ;
AsciiMode = memoasciimode ;
ShowMouse( 1 ) ;
while( Key OR Click OR Fire ) AffMouse() ;
}
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/* fontions evolues */
void Message( UBYTE *message, LONG flag )
{
T_MENU menu ;
WORD len ;
len = strlen(message)*SizeCar / (SizeCar+7) + 2 ;
if( !OpenMenu( &menu, len,2 ) ) return ;
AddText( &menu, 0,0, len,2, FLAG_CENTRE+FLAG_CONTOUR, message ) ;
DrawMenu( &menu, -1, -1 ) ;
if( flag )
{
ShowMouse( 1 ) ;
while( Click OR Fire OR Key ) ;
while( !Click AND !Fire AND !Key ) AffMouse() ;
while( Click OR Fire OR Key) ;
}
CloseMenu( &menu ) ;
}
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/* Confirm( "Voulez-vous vraiment ?", "OUI" (RETURN), "NON"(ESC) ) ; */
LONG Confirm( UBYTE *message, UBYTE *oui, UBYTE *non )
{
T_MENU menu ;
WORD len, select ;
len = strlen(message)*SizeCar / (SizeCar+7) + 2 ;
if( !OpenMenu( &menu, len,3 ) ) return 2 ;
AddText( &menu, 0,0, len,2, FLAG_CENTRE+FLAG_CONTOUR, message ) ;
AddButton( &menu, 1, 0,2, len/2,1, FLAG_CENTRE+FLAG_RED, oui ) ;
AddButton( &menu, 2, len/2,2, len/2,1, FLAG_CENTRE, non ) ;
DrawMenu( &menu, -1, -1 ) ;
ShowMouse( 1 ) ;
while( Click OR Fire OR Key ) AffMouse() ;
select = 0 ;
while( select < 1 )
{
AffMouse() ;
select = GereMenu( &menu ) ;
if( Fire & F_RETURN )
{
select = 1 ;
DrawBox( &menu, 1, FLAG_PUSHED, TRUE ) ;
}
if( Key == K_ESC )
{
select = 2 ;
DrawBox( &menu, 2, FLAG_PUSHED, TRUE ) ;
}
}
while( Click OR Fire OR Key ) AffMouse() ;
CloseMenu( &menu ) ;
return select ;
}
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/

554
LIB386/LIB_MENU/SELECTOR.C Normal file
View File

@@ -0,0 +1,554 @@
#include "\projet\lib386\lib_sys\adeline.h"
#include "\projet\lib386\lib_sys\lib_sys.h"
#include "\projet\lib386\lib_svga\lib_svga.h"
#include "\projet\lib386\lib_menu\lib_menu.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys\types.h>
#include <direct.h>
#include <string.h>
#include <dos.h>
#ifndef WATCOM9
#include <mem.h>
#endif
#define MAX_FILES 500
#define MAX_DIRS 100
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*
Ûßßßß Û Û Ûßßßß ÛÛßßß Ûßßßß Û Ûßßßß Ûßßßß ßßÛßß ÛßßßÛ ÛßßßÛ
ÛÛßß ÛÛ ÛÛ ÛÛßß ßßßßÛ ÛÛßß ÛÛ ÛÛßß ÛÛ ÛÛ ÛÛ Û ÛÛßÛß
ßß ßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßßßßß ßß ßßßßß ßß ß
*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
UBYTE SelectorPathname [_MAX_PATH] ;
UBYTE SDrive[_MAX_DRIVE] ;
UBYTE SDir[_MAX_DIR] ;
UBYTE SName[_MAX_FNAME] ;
UBYTE SExt[_MAX_EXT] ;
WORD NbFiles ;
UBYTE *ListFiles ;
UBYTE **IndexFiles ;
WORD NbDirs ;
UBYTE *ListDirs ;
UBYTE **IndexDirs ;
WORD StartFile = 0 ;
UBYTE SearchPathname[_MAX_PATH] ;
T_MENU Selector ;
T_WINLIST FilesWindow ;
T_WINLIST DirsWindow ;
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void CutFileName( UBYTE *filename )
{
while( (*filename!=0) AND (*filename!='.') )
filename++ ;
*filename = 0 ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void DrawListFiles( WORD flag )
{
WORD nb ;
ShowMouse( 0 ) ;
GetWindowButton( &Selector, 10, &FilesWindow ) ;
if( NbFiles )
{
if( StartFile >= NbFiles ) StartFile = NbFiles-1 ;
nb = NbFiles - StartFile ;
if( flag & SELECT_SHOW_EXT )
WinList( &FilesWindow, IndexFiles+StartFile, nb, 14 ) ;
else
WinList( &FilesWindow, IndexFiles+StartFile, nb, 9 ) ;
}
else
{
WinList( &FilesWindow, IndexFiles, 0, 14 ) ;
}
FlipWindow( &FilesWindow ) ;
ShowMouse( 1 ) ;
}
/*
int my_sort_function( char **a, char **b)
{
return( strcmp( *a, *b) ) ;
}
*/
void ScanFiles( UBYTE *selection, LONG flag )
{
struct find_t fileinfo ;
ULONG rc ;
UBYTE *ptr ;
UBYTE path[_MAX_PATH] ;
_splitpath( selection, SDrive, SDir, SName, SExt ) ;
_makepath( path, "", SearchPathname, SName, SExt ) ;
rc = _dos_findfirst( path, _A_NORMAL, &fileinfo ) ;
NbFiles = 0 ;
ptr = ListFiles ;
while( !rc )
{
IndexFiles[NbFiles] = ptr ;
if( !(flag & SELECT_SHOW_EXT) ) CutFileName( fileinfo.name ) ;
strcpy( ptr, fileinfo.name ) ;
ptr += strlen( fileinfo.name ) + 1 ;
NbFiles++ ;
if( NbFiles == MAX_FILES )
{
Message( "Warning: Truncated List", TRUE ) ;
break ;
}
rc = _dos_findnext( &fileinfo ) ;
}
if( NbFiles ) /* ? */
qsort( (void *)IndexFiles, NbFiles, sizeof( char * ), MySortCompFunc );
DrawListFiles( flag ) ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
WORD ThereIsFiles( UBYTE *path )
{
struct find_t fileinfo ;
if( !_dos_findfirst( path, _A_NORMAL, &fileinfo ) )
return 1 ;
else
return 0 ;
}
void ScanDirs( UBYTE *selection )
{
struct find_t fileinfo ;
ULONG rc ;
UBYTE *ptr ;
WORD n ;
UBYTE path[_MAX_PATH] ;
rc = _dos_findfirst( "*.*", _A_SUBDIR, &fileinfo ) ;
NbDirs = 0 ;
ptr = ListDirs ;
while( !rc )
{
if( fileinfo.attrib & _A_SUBDIR )
{
IndexDirs[NbDirs] = ptr ;
strcpy( ptr, fileinfo.name ) ;
ptr += strlen( fileinfo.name ) + 1 ;
NbDirs++ ;
if( NbDirs == MAX_FILES )
{
Message( "Warning: Truncated List", TRUE ) ;
break ;
}
}
rc = _dos_findnext( &fileinfo ) ;
}
ShowMouse( 0 ) ;
GetWindowButton( &Selector, 11, &DirsWindow ) ;
WinList( &DirsWindow, IndexDirs, NbDirs, 14 ) ;
FlipWindow( &DirsWindow ) ;
/* if option scan files */
for( n=0; n<NbDirs; n++ )
{
strcpy( path, IndexDirs[n] ) ;
strcat( path, "\\" ) ;
strcat( path, selection ) ;
if( ThereIsFiles( path ) )
{
WinSelect( &DirsWindow, n, B_ROUGE+1 ) ;
}
}
ShowMouse( 1 ) ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
void ScanDrives()
{
unsigned total ;
unsigned drive ;
unsigned orgdrive ;
WORD n ;
UBYTE *ptr ;
_dos_getdrive( &orgdrive ) ;
NbDirs = 0 ;
ptr = ListDirs ;
for( n=1; n<=26; n++ )
{
_dos_setdrive( n, &total ) ;
_dos_getdrive( &drive ) ;
if( drive == n )
{
IndexDirs[NbDirs] = ptr ;
strcpy( ptr, "A:" ) ;
ptr[0] = drive + 'A' -1 ;
ptr += 3 ;
NbDirs++ ;
}
}
_dos_setdrive( orgdrive, &total ) ;
ShowMouse( 0 ) ;
GetWindowButton( &Selector, 11, &DirsWindow ) ;
WinList( &DirsWindow, IndexDirs, NbDirs, 14 ) ;
FlipWindow( &DirsWindow ) ;
ShowMouse( 1 ) ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
LONG NumDrive( UBYTE *drive )
{
return ((*drive)&=~20)-'A'+1 ;
}
/*ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*/
WORD FileSelector( UBYTE *titre,
UBYTE *selection,
UBYTE *defaultname,
LONG flags )
{
WORD n, num ;
WORD flag, handle ;
WORD mode = 0 ;
unsigned total ;
unsigned testdrive = 0 ;
WORD rcode ;
WORD oldnum = -1 ;
char memopath[_MAX_PATH] ;
UBYTE workstring[256] ;
WORD memoasciimode ;
/* inits */
MemoClip() ;
UnSetClip() ;
/* memo drive/dir org */
getcwd( memopath, _MAX_PATH ) ;
/* init directory fichier par defaut */
strcpy( SelectorPathname , defaultname ) ;
_splitpath( SelectorPathname , SDrive, SDir, SName, SExt ) ;
if( strlen( SDir ) > 2 )
{
if( SDir[strlen(SDir)-1] == '\\' ) SDir[strlen(SDir)-1] = 0 ;
}
if( SDrive[0] != 0 )
{
SDrive[0] &= ~0x20 ;
_dos_setdrive( SDrive[0]-'A'+1, &total ) ;
_dos_getdrive( &testdrive ) ;
if( testdrive == SDrive[0]-'A'+1 )
{
chdir( SDir ) ;
}
else
{
Message( "Drive Error", TRUE ) ;
}
}
else chdir( SDir ) ;
strcpy( SelectorPathname, SName ) ;
_splitpath( selection, SDrive, SDir, SName, SExt ) ;
strcat( SelectorPathname, SExt ) ;
getcwd( SearchPathname, _MAX_PATH ) ;
/* window */
if( !OpenMenu( &Selector, 32,20 ) ) return 0 ;
AddText( &Selector, 0, 0, 32, 1, FLAG_CENTRE+FLAG_CONTOUR, titre ) ;
AddText( &Selector, 0, 1, 3, 1, NO_FLAG, "Path" ) ;
AddButton( &Selector, 0, 3, 1, 29, 1, NO_FLAG, SearchPathname ) ;
AddText( &Selector, 0, 2, 3, 1, NO_FLAG, "File" ) ;
AddButton( &Selector, 4, 3, 2, 29, 1, FLAG_RED, SelectorPathname ) ;
AddWindow( &Selector,10, 0, 4, 16,14, NO_FLAG ) ;
AddWindow( &Selector,11, 16, 4, 16,14, NO_FLAG ) ;
AddText( &Selector, 0, 3, 16, 1, FLAG_CENTRE+FLAG_CONTOUR, selection ) ;
AddButton( &Selector, 2, 16, 3, 8, 1, FLAG_CENTRE+FLAG_PUSHED, "Dirs" ) ;
AddButton( &Selector, 3, 24, 3, 8, 1, FLAG_CENTRE, "Drives" ) ;
AddButton( &Selector, 5, 16,18, 16, 2, FLAG_CENTRE+FLAG_CONTOUR, "Cancel" ) ;
AddButton( &Selector, 6, 0,18, 16, 2, FLAG_CENTRE+FLAG_CONTOUR+FLAG_RED, "OK" ) ;
DrawMenu( &Selector, -1,-1 ) ;
ShowMouse( 1 ) ;
IndexFiles = Malloc( MAX_FILES * sizeof(UBYTE*) ) ;
IndexDirs = Malloc( MAX_DIRS * sizeof(UBYTE*) ) ;
ListFiles = Malloc( MAX_FILES * 13 ) ;
ListDirs = Malloc( MAX_DIRS * 13 ) ;
/* test erreur malloc */
if( !IndexFiles OR !ListFiles OR !IndexDirs OR !ListDirs )
{
Message( "File List Malloc Error", TRUE ) ;
return 0 ;
}
if( !(flags & SELECT_KEEP_POS) ) StartFile = 0 ;
ScanFiles( selection, flags ) ;
ScanDirs( selection ) ;
while( Click ) AffMouse() ;
rcode = -1 ;
flag = 1 ;
while( flag != -1 )
{
if( Key == K_ESC ) rcode = 0 ;
if( Fire == F_RETURN ) rcode = 1 ;
AffMouse() ;
handle = GereMenu( &Selector ) ;
switch( handle )
{
case 10: /* files list */
if( Click & 2 )
{
GetMouseDep() ;
while( Click & 2 )
{
GetMouseDep() ;
StartFile -= Mouse_Y_Dep ;
if( StartFile < 0 ) StartFile = 0 ;
DrawListFiles(flags) ;
}
oldnum = -1 ;
}
else
{
num = GetIndexWinList( &FilesWindow ) + StartFile ;
if( oldnum != -1 )
{
if( num == oldnum ) /* double click */
{
rcode = 1 ;
break ;
}
WinSelect( &FilesWindow, oldnum-StartFile, 0 ) ; /* efface */
}
if( num != -1 )
{
WinSelect( &FilesWindow, num-StartFile, 15 ) ;
oldnum = num ;
if( flags & SELECT_SHOW_EXT )
{
strcpy( SelectorPathname, IndexFiles[num] ) ;
}
else
{
strcpy( SelectorPathname, IndexFiles[num] ) ;
_splitpath( selection, SDrive, SDir, SName, SExt ) ;
strcat( SelectorPathname, SExt ) ;
}
ChangeButtonString( &Selector, 4, SelectorPathname , TRUE ) ;
while( Click ) AffMouse() ;
}
}
break ;
case 11: /* dirs/drive list */
num = GetIndexWinList( &DirsWindow ) ;
if( num != -1 )
{
WinSelect( &DirsWindow, num, 15 ) ;
if( !mode ) /* dir */
{
chdir( IndexDirs[num] ) ;
getcwd( SearchPathname, _MAX_PATH ) ;
ChangeButtonString( &Selector, 0, SearchPathname, TRUE ) ;
ScanDirs( selection ) ;
}
else /* drive */
{
n = IndexDirs[num][0] - 'A' + 1 ;
memoasciimode = AsciiMode ;
AsciiMode = TRUE ;
_dos_setdrive( n, &total ) ;
getcwd( SearchPathname, _MAX_PATH ) ;
AsciiMode = memoasciimode ;
ScanDrives() ;
}
getcwd( SearchPathname, _MAX_PATH ) ;
ChangeButtonString( &Selector, 0, SearchPathname, TRUE ) ;
ScanFiles( selection, flags ) ;
oldnum = -1 ;
while( Click ) AffMouse() ;
}
break ;
case 0: /* input new searchpath */
InputString( &Selector, 0, _MAX_PATH ) ;
_splitpath( SearchPathname, SDrive,SDir,SName,SExt ) ;
_dos_setdrive( SDrive[0]-'A'+1, &total ) ;
chdir( SDir ) ;
getcwd( SearchPathname, _MAX_PATH ) ;
ChangeButtonString( &Selector, 0, SearchPathname, TRUE ) ;
ScanFiles( selection, flags ) ;
ScanDirs( selection ) ;
oldnum = -1 ;
break ;
case 2: /* dirs */
ChangeButtonFlags( &Selector, 2, FLAG_CENTRE+FLAG_PUSHED, 1 ) ;
ChangeButtonFlags( &Selector, 3, FLAG_CENTRE, 1 ) ;
ScanDirs( selection ) ;
mode = 0 ;
oldnum = -1 ;
break ;
case 3: /* drives */
ChangeButtonFlags( &Selector, 2, FLAG_CENTRE, 1 ) ;
ChangeButtonFlags( &Selector, 3, FLAG_CENTRE+FLAG_PUSHED, 1 ) ;
ScanDrives() ;
mode = 1 ;
oldnum = -1 ;
break ;
case 4: /* selected */
InputString( &Selector, 4, _MAX_PATH ) ;
_splitpath( SelectorPathname, SDrive, SDir, SName, SExt ) ;
strcpy( SelectorPathname, SName ) ;
_splitpath( selection, SDrive,SDir,SName,SExt ) ;
strcat( SelectorPathname, SExt ) ;
ChangeButtonString( &Selector, 4, SelectorPathname, 1 ) ;
oldnum = -1 ;
break ;
case 6: /* ok */
rcode = 1 ;
break ;
case 5: /* cancel */
rcode = 0 ;
break ;
}
if( rcode == 1 )
{
_splitpath( SelectorPathname, SDrive, SDir, SName, SExt ) ;
strcpy( SelectorPathname, SearchPathname ) ;
strcat( SelectorPathname, "\\" ) ;
strcat( SelectorPathname, SName ) ;
strcat( SelectorPathname, SExt ) ;
if( flags & SELECT_TEST_EXIST )
{
if( FileSize( SelectorPathname ) != 0L )
{
strcpy( defaultname, SelectorPathname ) ;
flag = -1 ; /* OK */
}
else
{
strcpy( workstring, SelectorPathname ) ;
strcat( workstring, " n'existe pas !" ) ;
Message( workstring, TRUE ) ;
}
}
else if( flags & SELECT_TEST_OVERWRITE )
{
if( FileSize( SelectorPathname ) != 0L )
{
strcpy( workstring, SelectorPathname ) ;
strcat( workstring, " existe dj… !" ) ;
if( Confirm(workstring, "Ecrase", "Oups") == 1 )
{ /* ok */
strcpy( defaultname, SelectorPathname ) ;
flag = -1 ;
}
}
else
{
strcpy( defaultname, SelectorPathname ) ;
flag = -1 ; /* OK */
}
}
else
{
strcpy( defaultname, SelectorPathname ) ;
flag = -1 ; /* OK */
}
if( flag != -1 )
{
DrawMenu( &Selector, -1,-1 ) ;
ScanFiles( selection, flags ) ;
if( !mode ) /* dir */
{
ScanDirs( selection ) ;
}
else /* drive */
{
ScanDrives() ;
}
ShowMouse( 1 ) ;
rcode = -1 ;
}
}
if( rcode == 0 )
{
strcpy( SelectorPathname, "" ) ;
flag = -1 ;
}
}
Free( IndexFiles ) ;
Free( ListFiles ) ;
Free( IndexDirs ) ;
Free( ListDirs ) ;
CloseMenu( &Selector ) ;
while( Click OR Key OR Fire ) AffMouse() ;
RestoreClip() ;
/* restore drive/dir org */
_dos_setdrive( memopath[0]-'A'+1, &total ) ;
chdir( memopath ) ;
return rcode ;
}
/*ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ*/