home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / rclesrc.10 / ircle sources / IRCHelp.p < prev    next >
Encoding:
Text File  |  1992-09-05  |  2.8 KB  |  127 lines

  1. {    ircle - Internet Relay Chat client    }
  2. {    File: IRCHelp    }
  3. {    Copyright ⌐ 1992 Olaf Titz (s_titz@iravcl.ira.uka.de)    }
  4.  
  5. {    This program is free software; you can redistribute it and/or modify    }
  6. {    it under the terms of the GNU General Public License as published by    }
  7. {    the Free Software Foundation; either version 2 of the License, or    }
  8. {    (at your option) any later version.    }
  9.  
  10. {    This program is distributed in the hope that it will be useful,    }
  11. {    but WITHOUT ANY WARRANTY; without even the implied warranty of    }
  12. {    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    }
  13. {    GNU General Public License for more details.    }
  14.  
  15. {    You should have received a copy of the GNU General Public License    }
  16. {    along with this program; if not, write to the Free Software    }
  17. {    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.    }
  18.  
  19. unit IRCHelp;
  20. { About and Help functions }
  21.  
  22. interface
  23. uses
  24.     TCPTypes, TCPStuff, TCPConnections, ApplBase, MsgWindows, IRCGlobals;
  25.  
  26. procedure InitIRCHelp;
  27. { Startup }
  28.  
  29. procedure ShowHelp;
  30. { Show HELP Window }
  31.  
  32. implementation
  33.  
  34. var
  35.     dia: DialogPtr;    { About dialog box }
  36.     hel: MWHndl;    { Help window }
  37.  
  38. procedure closehelp (w: WindowPtr);
  39.     begin
  40.         DeleteMWindow(hel);
  41.         hel := nil
  42.     end;
  43.  
  44. procedure GetVersion (var s: string);
  45.     type
  46.         vers = record
  47.                 v, st, l: integer;
  48.             end;
  49.         versPtr = ^vers;
  50.         versHndl = ^versPtr;
  51.     var
  52.         vh: VersHndl;
  53.     begin
  54.         vh := VersHndl(GetResource('vers', 1));
  55.         if vh <> nil then begin
  56.             with vh^^ do begin
  57.                 s := concat(char(v div 256 + 48), '.', chr((v div 16) mod 16 + 48));
  58.                 if (v mod 16) <> 0 then
  59.                     s := concat(s, '.', chr(v mod 16 + 48));
  60.             end;
  61.             case (vh^^.st div 8192) of
  62.                 1: 
  63.                     s := concat(s, ' (development)');
  64.                 2: 
  65.                     s := concat(s, ' (alpha)');
  66.                 3: 
  67.                     s := concat(s, ' (beta)');
  68.                 4: 
  69.                     ;
  70.             end;
  71.             ReleaseResource(Handle(vh));
  72.         end
  73.     end;
  74.  
  75. procedure ShowHelp;
  76.     var
  77.         st: str255;
  78.         h, h0: Handle;
  79.     begin
  80.         if hel = nil then begin
  81. { The Help function consists of just loading the complete text into a window }
  82. { Sorry, no fancy section selector or hyperlinks. }
  83. { These are the things I am too lazy to write }
  84.             st := 'Help';
  85.             hel := NewMWindow(st, @closehelp);
  86.             h := GetResource('TEXT', 128);
  87.             DetachResource(h);
  88.             h0 := hel^^.t^^.hText;
  89.             DisposHandle(h0);
  90.             hel^^.t^^.hText := h;
  91.             TECalText(hel^^.t);
  92.             SetCtlMax(hel^^.vscr, hel^^.t^^.nlines - hel^^.vislines);
  93.         end
  94.         else
  95.             SelectWindow(hel^^.w);
  96.     end;
  97.  
  98.  
  99. function Menu256 (var e: EventRecord): boolean;
  100.     var
  101.         i: integer;
  102.     begin
  103.         if e.message = 1 then begin
  104.             ParamText(CL_VERSION, '', '', '');
  105.             SetDAFont(courier);
  106.             i := Alert(A_INFO, nil);
  107.             SetDAFont(0);
  108.             if i = 2 then begin
  109.                 ShowHelp;
  110.                 Menu256 := true
  111.             end
  112.             else
  113.                 Menu256 := false;
  114.         end;
  115.     end;
  116.  
  117. procedure InitIRCHelp;
  118.     var
  119.         i: integer;
  120.     begin
  121.         i := ApplTask(@Menu256, menuMsg + 256);
  122.         dia := nil;
  123.         hel := nil;
  124.         GetVersion(CL_VERSION)
  125.     end;
  126.  
  127. end.