home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
new
/
amigalibdisks
/
d996
/
startup-menu
/
source
/
smprefs
/
main.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-04-05
|
24KB
|
683 lines
(* SMPrefs. Creates a data file which is stored
* in S: which holds the description of gadgets required on the menu.
* Lee Kindness Jan '94 HSP source.
* v1.00
*)
Program SMPrefs(input, output);
Uses Exec, Intuition, utility, gadtools, graphics, DiskFont,
ASL, AmigaDOS, LSKExtras, Amiga, IFFParse, DOS, ReqTools;
(*$I SMEditor.h *)
(*$I Config.PAS *)
(*$I List.PAS *)
(*$I Window.PAS *)
(* ===================================================================== *)
Procedure Close_Window;
Begin
CloseWindow(TheWindow); (* close window and free gadgets and *)
FreeGadgets(gads[G_NI]); (* visualinfo *)
FreeVisualInfo(vi);
End;
(* ===================================================================== *)
Procedure GetTitles;
VAR
buffer: Pointer;
values: argarray;
ret : Long;
tags : array [0..4] of tTagItem;
begin
wl := rtLockWindow(TheWindow);
tags[0].ti_Tag := RT_Window;
tags[0].ti_Data := LONG(TheWindow);
tags[1].ti_Tag := RTGS_TextFmt;
tags[1].ti_Data := LONG(CStrConstPtr('Enter the text to be displayed'+#10+' on the screen titlebar.'));
tags[2].ti_Tag := RTGS_FLAGS;
tags[2].ti_Data := GSREQF_CENTERTEXT;
tags[3].ti_Tag := TAG_END;
buffer := @CD.cd_ScrTit[1];
ret:=rtGetStringA (buffer, 127, 'SMPrefs', NIL, @tags);
values[0]:=LongInt(buffer);
if ret <> 0 then
CD.cd_ScrTit := retrievestr(Pointer(values[0])) + #0;
buffer := @CD.cd_WinTit[1];
tags[1].ti_Data := LONG(CStrConstPtr('Enter the text to be displayed'+#10+' on the window titlebar.'));
ret:=rtGetStringA (buffer, 127, 'SMPrefs', NIL, @tags);
values[0] := LongInt(buffer);
if ret <> 0 then
CD.cd_WinTit := retrievestr(Pointer(values[0])) + #0;
tl := rtUnLockWindow(TheWindow, pointer(wl));
end;
(* ===================================================================== *)
Procedure GetPal;
CONST
MyPens : Array[0..8] of Word = ($FFFF); (* Get default *)
VAR
result : Long;
tags : array [0..10] of tTagItem;
TheScreen : pScreen;
win : pWindow;
ok : boolean;
MyTextFont : pTextFont;
begin
wl := rtLockWindow(TheWindow);
DiskFontBase := Openlibrary('diskfont.library',36);
If DiskFontBase <> NIL Then begin
MyTextFont := OpenDiskFont(@CD.cd_Font);
CloseLibrary(pLibrary(DiskFontBase));
end;
tags[0].ti_Tag := SA_Type;
tags[0].ti_Data := CUSTOMSCREEN;
tags[1].ti_Tag := SA_Title;
tags[1].ti_Data := LONG(CStrConstPtr('Change the palette'));
tags[2].ti_Tag := SA_OverScan;
tags[2].ti_Data := OSCAN_TEXT;
tags[3].ti_Tag := SA_Depth;
tags[3].ti_Data := 2;
tags[4].ti_Tag := SA_Font;
tags[4].ti_Data := LONG(@CD.cd_Font);
tags[5].ti_Tag := SA_DisplayID;
tags[5].ti_Data := CD.cd_ModeID;
tags[6].ti_Tag := SA_Width;
tags[6].ti_Data := STDSCREENWIDTH;
tags[7].ti_Tag := SA_Height;
tags[7].ti_Data := STDSCREENHEIGHT;
tags[8].ti_Tag := SA_Pens;
tags[8].ti_Data := LONG(@MyPens);
tags[9].ti_Tag := SA_Colors;
tags[9].ti_Data := LONG(NIL);
tags[10].ti_Tag := TAG_END;
TheScreen := OpenScreenTagList(NIL, @tags);
IF TheScreen <> NIL then begin
LoadRGB4(@TheScreen^.ViewPort, @CD.cd_Pal[0], 4);
tags[0].ti_Tag := RT_Screen;
tags[0].ti_Data := LONG(TheScreen);
tags[1].ti_Tag := TAG_END;
result := rtPaletteRequestA ('Change palette', NIL, @tags);
if result <> -1 then begin
CD.cd_Pal[0] := GetRGB4(TheScreen^.ViewPort.ColorMap,0);
CD.cd_Pal[1] := GetRGB4(TheScreen^.ViewPort.ColorMap,1);
CD.cd_Pal[2] := GetRGB4(TheScreen^.ViewPort.ColorMap,2);
CD.cd_Pal[3] := GetRGB4(TheScreen^.ViewPort.ColorMap,3);
end;
ok := CloseScreen(TheScreen);
end;
tl := rtUnLockWindow(TheWindow, pointer(wl));
end;
(* ===================================================================== *)
Function GetSCRID : LongInt; (* Use Reqtools to get ModeID *)
VAR
scrnreq: prtScreenModeRequester;
Value : Longint;
ret : longint;
mytag : Array[0..3] of tTagItem;
Begin
wl := rtLockWindow(TheWindow);
scrnreq := Pointer(rtAllocRequestA (RT_SCREENMODEREQ, NIL));
if (scrnreq<>NIL) then begin
scrnreq^.DisplayID := CD.cd_ModeID;
mytag[0].ti_Tag:=RTSC_Flags;
mytag[0].ti_Data:= 0;
mytag[1].ti_Tag:=RT_UnderScore;
mytag[1].ti_Data:=LongInt('_');
mytag[2].ti_Tag := RT_Window;
mytag[2].ti_Data := LONG(TheWindow);
mytag[3].ti_Tag:=TAG_END;
ret:=rtScreenModeRequestA ( scrnreq, 'Pick a screenmode', @mytag);
value :=LongInt(scrnreq^.DisplayID);
end ;
ret:=rtFreeRequest (scrnreq);
GetSCRID := value;
tl := rtUnLockWindow(TheWindow, pointer(wl));
end;
(* ===================================================================== *)
Procedure HandleIDCMP;
Type
strarray = Array[1..3] Of string;
Tag2 = Array[0..8] Of tTagItem;
Const
exitflag : Boolean = False;
small : Boolean = False;
NumStrs : shortint = 3;
Var
dummy, dum, ret : longint; (* the main loop of the program. *)
Tags : tag2; (* monitors IDCMP messages and *)
message : pIntuiMessage; (* responds as appropriate *)
MsgClass : LongInt;
MsgCode : Word;
gadcode : pGadget;
StrInfo : pStringInfo;
tempint : Array[1..4] Of longint;
OKRes : boolean;
i, cnt : Longint;
tmpstr : string;
fr : pFontRequester;
lr, sr, cr : pFileRequester;
cfile : PathStr;
cdir : DirStr;
Procedure TxtInGads(curnode : pMyNode);
begin
Tags[0].ti_Tag := GTST_String;
Tags[0].ti_Data := LONG(@currentnode^.LSK_Name[1]);
Tags[1].ti_Tag := TAG_END;
GT_SetGadgetAttrsA(gads[G_S_TXT], TheWindow, NIL, @Tags);
Tags[0].ti_Tag := GTST_String;
Tags[0].ti_Data := LONG(@currentnode^.LSK_Cmd[1]);
Tags[1].ti_Tag := TAG_END;
GT_SetGadgetAttrsA(gads[G_S_CMD], TheWindow, NIL, @Tags);
Tags[0].ti_Tag := GTST_String;
Tags[0].ti_Data := LONG(@currentnode^.LSK_Key[1]);
Tags[1].ti_Tag := TAG_END;
GT_SetGadgetAttrsA(gads[G_S_KEY], TheWindow, NIL, @Tags);
end;
Begin
Tags[0].ti_Tag := ASL_Hail;
Tags[0].ti_Data := LONG(CstrConstPtrAR(@RememberKey, 'Pick a font'));
Tags[1].ti_Tag := ASL_FontName;
Tags[1].ti_Data := LONG(CD.cd_Font.ta_Name);
Tags[2].ti_Tag := ASL_FontHeight;
Tags[2].ti_Data := long(CD.cd_Font.ta_YSize);
Tags[3].ti_Tag := ASL_MinHeight;
Tags[3].ti_Data := 6;
Tags[4].ti_Tag := ASL_MaxHeight;
Tags[4].ti_Data := 30;
Tags[5].ti_Tag := ASL_FuncFlags;
Tags[5].ti_Data := FONF_STYLES;
Tags[6].ti_Tag := ASL_Window;
Tags[6].ti_Data := long(TheWindow);
Tags[7].ti_Tag := ASL_FontStyles;
Tags[7].ti_Data := long(CD.cd_Font.ta_Style);
Tags[8].ti_Tag := TAG_DONE;
fr := AllocASLRequest(ASL_FontRequest, @Tags[0]);
Tags[0].ti_Tag := ASL_Hail;
Tags[0].ti_Data := LONG(CstrConstPtrAR(@RememberKey, 'Locate the prefs file'));
Tags[1].ti_Tag := ASL_File;
Tags[1].ti_Data := LONG(@PREFSNAME[1]);
Tags[2].ti_Tag := ASL_Dir;
Tags[2].ti_Data := long(@PREFSDIRH[1]);
Tags[3].ti_Tag := ASL_Window;
Tags[3].ti_Data := long(TheWindow);
Tags[4].ti_Tag := ASL_FuncFlags;
Tags[4].ti_Data := 0;
Tags[5].ti_Tag := ASL_Pattern;
Tags[5].ti_Data := LONG(CstrConstPtrAR(@RememberKey, '#?.prefs'));
Tags[6].ti_Tag := TAG_DONE;
lr := AllocASLRequest(ASL_FileRequest, @Tags[0]);
Tags[0].ti_Tag := ASL_Hail;
Tags[0].ti_Data := LONG(CstrConstPtrAR(@RememberKey, 'Pick Command'));
Tags[1].ti_Tag := ASL_Window;
Tags[1].ti_Data := long(TheWindow);
Tags[2].ti_Tag := ASL_FuncFlags;
Tags[2].ti_Data := 0;
Tags[3].ti_Tag := ASL_Pattern;
Tags[3].ti_Data := LONG(CstrConstPtrAR(@RememberKey, '~(#?.info)'));
Tags[4].ti_Tag := ASL_Dir;
Tags[4].ti_Data := long(CstrConstPtrAR(@RememberKey, 'SYS:'));
Tags[5].ti_Tag := TAG_DONE;
cr := AllocASLRequest(ASL_FileRequest, @Tags[0]);
Tags[0].ti_Tag := ASL_Hail;
Tags[0].ti_Data := LONG(CstrConstPtrAR(@RememberKey, 'Save prefs file as'));
Tags[1].ti_Tag := ASL_File;
Tags[1].ti_Data := LONG(@PREFSNAME[1]);
Tags[2].ti_Tag := ASL_Dir;
Tags[2].ti_Data := long(@PREFSDIRH[1]);
Tags[3].ti_Tag := ASL_Window;
Tags[3].ti_Data := long(TheWindow);
Tags[4].ti_Tag := ASL_FuncFlags;
Tags[4].ti_Data := FILF_SAVE;
Tags[5].ti_Tag := ASL_Pattern;
Tags[5].ti_Data := LONG(CstrConstPtrAR(@R