2009-09-04 00:26:56 -04:00
|
|
|
unit TestUnit;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
2009-09-25 15:29:03 -04:00
|
|
|
StdCtrls, Menus, ComCtrls, ExtCtrls, SynEdit, SynHighlighterPas, SynMemo,
|
2009-09-22 16:55:15 -04:00
|
|
|
//Client,
|
|
|
|
MufasaTypes,
|
|
|
|
mmlpsthread,
|
|
|
|
mmlthread,
|
2009-09-22 19:58:14 -04:00
|
|
|
window, // for the comp picker and selector
|
2009-09-23 16:18:33 -04:00
|
|
|
colourpicker,
|
|
|
|
windowselector
|
2009-09-22 16:55:15 -04:00
|
|
|
;
|
2009-09-04 00:26:56 -04:00
|
|
|
|
|
|
|
type
|
|
|
|
|
|
|
|
{ TForm1 }
|
|
|
|
|
|
|
|
TForm1 = class(TForm)
|
2009-09-22 16:55:15 -04:00
|
|
|
Mufasa_Image_List: TImageList;
|
2009-09-19 22:08:02 -04:00
|
|
|
MainMenu1: TMainMenu;
|
|
|
|
Memo1: TMemo;
|
|
|
|
MenuItemScript: TMenuItem;
|
|
|
|
MenuItemRun: TMenuItem;
|
2009-09-12 02:24:59 -04:00
|
|
|
SynEdit1: TSynEdit;
|
|
|
|
SynFreePascalSyn1: TSynFreePascalSyn;
|
2009-09-22 16:55:15 -04:00
|
|
|
ToolBar1: TToolBar;
|
|
|
|
TB_Run: TToolButton;
|
|
|
|
TB_Pause: TToolButton;
|
|
|
|
TB_Stop: TToolButton;
|
|
|
|
ToolButton1: TToolButton;
|
|
|
|
TB_ReloadPlugins: TToolButton;
|
2009-09-25 15:29:03 -04:00
|
|
|
TB_Tray: TToolButton;
|
2009-09-22 16:55:15 -04:00
|
|
|
TB_NewTab: TToolButton;
|
|
|
|
TB_CloseTab: TToolButton;
|
|
|
|
ToolButton4: TToolButton;
|
|
|
|
TB_ClearDebug: TToolButton;
|
|
|
|
TB_PickColour: TToolButton;
|
|
|
|
TB_SelectClient: TToolButton;
|
|
|
|
ToolButton8: TToolButton;
|
|
|
|
TB_Convert: TToolButton;
|
2009-09-25 15:29:03 -04:00
|
|
|
MTrayIcon: TTrayIcon;
|
2009-09-04 00:26:56 -04:00
|
|
|
procedure Button1Click(Sender: TObject);
|
2009-09-12 14:50:10 -04:00
|
|
|
procedure FormCreate(Sender: TObject);
|
2009-09-13 19:56:15 -04:00
|
|
|
procedure FormDestroy(Sender: TObject);
|
2009-09-19 22:08:02 -04:00
|
|
|
procedure MenuItemRunClick(Sender: TObject);
|
2009-09-22 19:58:14 -04:00
|
|
|
procedure PickColorEvent(Sender: TObject);
|
2009-09-23 16:18:33 -04:00
|
|
|
procedure Selector_DOWN(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
2009-09-25 15:29:03 -04:00
|
|
|
procedure NoTray(Sender: TObject);
|
|
|
|
procedure ToTray(Sender: TObject);
|
2009-09-04 00:26:56 -04:00
|
|
|
private
|
|
|
|
{ private declarations }
|
|
|
|
public
|
2009-09-22 16:55:15 -04:00
|
|
|
Window: TMWindow;
|
2009-09-22 19:58:14 -04:00
|
|
|
Picker: TMColorPicker;
|
2009-09-23 16:18:33 -04:00
|
|
|
Selector: TMWindowSelector;
|
2009-09-22 18:28:10 -04:00
|
|
|
{ public declarations }
|
2009-09-04 00:26:56 -04:00
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
2009-09-22 18:28:10 -04:00
|
|
|
Form1: TForm1;
|
|
|
|
|
2009-09-04 00:26:56 -04:00
|
|
|
|
|
|
|
implementation
|
2009-09-09 03:08:58 -04:00
|
|
|
uses
|
2009-09-23 18:01:19 -04:00
|
|
|
lclintf,plugins;
|
2009-09-04 00:26:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ TForm1 }
|
2009-09-19 22:08:02 -04:00
|
|
|
procedure Run;
|
2009-09-04 00:26:56 -04:00
|
|
|
Var
|
2009-09-12 02:24:59 -04:00
|
|
|
MMLPSThread : TMMLPSThread;
|
2009-09-04 00:26:56 -04:00
|
|
|
|
|
|
|
begin
|
2009-09-12 02:24:59 -04:00
|
|
|
MMLPSThread := TMMLPSThread.Create(True);
|
2009-09-19 22:08:02 -04:00
|
|
|
MMLPSThread.SetPSScript(Form1.SynEdit1.Lines.Text);
|
|
|
|
MMLPSThread.SetDebug(Form1.Memo1);
|
2009-09-22 18:28:10 -04:00
|
|
|
|
|
|
|
// This doesn't actually set the Client's MWindow to the passed window, it
|
|
|
|
// only copies the current set window handle.
|
2009-09-23 18:01:19 -04:00
|
|
|
MMLPSThread.Client.MWindow.SetWindow(Form1.Window);
|
2009-09-22 18:28:10 -04:00
|
|
|
|
2009-09-12 02:24:59 -04:00
|
|
|
MMLPSThread.Resume;
|
2009-09-28 22:12:29 -04:00
|
|
|
|
|
|
|
// sleep(500);
|
|
|
|
// MMLPSThread.PSScript.Stop;
|
|
|
|
|
2009-09-19 22:08:02 -04:00
|
|
|
end;
|
2009-09-12 02:24:59 -04:00
|
|
|
|
2009-09-19 22:08:02 -04:00
|
|
|
procedure TForm1.Button1Click(Sender: TObject);
|
|
|
|
begin;
|
|
|
|
Run;
|
2009-09-12 02:24:59 -04:00
|
|
|
end;
|
|
|
|
|
2009-09-12 14:50:10 -04:00
|
|
|
procedure TForm1.FormCreate(Sender: TObject);
|
|
|
|
begin
|
2009-09-22 16:55:15 -04:00
|
|
|
Window := TMWindow.Create;
|
2009-09-22 19:58:14 -04:00
|
|
|
Picker := TMColorPicker.Create(Window);
|
2009-09-23 16:18:33 -04:00
|
|
|
Selector := TMWindowSelector.Create(Window);
|
2009-09-22 19:58:14 -04:00
|
|
|
|
2009-09-13 19:56:15 -04:00
|
|
|
MainDir:= ExtractFileDir(Application.ExeName);
|
|
|
|
PluginsGlob := TMPlugins.Create;
|
|
|
|
PluginsGlob.PluginDirs.Add(ExpandFileName(MainDir + DS + '..' + DS + '..'+ DS + 'Plugins'+ DS));
|
2009-09-19 22:08:02 -04:00
|
|
|
// SynMemo1.sc
|
2009-09-13 19:56:15 -04:00
|
|
|
end;
|
2009-09-12 14:50:10 -04:00
|
|
|
|
2009-09-13 19:56:15 -04:00
|
|
|
procedure TForm1.FormDestroy(Sender: TObject);
|
|
|
|
begin
|
2009-09-23 16:18:33 -04:00
|
|
|
Selector.Free;
|
2009-09-22 19:58:14 -04:00
|
|
|
Picker.Free;
|
2009-09-22 16:55:15 -04:00
|
|
|
Window.Free;
|
2009-09-13 19:56:15 -04:00
|
|
|
PluginsGlob.Free;
|
2009-09-12 14:50:10 -04:00
|
|
|
end;
|
|
|
|
|
2009-09-19 22:08:02 -04:00
|
|
|
procedure TForm1.MenuItemRunClick(Sender: TObject);
|
2009-09-12 02:24:59 -04:00
|
|
|
begin
|
2009-09-19 22:08:02 -04:00
|
|
|
Run;
|
2009-09-04 00:26:56 -04:00
|
|
|
end;
|
|
|
|
|
2009-09-22 19:58:14 -04:00
|
|
|
procedure TForm1.PickColorEvent(Sender: TObject);
|
|
|
|
var
|
|
|
|
c, x, y: Integer;
|
|
|
|
begin
|
|
|
|
Picker.Pick(c, x, y);
|
|
|
|
writeln('Picked colour: ' + inttostr(c) + ' at (' + inttostr(x) + ', ' + inttostr(y) + ')');
|
|
|
|
end;
|
|
|
|
|
2009-09-23 16:18:33 -04:00
|
|
|
procedure TForm1.Selector_DOWN(Sender: TObject; Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: Integer);
|
|
|
|
begin
|
2009-09-23 17:56:51 -04:00
|
|
|
Window.SetTarget(Selector.Drag {$ifdef MSWINDOWS},w_window{$endif});
|
2009-09-23 18:01:19 -04:00
|
|
|
writeln('New window: ' + IntToStr(Window.{$ifdef MSWindows}TargetHandle{$else}CurWindow{$ENDIF}));
|
2009-09-23 16:18:33 -04:00
|
|
|
end;
|
|
|
|
|
2009-09-25 15:29:03 -04:00
|
|
|
procedure TForm1.NoTray(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Not Form1.IsVisible then
|
|
|
|
Form1.Show
|
|
|
|
else
|
|
|
|
Form1.Hide;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TForm1.ToTray(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Form1.Hide;
|
|
|
|
end;
|
|
|
|
|
2009-09-19 22:08:02 -04:00
|
|
|
|
2009-09-04 00:26:56 -04:00
|
|
|
initialization
|
|
|
|
{$I testunit.lrs}
|
|
|
|
|
|
|
|
end.
|
|
|
|
|