MAGMAOWL.TXT

Notes on the Borland Pascal OWL interface to MAGMAED.DLL

This interface consists of two primary objects, and a number of smaller
objects used by those objects.  Programs will generally create a TMagmaWindow
which is a container for a TMagmaEdit.  If you need to customize the
TMagmaEdit object, you can replace your child object with the default by
using the virtual function CreateEditor.  This is done in the same way that
InitMainWindow allows customized main windows to be managed by the TApplication
object.

It is easiest to explain in code, so let me present a small sample
application.  This example creates a regular TMagmaWindow, with a customized
TmagmaEdit (called TMyEdit) which grabs wm_keyup messages to call a validator.
For simplicity, I have left out the validator.

Program MagmaEditDemo;

uses wintypes,owindows,magmaed;

type
  papp=^tapp;
  tapp=object(tapplication)
    procedure initmainwindow; virtual;
  end;

  pmainwin=^tmainwin;
  tmainwin=object(tmagmawindow)
    procedure CreateEditor; virtual;
  end;

  pmyedit=^tmyedit;
  tmyedit=object(tmagmaedit)
    procedure wmKeyup(var msg:tmessage);
      virtual wm_first + wm_keyup;
  end;

procedure TMainWin.CreateEditor;
begin
  edit:=new(PMyEdit,init(@self,100,'',0,0,100,100,32000,true));
end;

procedure tmyedit.wmKeyup(var msg:tmessage);
begin
  {Validate line here}
  defwndproc(msg);
end;

procedure tapp.initmainwindow;
begin
  mainwindow:=new(pmainwin,init(nil,'Magma Edit for Pascal'));
end;

var
  app:papp;
begin
  app:=new(papp,init('Magma Test'));
  app^.run;
  dispose(app,done);
end.

Nifty Stuff:

-  The TMagmaWindow contains all the code you need for file, edit, and search
   menus.  They could be improved, but they aren't bad.  Attach them with
   AddFileMenu, AddEditMenu, and AddSearchMenu.  Add items to them with
   AddToFileMenu, AddToEditMenu and AddToSearchMenu.
-  The TMagmaWindow will put up a status window for loading files.  Turn this
   on by overriding the ShowStatusWin function to return true.
-  Limited (and a bit buggy) syntax highlighting is built in to the
   TMagmaHighlight object.  It will highlight lists of words by changing their
   font and/or colour.  Use CreateWordGroup to create a new list of words, and
   AppendWordList to add words to the list.  Be warned that this feature doesn't
   work very well.  (See Known Bugs below).
-  The MAGMAED.PAS uses a linked list object, stored in a separate file
   (LINKED.PAS) which I use all the time.  If you figure it out, you are
   welcome to use it.


Possible Enhancements:

-  I'd like to fix up painting to avoid flicker
-  The TMagmaHighlight object needs work.  It is slow, and I think speed could
   be improved if I were to switch from the linked list currently used to
   keep track of highlighted words to a binary tree.  I would also like to
   find a better hash function.
-  I'd like to add a status window for writes as well as reads.  I will do
   this as soon as a MAGMAED.DLL which supports it is made available.


Known Bugs:

-  Vertical scrolling does not work well in the TMagmaHighlight object.
-  The TMagmaHighlight object does not check the correct background colour,
   but uses white always.
-  The TMagmaHighlight object highlights words including following symbols
   such as brackets and quotes.  This looks silly.


If you need help, or want to send me bug reports, fixes or hate-mail, please
mail me at vic@io.org.  I'll be happy to send you the latest version.  (Verson
number can be found at the top of the MAGMAED.PAS file.)


