Usage
Note! You can not install components of a crossword puzzle on a Delphi's IDE component palette. They have nor Register procedure. To use them you must create components on-fly. 
procedure TXWordF.FormCreate(Sender: TObject);
begin
  { Create crossword panel and put it on the XWordSB scroll box}
  XPanel := TXWPanel.Create( XWordSB);
  with XPanel do begin
    Parent := XWordSB;
    Width := 470;
    Height := 470;
    CellSize := 20;
    PopupMenu := XwPanelPM;
    end;

  { Create word editor and put it on the WEditP panel}
  WEdit := TXWordEdit.Create( WEditP);
  with WEdit do begin
    Parent := WEditP;
    Top := 2;
    Left := 2;
    Font.Name := 'Courier New';
    Font.Size := 12;
    Width := WEditP.Width - 4;
    WEditP.Height := Height + 4;
    end;

  { Create word description drid and put it on the WDescP panel}
  WDesc := TXWDescGrid.Create( WDescP);
  with WDesc do begin
    Parent := WDescP;
    Align := alClient;
    ColWidths[ 1] := 99;
    ColWidths[ 2] := WDescP.Width - ColWidths[ 0] - ColWidths[ 1] - 21;
    end;

  { Create pattern collection and link crossword panel, word editor and description grid}
  XPContainer := TXWDControlCollection.Create;
  with XPContainer do begin
    OnWordChange := WordChanged;
    XPContainer.XWPanel := XPanel;
    XPContainer.XWordEdit := WEdit;
    XPContainer.XWDescGrid := WDesc;
    end;
end;

procedure TXWordF.FormDestroy(Sender: TObject);
begin
  XPContainer.Free;
  WDesc.Free;
  WEdit.Free;
  XPanel.Free;
end;
 
 
Units
XwType.pas - crossword types and common procedures
XWObj.pas - crossword base components
XWCont.pas - crossword visual controls
XwContFill.pas - objects and controls for filling blank crossword
XwDMU.pas - data module for word DataBase
HtmlExport.pas - export crossword data into HTML code
 
 
Components
TXWordData (XWObj.pas) 
constructor Create( XPStr : XPStringDataType); virtual;
procedure SaveToStream(Stream: TStream); virtual;
procedure LoadFromStream(Stream: TStream); virtual;
property CanChange : boolean read FCanChange write FCanChange;
property X : byte 
X coordinate
property Y : byte 
Y coordinate
property L : byte 
Pattern length
property O : XPSOrientationType 
Pattern orientation, can be XPSHorizontal or XPSVertical
property XPS : XPStringDataType; 
Pattern structure record
function ContainsXY( X, Y : byte) : byte; 
Whether contains pattern a point with coordinates X, Y
function HasXross( PD : TXPatternData) : byte; 
If given pattern crosses another pattern that returns in what position it cross
function WhoXrossInChar( CharPosition : byte; var InPosition : byte) : TXPatternData; 
Who crosses given pattern in a position CharPosition. If such exists that function returns this pattern and in variable InPosition in what position is crossed returned pattern.
property Selected : boolean; 
property PatNum : integer; 
Pattern number
property OwnerList : TXPatternCollection; 
Owner of pattern
property Index : integer; 
Pattern index in collection
property AsString : string; 
Pattern data as string 
property XrossNum : integer; 
Quantity of crossings given pattern by others patterns
property XWord  : XWordType; 
Pattern word
property XEtalon  : XWordType; 
Correct word of pattern
property XWDescription : string; 
Word description
function XWMatch : boolean; 
Whether are identical XWord and XEtalon 
function WordFill : integer; 
On how many of percents the word is filled. 0-not filled, 100-complete
function EditMask : string; 
property TouchCount : integer; 
How many time was the reference to a word. Is used in the program of automatic filling of a crossword puzzle
 
TXWordCollection (XWObj.pas) 
procedure LoadFromTextFile( FN : string); 
procedure SaveToTextFile( FN : string); 
procedure SaveToStream(Stream: TStream); 
procedure LoadFromStream(Stream: TStream); 
function Add(Item: TXPatternData): Integer; 
Adds pattern in a collection. Returns index of pattern in a collection
procedure Clear; 
Clears a collection but does not release its elements
procedure Delete(Index: Integer); 
Deletes an element on an index but does not release it
procedure Remove(Index: Integer); 
Deletes an element on an index and releases it
procedure RemoveAll; 
Clears a collection and releases its elements
property Count : integer 
Quantity of elements in a collection
procedure ForEach( Action : TForEachItem); 
Makes action with each element
property Items [Index: Integer]: TXPatternData; 
Returns an element on the given index
function IndexOf( Item : TXPatternData) : integer; 
 Returns an index of the given element
property Bounds : TPoint; 
The sizes of a crossword puzzle
property Selected [Index: Integer]: boolean; 
Set or reset item selection. If index < 0 then set or reset for all elements
property ItemIndex : integer; 
Index of the current element
function XrossList( Index : Integer; XL : TList) : integer; 
Returns quantity of patterns, which cross pattern on the given index. If such patterns exist, their list returns in variable XL
function OverlayList( Index : Integer; OL : TList) : integer; 
Returns quantity of patterns, which overlays on pattern on the given index. If such patterns exist, their list returns in variable OL
function IndexOfXY( X, Y : byte) : integer; 
Returns an index of pattern in a collection, which contains a point X, Y
property Sort : TSortKind; 
Sort collection 
skNoSort, skNothing - no sort 
skYXO, - by X,Y,O values of pattern 
skLength,  by word length 
skWord, 
skFill,    by word fill value 
skXross,   by cross number 
skTouch,   by touch count
property SortDescend : boolean; 
property Lock : boolean; 
Blocks/unblock internal calculations in a collection
function XWordIndex( XW : XWordType) : integer; 
Search of a word in a collection
property XWItems [Index: Integer]: TXWordData; 
property XWords[Index: Integer]: XWordType; 
property XMatch[Index: Integer]: boolean; 
procedure XWStat( var WComplete, WPartialFill, WEmpty : integer); 
Returns statistics 
WComplete - Quantity of words filled completely 
WPartialFill - Quantity of words filled partially 
WEmpty - Quantity of empty words
property OnIndexChange 
property OnAdd 
property OnWordChange 
 
TXWordDataControl (XWCont.pas)
TXWDControlCollection  (XWCont.pas) 
property XWPanel 
property XWordEdit 
property XWDescGrid 
 
TXWPanel  (XWCont.pas) 
procedure SaveSettings( Stream: TStream);
procedure LoadSettings( Stream: TStream);
property CellSize : integer 
property Color;
property Font;
property OnSelect 
 
TXWordEdit  (XWCont.pas) 
procedure SaveSettings( Stream: TStream);
procedure LoadSettings( Stream: TStream);
 
TXWDescGrid  (XWCont.pas) 
procedure SaveSettings( Stream: TStream);
procedure LoadSettings( Stream: TStream);
property XWordCol : TXWDControlCollection 
property XWords[ Index : integer] : string 
property CanEdit : boolean 
 

back