home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / DELPHI / HTMLVIEW.ZIP / INSTALL.ZIP / HTMLVIEW.INT < prev    next >
Encoding:
Text File  |  1996-02-02  |  7.2 KB  |  182 lines

  1. {$A+,B-,F-,G+,I+,P+,Q-,R-,S-,T-,V+,W-,X+}
  2.  
  3. {*********************************************************}
  4. {*                     HTMLVIEW.PAS                      *}
  5. {*                Copyright (c) 1995-6 by                *}
  6. {*                   L. David Baldwin                    *}
  7. {*                 All rights reserved.                  *}
  8. {*********************************************************}
  9.  
  10. unit Htmlview;
  11.  
  12. interface
  13.  
  14. uses
  15.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  16.   Forms, Dialogs, ExtCtrls, ReadHTML, HTMLUn1, HTMLSubs, Printers;
  17.  
  18. type
  19.   THotSpotEvent = procedure(Sender: TObject; const SRC: string) of Object;
  20.   THotSpotClickEvent = procedure(Sender: TObject; const SRC: string;
  21.                      var Handled: boolean) of Object;
  22.   TProcessingEvent = procedure(Sender: TObject; ProcessingOn: boolean) of Object;
  23.  
  24.   TThumbScrollBox = class(TScrollBox)
  25.   private
  26.     FCanvas: TCanvas;
  27.     procedure WMVScroll(var Message: TWMVScroll); message WM_VScroll;
  28.   public
  29.     constructor Create(AOwner: TComponent); override;
  30.     destructor Destroy; override;
  31.     end;
  32.  
  33. type
  34.   TPaintPanel = class(TCustomPanel)
  35.   private
  36.     FOnPaint: TNotifyEvent;
  37.     FViewer: TComponent;
  38.     procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_EraseBkgnd;
  39.     procedure Paint; override;
  40.     constructor Create(AOwner: TComponent; Viewer: TComponent);
  41.     property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
  42.   end;
  43.  
  44.   THTMLViewer = class(TWinControl)
  45.   private
  46.     { Private declarations }
  47.     DontDraw: boolean;
  48.     FTitle: PString;
  49.     FURL: PString;
  50.     FBase: PString;
  51.     FCurrentFile: PString;
  52.     FNameList: TStringList;
  53.     FOnHotSpotCovered: THotSpotEvent;
  54.     FOnHotSpotClick: THotSpotClickEvent;
  55.     FOnBitmapRequest: TGetBitmapEvent;
  56.     FOnFormSubmit: TFormSubmitEvent;
  57.     FOnHistoryChange: TNotifyEvent;
  58.     FOnProcessing: TProcessingEvent; 
  59.     FHistory: TStrings;
  60.     FHistoryIndex: integer;
  61.     FHistoryMaxCount: integer;
  62.     FFontName: PString;
  63.     FPreFontName: PString;
  64.     FFontColor: TColor;
  65.     FHotSpotColor: TColor;
  66.     FBackGround: TColor;
  67.     FFontSize: integer;
  68.     FProcessing: boolean;
  69.     FSectionList: TSectionList;
  70.     procedure ScrollResize(Sender: TObject);
  71.     procedure SetViewImages(Value: boolean);
  72.     function GetViewImages: boolean;
  73.     procedure SetColor(Value: TColor);
  74.     function GetBase: string;
  75.     function GetFURL: string;
  76.     function GetTitle: string;
  77.     function GetCurrentFile: string;
  78.     procedure SetBorderStyle(Value: TBorderStyle);
  79.     function GetBorderStyle: TBorderStyle;
  80.     function GetPosition: LongInt;
  81.     procedure SetPosition(Value: LongInt);
  82.     function GetScrollPos: integer;
  83.     procedure SetScrollPos(Value: integer);
  84.     function GetScrollBarRange: integer;
  85.     procedure SetHistoryIndex(Value: integer);
  86.     function GetFontName: TFontName;
  87.     procedure SetFontName(Value: TFontName);
  88.     function GetPreFontName: TFontName;
  89.     procedure SetPreFontName(Value: TFontName);
  90.     procedure SetFontSize(Value: integer);
  91.     procedure SetFontColor(Value: TColor);
  92.     procedure SetHotSpotColor(Value: TColor);
  93.     procedure SetOnBitmapRequest(Handler: TGetBitmapEvent);
  94.     procedure SetOnFormSubmit(Handler: TFormSubmitEvent);
  95.     procedure WMGetDlgCode(var Message: TMessage); message WM_GETDLGCODE;
  96.     procedure SetupAndLogic;
  97.     procedure BackgroundChange(Sender: TObject);
  98.  
  99.   protected
  100.     { Protected declarations }
  101.     ScrollBox: TThumbScrollBox;
  102.     PaintPanel: TPaintPanel;
  103.     CaretPos, Sel1: LongInt;
  104.     function DoLogic: integer;
  105.     function GetURL(X, Y: integer; var URL: OpenString): boolean;
  106.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  107.     function GetPalette: HPALETTE; override;
  108.     procedure HTMLPaint(Sender: TObject); virtual;
  109.     procedure HTMLMouseDown(Sender: TObject; Button: TMouseButton;
  110.       Shift: TShiftState; X, Y: Integer); virtual;
  111.     procedure HTMLMouseMove(Sender: TObject; Shift: TShiftState; X,
  112.       Y: Integer); virtual;
  113.     procedure HTMLMouseUp(Sender: TObject; Button: TMouseButton;
  114.       Shift: TShiftState; X, Y: Integer); virtual;
  115.     procedure URLAction; virtual;
  116.     function HotSpotClickHandled: boolean; dynamic;
  117.     procedure BumpHistory(const FileName: string; OldPos: LongInt);
  118.     procedure LoadFile(const FileName: string);
  119.     procedure PaintWindow(DC: HDC); override;
  120.     procedure ClearImages; virtual;
  121.  
  122.   public
  123.     { Public declarations }
  124.     constructor Create(AOwner: TComponent); override;
  125.     destructor Destroy; override;
  126.     function HTMLExpandFilename(const Filename: string): string; virtual;
  127.     procedure LoadFromFile(const FileName: string);
  128.     procedure LoadStrings(Strings: TStrings);
  129.     procedure LoadFromBuffer(Buffer: PChar; BufSize: LongInt);
  130.     procedure Print(FromPage, ToPage: integer);
  131.     function PositionTo(Dest: string): boolean;
  132.     function Find(const S: String; MatchCase: boolean): boolean;    
  133.     procedure Clear; virtual;  
  134.     property DocumentTitle: string read GetTitle;
  135.     property URL: string read GetFURL;
  136.     property Base: string read GetBase;
  137.     property Position: LongInt read GetPosition write SetPosition;
  138.     property VScrollBarPosition: integer read GetScrollPos write SetScrollPos;
  139.     property VScrollBarRange: integer read GetScrollBarRange;
  140.     property CurrentFile: string read GetCurrentFile;
  141.     property History: TStrings read FHistory;
  142.     property HistoryIndex: integer read FHistoryIndex write SetHistoryIndex;
  143.     property Processing: boolean read FProcessing;
  144.   published
  145.     { Published declarations }
  146.     property OnHotSpotCovered: THotSpotEvent read FOnHotSpotCovered
  147.              write FOnHotSpotCovered;
  148.     property OnHotSpotClick: THotSpotClickEvent read FOnHotSpotClick
  149.              write FOnHotSpotClick;
  150.     property OnBitmapRequest: TGetBitmapEvent read FOnBitmapRequest
  151.              write SetOnBitmapRequest;
  152.     property OnFormSubmit: TFormSubmitEvent read FOnFormSubmit
  153.              write SetOnFormSubmit;   
  154.     property OnHistoryChange: TNotifyEvent read FOnHistoryChange
  155.              write FOnHistoryChange;
  156.     property ViewImages: boolean read GetViewImages write SetViewImages;
  157.     property TabStop;
  158.     property TabOrder;
  159.     property Align;
  160.     property Name;
  161.     property Tag;
  162.     property Height default 150;
  163.     property Width default 150;
  164.     property DefBackground: TColor read FBackground write SetColor default clBtnFace;
  165.     property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle;
  166.     property Visible;
  167.     property HistoryMaxCount: integer read FHistoryMaxCount write FHistoryMaxCount;
  168.     property DefFontName: TFontName read GetFontName write SetFontName;
  169.     property DefPreFontName: TFontName read GetPreFontName write SetPreFontName;
  170.     property DefFontSize: integer read FFontSize write SetFontSize default 12;
  171.     property DefFontColor: TColor read FFontColor write SetFontColor
  172.              default clBtnText;
  173.     property DefHotSpotColor: TColor read FHotSpotColor write SetHotSpotColor
  174.              default clBlue;
  175.     property OnProcessing: TProcessingEvent read FOnProcessing write FOnProcessing;
  176.     end;
  177.  
  178. procedure Register;
  179.  
  180. implementation
  181.  
  182.