1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-03-03 02:41:54 -05:00

Je ziet maar

git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@11 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Raymond 2009-09-03 03:59:26 +00:00
parent abb0020dc5
commit ba1e0833b0
6 changed files with 683 additions and 556 deletions

View File

@ -103,13 +103,14 @@ var
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
var var
MousePoint : TPoint; MousePoint : TPoint;
Rect : TRect;
{$ENDIF} {$ENDIF}
begin begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
Windows.GetCursorPos(MousePoint); Windows.GetCursorPos(MousePoint);
Windows.ScreenToClient( TClient(Client).MWindow.TargetHandle, MousePoint); GetWindowRect(TClient(Client).MWindow.TargetHandle,Rect);
x := MousePoint.x; x := MousePoint.x - Rect.Left;
y := MousePoint.y; y := MousePoint.y - Rect.Top;
{$ENDIF} {$ENDIF}
{$IFDEF LINUX} {$IFDEF LINUX}
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler); Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
@ -131,6 +132,7 @@ begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
GetWindowRect(TClient(Client).MWindow.TargetHandle, Rect); GetWindowRect(TClient(Client).MWindow.TargetHandle, Rect);
Windows.SetCursorPos(x + Rect.Left, y + Rect.Top); Windows.SetCursorPos(x + Rect.Left, y + Rect.Top);
{$ENDIF} {$ENDIF}
{$IFDEF LINUX} {$IFDEF LINUX}
Old_Handler := XSetErrorHandler(@MufasaXErrorHandler); Old_Handler := XSetErrorHandler(@MufasaXErrorHandler);
@ -229,8 +231,8 @@ begin
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
case mType of case mType of
Mouse_Left: Result := (GetAsyncKeyState(VK_LBUTTON) <> 0); Mouse_Left: Result := (GetAsyncKeyState(VK_LBUTTON) <> 0);
Mouse_Middle: Result := (GetAsyncKeyState(VK_MBUTTON) <> 0) Mouse_Middle: Result := (GetAsyncKeyState(VK_MBUTTON) <> 0);
Mouse_Right: Result := (GetAsyncKeyState(VK_RBUTTON) <> 0) mouse_Right: Result := (GetAsyncKeyState(VK_RBUTTON) <> 0);
end; end;
{$ENDIF} {$ENDIF}
{$IFDEF LINUX} {$IFDEF LINUX}

View File

@ -5,22 +5,28 @@ unit Window;
interface interface
uses uses
Classes, SysUtils, mufasatypes, graphics, Classes, SysUtils, mufasatypes{$IFDEF MSWINDOWS},windows {$ENDIF}, graphics,
LCLType LCLType
{$IFDEF LINUX}, xlib, x, xutil, ctypes{$ENDIF}; {$IFDEF LINUX}, xlib, x, xutil, ctypes{$ENDIF};
type type
{ TMWindow }
TMWindow = class(TObject) TMWindow = class(TObject)
function ReturnData(xs, ys, width, height: Integer): PRGB32; function ReturnData(xs, ys, width, height: Integer): PRGB32;
procedure FreeReturnData; procedure FreeReturnData;
procedure GetDimensions(var W, H: Integer); procedure GetDimensions(var W, H: Integer);
function CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap; function CopyClientToBitmap(xs, ys, xe, ye: integer): TBitmap;
procedure ActivateClient;
{$IFDEF LINUX} {$IFDEF LINUX}
function SetTarget(XWindow: x.TWindow): integer; overload; function SetTarget(XWindow: x.TWindow): integer; overload;
{$ENDIF} {$ENDIF}
{$IFDEF MSWINDOWS}
function UpdateDrawBitmap:boolean;
{$ENDIF}
function SetTarget(Window: THandle; NewType: TTargetWindowMode): integer; overload; function SetTarget(Window: THandle; NewType: TTargetWindowMode): integer; overload;
function SetTarget(ArrPtr: PRGB32): integer; overload; function SetTarget(ArrPtr: PRGB32): integer; overload;
@ -33,9 +39,15 @@ type
// Target Window Mode. // Target Window Mode.
TargetMode: TTargetWindowMode; TargetMode: TTargetWindowMode;
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
//Target handle; HWND //Target handle; HWND
TargetHandle : Hwnd; TargetHandle : Hwnd;
DrawBmpDataPtr : PRGB32;
//Works on linux as well, test it out
TargetDC : HDC;
DrawBitmap : TBitmap;
{$ENDIF} {$ENDIF}
{$IFDEF LINUX} {$IFDEF LINUX}
@ -90,6 +102,13 @@ constructor TMWindow.Create(Client: TObject);
begin begin
inherited Create; inherited Create;
Self.Client := Client; Self.Client := Client;
{$IFDEF MSWINDOWS}
Self.DrawBitmap := TBitmap.Create;
Self.TargetMode:= w_Window;
Self.TargetHandle:= windows.GetDesktopWindow;
Self.TargetDC:= GetWindowDC(Self.TargetHandle);
Self.UpdateDrawBitmap;
{$ENDIF}
{$IFDEF LINUX} {$IFDEF LINUX}
Self.TargetMode := w_XWindow; Self.TargetMode := w_XWindow;
@ -106,8 +125,6 @@ begin
Self.DesktopWindow:= RootWindow(Self.XDisplay, Self.XScreenNum); Self.DesktopWindow:= RootWindow(Self.XDisplay, Self.XScreenNum);
Self.CurWindow:= Self.DesktopWindow; Self.CurWindow:= Self.DesktopWindow;
{$ELSE}
// Set Target mode for windows.
{$ENDIF} {$ENDIF}
end; end;
@ -118,7 +135,11 @@ begin
{$IFDEF LINUX} {$IFDEF LINUX}
XCloseDisplay(Self.XDisplay); XCloseDisplay(Self.XDisplay);
{$ENDIF} {$ENDIF}
{$IFDEF MSWINDOWS}
if TargetMode = w_Window then
ReleaseDC(TargetHandle,TargetDC);
DrawBitmap.Free;
{$ENDIF}
inherited; inherited;
end; end;
@ -129,6 +150,13 @@ var
{$ENDIF} {$ENDIF}
begin begin
case Self.TargetMode of case Self.TargetMode of
w_Window:
begin
{$IFDEF MSWINDOWS}
BitBlt(Self.DrawBitmap.Canvas.Handle,0,0, width, height, Self.TargetDC, xs,ys, SRCCOPY);
Result := Self.DrawBmpDataPtr;
{$ENDIF}
end;
w_XWindow: w_XWindow:
begin begin
{$IFDEF LINUX} {$IFDEF LINUX}
@ -190,6 +218,17 @@ begin
hh := ye-ys; hh := ye-ys;
case Self.TargetMode Of case Self.TargetMode Of
w_Window:
begin
{$IFDEF MSWINDOWS}
if(xs < 0) or (ys < 0) or (xe > W) or (ye > H) then
Writeln('pervet');
Result := TBitmap.Create;
Result.SetSize(ww+1,hh+1);
BitBlt(result.canvas.handle,0,0,ww+1,hh+1,
self.TargetDC,xs,ys, SRCCOPY);
{$ENDIF}
end;
w_XWindow: w_XWindow:
begin begin
{$IFDEF LINUX} {$IFDEF LINUX}
@ -225,6 +264,30 @@ begin
end; end;
end; end;
procedure TMWindow.ActivateClient;
begin
{$IFDEF MSWINDOWS}
SetForegroundWindow(Self.TargetHandle);
{$ENDIF}
{$IFDEF LINUX}
XSetInputFocus(Self.XDisplay,Self.CurWindow,RevertToParent,CurrentTime);
{$ENDIF}
end;
{$IFDEF MSWINDOWS} //Probably need one for Linux as well
function TMWindow.UpdateDrawBitmap :boolean;
var
w,h : integer;
BmpInfo : Windows.TBitmap;
begin
GetDimensions(w,h);
DrawBitmap.SetSize(w,h);
GetObject(DrawBitmap.Handle, SizeOf(BmpInfo), @BmpInfo);
DrawBmpDataPtr := BmpInfo.bmBits;
end;
{$ENDIF}
procedure TMWindow.GetDimensions(var W, H: Integer); procedure TMWindow.GetDimensions(var W, H: Integer);
{$IFDEF LINUX} {$IFDEF LINUX}
var var
@ -233,10 +296,19 @@ var
childwindow : x.TWindow; childwindow : x.TWindow;
Old_Handler: TXErrorHandler; Old_Handler: TXErrorHandler;
{$ENDIF} {$ENDIF}
{$IFDEF MSWINDOWS}
var
Rect : TRect;
{$ENDIF}
begin begin
case TargetMode of case TargetMode of
w_Window: w_Window:
begin begin
{$IFDEF MSWINDOWS}
GetWindowRect(Self.TargetHandle, Rect);
w:= Rect.Right - Rect.left + 1;
h:= Rect.Bottom - Rect.Top + 1;
{$ENDIF}
end; end;
w_XWindow: w_XWindow:
begin begin
@ -280,8 +352,19 @@ begin
if NewType in [ w_XWindow, w_ArrayPtr ] then if NewType in [ w_XWindow, w_ArrayPtr ] then
begin begin
// throw exception // throw exception
Exit;
end; end;
case NewType of
w_Window :
begin;
ReleaseDC(Self.TargetHandle,Self.TargetDC);
Self.TargetHandle := Window;
Self.TargetDC := GetWindowDC(Window);
end;
end;
{$IFDEF MSWINDOWS}
UpdateDrawBitmap;
{$ENDIF}
end; end;
function TMWindow.SetTarget(ArrPtr: PRGB32): integer; overload; function TMWindow.SetTarget(ArrPtr: PRGB32): integer; overload;

View File

@ -1,404 +1,440 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<Version Value="7"/> <Version Value="7"/>
<General> <General>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<TargetFileExt Value=""/> <TargetFileExt Value=""/>
<UseXPManifest Value="True"/> <UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="6"/> <ActiveEditorIndexAtStart Value="10"/>
</General> </General>
<VersionInfo> <VersionInfo>
<ProjectVersion Value=""/> <ProjectVersion Value=""/>
<Language Value=""/> <Language Value=""/>
<CharSet Value=""/> <CharSet Value=""/>
</VersionInfo> </VersionInfo>
<PublishOptions> <PublishOptions>
<Version Value="2"/> <Version Value="2"/>
<IgnoreBinaries Value="False"/> <IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/> <ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions> </PublishOptions>
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="1"> <RequiredPackages Count="1">
<Item1> <Item1>
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item1> </Item1>
</RequiredPackages> </RequiredPackages>
<Units Count="26"> <Units Count="33">
<Unit0> <Unit0>
<Filename Value="project1.lpr"/> <Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="project1"/> <UnitName Value="project1"/>
<CursorPos X="60" Y="16"/> <CursorPos X="1" Y="19"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="1"/> <EditorIndex Value="0"/>
<UsageCount Value="44"/> <UsageCount Value="48"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="unit1.pas"/> <Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/> <ComponentName Value="Form1"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<UnitName Value="TestUnit"/> <UnitName Value="TestUnit"/>
<CursorPos X="33" Y="57"/> <CursorPos X="33" Y="57"/>
<TopLine Value="32"/> <TopLine Value="32"/>
<UsageCount Value="44"/> <UsageCount Value="48"/>
</Unit1> </Unit1>
<Unit2> <Unit2>
<Filename Value="client.pas"/> <Filename Value="client.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="Client"/> <UnitName Value="Client"/>
<CursorPos X="18" Y="34"/> <CursorPos X="18" Y="34"/>
<TopLine Value="10"/> <TopLine Value="10"/>
<UsageCount Value="44"/> <UsageCount Value="48"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="../cogat/Units/CogatUnits/comptypes.pas"/> <Filename Value="../cogat/Units/CogatUnits/comptypes.pas"/>
<UnitName Value="CompTypes"/> <UnitName Value="CompTypes"/>
<CursorPos X="13" Y="531"/> <CursorPos X="13" Y="531"/>
<TopLine Value="523"/> <TopLine Value="523"/>
<EditorIndex Value="8"/> <UsageCount Value="22"/>
<UsageCount Value="22"/> </Unit3>
<Loaded Value="True"/> <Unit4>
</Unit3> <Filename Value="mufasatypes.pas"/>
<Unit4> <IsPartOfProject Value="True"/>
<Filename Value="mufasatypes.pas"/> <UnitName Value="MufasaTypes"/>
<IsPartOfProject Value="True"/> <CursorPos X="52" Y="20"/>
<UnitName Value="MufasaTypes"/> <TopLine Value="1"/>
<CursorPos X="52" Y="20"/> <UsageCount Value="48"/>
<TopLine Value="1"/> </Unit4>
<UsageCount Value="44"/> <Unit5>
</Unit4> <Filename Value="window.pas"/>
<Unit5> <IsPartOfProject Value="True"/>
<Filename Value="window.pas"/> <UnitName Value="Window"/>
<IsPartOfProject Value="True"/> <CursorPos X="4" Y="100"/>
<UnitName Value="Window"/> <TopLine Value="85"/>
<CursorPos X="4" Y="100"/> <UsageCount Value="48"/>
<TopLine Value="85"/> </Unit5>
<UsageCount Value="44"/> <Unit6>
</Unit5> <Filename Value="../Documents/fpc/rtl/inc/systemh.inc"/>
<Unit6> <CursorPos X="3" Y="261"/>
<Filename Value="../../Documents/fpc/rtl/inc/systemh.inc"/> <TopLine Value="246"/>
<CursorPos X="3" Y="261"/> <UsageCount Value="8"/>
<TopLine Value="246"/> </Unit6>
<UsageCount Value="8"/> <Unit7>
</Unit6> <Filename Value="input.pas"/>
<Unit7> <IsPartOfProject Value="True"/>
<Filename Value="input.pas"/> <UnitName Value="Input"/>
<IsPartOfProject Value="True"/> <CursorPos X="5" Y="20"/>
<UnitName Value="Input"/> <TopLine Value="15"/>
<CursorPos X="5" Y="20"/> <UsageCount Value="47"/>
<TopLine Value="15"/> </Unit7>
<UsageCount Value="43"/> <Unit8>
</Unit7> <Filename Value="../cogat/Units/CogatUnits/compinput.pas"/>
<Unit8> <UnitName Value="CompInput"/>
<Filename Value="../cogat/Units/CogatUnits/compinput.pas"/> <CursorPos X="43" Y="250"/>
<UnitName Value="CompInput"/> <TopLine Value="236"/>
<CursorPos X="43" Y="250"/> <UsageCount Value="20"/>
<TopLine Value="236"/> </Unit8>
<EditorIndex Value="10"/> <Unit9>
<UsageCount Value="20"/> <Filename Value="Units/MMLCore/client.pas"/>
<Loaded Value="True"/> <UnitName Value="Client"/>
</Unit8> <CursorPos X="27" Y="16"/>
<Unit9> <TopLine Value="1"/>
<Filename Value="Units/MMLCore/client.pas"/> <EditorIndex Value="11"/>
<UnitName Value="Client"/> <UsageCount Value="20"/>
<CursorPos X="1" Y="1"/> <Loaded Value="True"/>
<TopLine Value="1"/> </Unit9>
<EditorIndex Value="7"/> <Unit10>
<UsageCount Value="18"/> <Filename Value="Units/MMLCore/input.pas"/>
<Loaded Value="True"/> <UnitName Value="Input"/>
</Unit9> <CursorPos X="52" Y="241"/>
<Unit10> <TopLine Value="234"/>
<Filename Value="Units/MMLCore/input.pas"/> <EditorIndex Value="1"/>
<UnitName Value="Input"/> <UsageCount Value="20"/>
<CursorPos X="42" Y="141"/> <Loaded Value="True"/>
<TopLine Value="125"/> </Unit10>
<EditorIndex Value="2"/> <Unit11>
<UsageCount Value="18"/> <Filename Value="Units/MMLCore/mufasatypes.pas"/>
<Loaded Value="True"/> <UnitName Value="MufasaTypes"/>
</Unit10> <CursorPos X="20" Y="3"/>
<Unit11> <TopLine Value="1"/>
<Filename Value="Units/MMLCore/mufasatypes.pas"/> <EditorIndex Value="6"/>
<UnitName Value="MufasaTypes"/> <UsageCount Value="20"/>
<CursorPos X="40" Y="19"/> <Loaded Value="True"/>
<TopLine Value="1"/> </Unit11>
<EditorIndex Value="3"/> <Unit12>
<UsageCount Value="18"/> <Filename Value="Units/MMLCore/window.pas"/>
<Loaded Value="True"/> <UnitName Value="Window"/>
</Unit11> <CursorPos X="14" Y="329"/>
<Unit12> <TopLine Value="185"/>
<Filename Value="Units/MMLCore/window.pas"/> <EditorIndex Value="7"/>
<UnitName Value="Window"/> <UsageCount Value="20"/>
<CursorPos X="20" Y="279"/> <Loaded Value="True"/>
<TopLine Value="258"/> </Unit12>
<EditorIndex Value="4"/> <Unit13>
<UsageCount Value="18"/> <Filename Value="Units/MMLCore/windowutil.pas"/>
<Loaded Value="True"/> <IsPartOfProject Value="True"/>
</Unit12> <UnitName Value="windowutil"/>
<Unit13> <CursorPos X="45" Y="13"/>
<Filename Value="Units/MMLCore/windowutil.pas"/> <TopLine Value="1"/>
<IsPartOfProject Value="True"/> <UsageCount Value="40"/>
<UnitName Value="windowutil"/> </Unit13>
<CursorPos X="45" Y="13"/> <Unit14>
<TopLine Value="1"/> <Filename Value="../Documents/lazarus/lcl/graphics.pp"/>
<UsageCount Value="36"/> <UnitName Value="Graphics"/>
</Unit13> <CursorPos X="15" Y="1287"/>
<Unit14> <TopLine Value="1272"/>
<Filename Value="../../Documents/lazarus/lcl/graphics.pp"/> <UsageCount Value="17"/>
<UnitName Value="Graphics"/> </Unit14>
<CursorPos X="15" Y="1287"/> <Unit15>
<TopLine Value="1272"/> <Filename Value="../cogat/Units/CogatUnits/compbitmaps.pas"/>
<EditorIndex Value="0"/> <UnitName Value="CompBitmaps"/>
<UsageCount Value="17"/> <CursorPos X="1" Y="109"/>
<Loaded Value="True"/> <TopLine Value="92"/>
</Unit14> <UsageCount Value="17"/>
<Unit15> </Unit15>
<Filename Value="../cogat/Units/CogatUnits/compbitmaps.pas"/> <Unit16>
<UnitName Value="CompBitmaps"/> <Filename Value="../Documents/lazarus/lcl/include/rasterimage.inc"/>
<CursorPos X="1" Y="109"/> <CursorPos X="1" Y="1"/>
<TopLine Value="92"/> <TopLine Value="691"/>
<EditorIndex Value="11"/> <UsageCount Value="9"/>
<UsageCount Value="17"/> </Unit16>
<Loaded Value="True"/> <Unit17>
</Unit15> <Filename Value="../Documents/fpc/packages/x11/src/xlib.pp"/>
<Unit16> <UnitName Value="xlib"/>
<Filename Value="../../Documents/lazarus/lcl/include/rasterimage.inc"/> <CursorPos X="47" Y="1272"/>
<CursorPos X="1" Y="1"/> <TopLine Value="1257"/>
<TopLine Value="691"/> <UsageCount Value="12"/>
<UsageCount Value="9"/> </Unit17>
</Unit16> <Unit18>
<Unit17> <Filename Value="testunit.pas"/>
<Filename Value="../../Documents/fpc/packages/x11/src/xlib.pp"/> <ComponentName Value="Form1"/>
<UnitName Value="xlib"/> <HasResources Value="True"/>
<CursorPos X="47" Y="1272"/> <ResourceBaseClass Value="Form"/>
<TopLine Value="1257"/> <UnitName Value="TestUnit"/>
<EditorIndex Value="5"/> <CursorPos X="34" Y="61"/>
<UsageCount Value="12"/> <TopLine Value="50"/>
<Loaded Value="True"/> <EditorIndex Value="10"/>
</Unit17> <UsageCount Value="17"/>
<Unit18> <Loaded Value="True"/>
<Filename Value="testunit.pas"/> </Unit18>
<ComponentName Value="Form1"/> <Unit19>
<HasResources Value="True"/> <Filename Value="../cogat/Units/CogatUnits/compcolors.pas"/>
<ResourceBaseClass Value="Form"/> <UnitName Value="CompColors"/>
<UnitName Value="TestUnit"/> <CursorPos X="44" Y="914"/>
<CursorPos X="30" Y="72"/> <TopLine Value="897"/>
<TopLine Value="64"/> <UsageCount Value="15"/>
<EditorIndex Value="6"/> </Unit19>
<UsageCount Value="15"/> <Unit20>
<Loaded Value="True"/> <Filename Value="../Documents/fpc/packages/x11/src/x.pp"/>
</Unit18> <UnitName Value="x"/>
<Unit19> <CursorPos X="4" Y="179"/>
<Filename Value="../cogat/Units/CogatUnits/compcolors.pas"/> <TopLine Value="164"/>
<UnitName Value="CompColors"/> <UsageCount Value="10"/>
<CursorPos X="44" Y="914"/> </Unit20>
<TopLine Value="897"/> <Unit21>
<EditorIndex Value="9"/> <Filename Value="../Documents/fpc/rtl/unix/aliasctp.inc"/>
<UsageCount Value="15"/> <CursorPos X="63" Y="45"/>
<Loaded Value="True"/> <TopLine Value="30"/>
</Unit19> <UsageCount Value="10"/>
<Unit20> </Unit21>
<Filename Value="../../Documents/fpc/packages/x11/src/x.pp"/> <Unit22>
<UnitName Value="x"/> <Filename Value="../cogat/Units/CogatUnits/compdragger.pas"/>
<CursorPos X="4" Y="179"/> <UnitName Value="CompDragger"/>
<TopLine Value="164"/> <CursorPos X="33" Y="14"/>
<UsageCount Value="10"/> <TopLine Value="6"/>
</Unit20> <UsageCount Value="10"/>
<Unit21> </Unit22>
<Filename Value="../../Documents/fpc/rtl/unix/aliasctp.inc"/> <Unit23>
<CursorPos X="63" Y="45"/> <Filename Value="../Documents/lazarus/lcl/lcltype.pp"/>
<TopLine Value="30"/> <UnitName Value="LCLType"/>
<UsageCount Value="10"/> <CursorPos X="9" Y="99"/>
</Unit21> <TopLine Value="83"/>
<Unit22> <UsageCount Value="10"/>
<Filename Value="../cogat/Units/CogatUnits/compdragger.pas"/> </Unit23>
<UnitName Value="CompDragger"/> <Unit24>
<CursorPos X="33" Y="14"/> <Filename Value="testunit.lfm"/>
<TopLine Value="6"/> <CursorPos X="1" Y="1"/>
<UsageCount Value="10"/> <TopLine Value="1"/>
</Unit22> <UsageCount Value="10"/>
<Unit23> <SyntaxHighlighter Value="LFM"/>
<Filename Value="../../Documents/lazarus/lcl/lcltype.pp"/> </Unit24>
<UnitName Value="LCLType"/> <Unit25>
<CursorPos X="9" Y="99"/> <Filename Value="../Documents/fpc/rtl/unix/unix.pp"/>
<TopLine Value="83"/> <UnitName Value="Unix"/>
<UsageCount Value="10"/> <CursorPos X="63" Y="63"/>
</Unit23> <TopLine Value="56"/>
<Unit24> <UsageCount Value="10"/>
<Filename Value="testunit.lfm"/> </Unit25>
<CursorPos X="1" Y="1"/> <Unit26>
<TopLine Value="1"/> <Filename Value="../Compilertje/Units/CogatUnits/compinput.pas"/>
<UsageCount Value="10"/> <UnitName Value="CompInput"/>
<SyntaxHighlighter Value="LFM"/> <CursorPos X="6" Y="462"/>
</Unit24> <TopLine Value="449"/>
<Unit25> <EditorIndex Value="2"/>
<Filename Value="../../Documents/fpc/rtl/unix/unix.pp"/> <UsageCount Value="12"/>
<UnitName Value="Unix"/> <Loaded Value="True"/>
<CursorPos X="63" Y="63"/> </Unit26>
<TopLine Value="56"/> <Unit27>
<UsageCount Value="10"/> <Filename Value="../FPC/FPCCheckout/rtl/win/wininc/func.inc"/>
</Unit25> <CursorPos X="10" Y="663"/>
</Units> <TopLine Value="635"/>
<JumpHistory Count="30" HistoryIndex="29"> <EditorIndex Value="5"/>
<Position1> <UsageCount Value="11"/>
<Filename Value="Units/MMLCore/input.pas"/> <Loaded Value="True"/>
<Caret Line="97" Column="63" TopLine="82"/> </Unit27>
</Position1> <Unit28>
<Position2> <Filename Value="../Compilertje/Units/CogatUnits/comptypes.pas"/>
<Filename Value="../cogat/Units/CogatUnits/compinput.pas"/> <UnitName Value="CompTypes"/>
<Caret Line="8" Column="33" TopLine="1"/> <CursorPos X="13" Y="418"/>
</Position2> <TopLine Value="402"/>
<Position3> <EditorIndex Value="3"/>
<Filename Value="Units/MMLCore/input.pas"/> <UsageCount Value="11"/>
<Caret Line="100" Column="29" TopLine="84"/> <Loaded Value="True"/>
</Position3> </Unit28>
<Position4> <Unit29>
<Filename Value="Units/MMLCore/input.pas"/> <Filename Value="../Compilertje/Units/CogatUnits/compcolors.pas"/>
<Caret Line="106" Column="42" TopLine="89"/> <UnitName Value="CompColors"/>
</Position4> <CursorPos X="12" Y="603"/>
<Position5> <TopLine Value="573"/>
<Filename Value="Units/MMLCore/input.pas"/> <EditorIndex Value="4"/>
<Caret Line="112" Column="55" TopLine="95"/> <UsageCount Value="11"/>
</Position5> <Loaded Value="True"/>
<Position6> </Unit29>
<Filename Value="testunit.pas"/> <Unit30>
<Caret Line="38" Column="69" TopLine="31"/> <Filename Value="../lazarus/lcl/graphics.pp"/>
</Position6> <UnitName Value="Graphics"/>
<Position7> <CursorPos X="15" Y="1283"/>
<Filename Value="testunit.pas"/> <TopLine Value="1270"/>
<Caret Line="60" Column="14" TopLine="37"/> <EditorIndex Value="8"/>
</Position7> <UsageCount Value="11"/>
<Position8> <Loaded Value="True"/>
<Filename Value="Units/MMLCore/input.pas"/> </Unit30>
<Caret Line="22" Column="48" TopLine="1"/> <Unit31>
</Position8> <Filename Value="../lazarus/lcl/include/rasterimage.inc"/>
<Position9> <CursorPos X="20" Y="351"/>
<Filename Value="testunit.pas"/> <TopLine Value="339"/>
<Caret Line="9" Column="16" TopLine="1"/> <EditorIndex Value="9"/>
</Position9> <UsageCount Value="11"/>
<Position10> <Loaded Value="True"/>
<Filename Value="Units/MMLCore/input.pas"/> </Unit31>
<Caret Line="136" Column="1" TopLine="112"/> <Unit32>
</Position10> <Filename Value="../lazarus/lcl/intfgraphics.pas"/>
<Position11> <UnitName Value="IntfGraphics"/>
<Filename Value="Units/MMLCore/input.pas"/> <CursorPos X="3" Y="3251"/>
<Caret Line="135" Column="125" TopLine="113"/> <TopLine Value="3245"/>
</Position11> <UsageCount Value="10"/>
<Position12> </Unit32>
<Filename Value="Units/MMLCore/input.pas"/> </Units>
<Caret Line="127" Column="22" TopLine="113"/> <JumpHistory Count="29" HistoryIndex="28">
</Position12> <Position1>
<Position13> <Filename Value="../Compilertje/Units/CogatUnits/comptypes.pas"/>
<Filename Value="Units/MMLCore/input.pas"/> <Caret Line="174" Column="9" TopLine="146"/>
<Caret Line="136" Column="21" TopLine="113"/> </Position1>
</Position13> <Position2>
<Position14> <Filename Value="../Compilertje/Units/CogatUnits/comptypes.pas"/>
<Filename Value="Units/MMLCore/input.pas"/> <Caret Line="177" Column="19" TopLine="146"/>
<Caret Line="135" Column="2" TopLine="113"/> </Position2>
</Position14> <Position3>
<Position15> <Filename Value="../Compilertje/Units/CogatUnits/comptypes.pas"/>
<Filename Value="testunit.pas"/> <Caret Line="324" Column="19" TopLine="296"/>
<Caret Line="74" Column="3" TopLine="50"/> </Position3>
</Position15> <Position4>
<Position16> <Filename Value="../Compilertje/Units/CogatUnits/compinput.pas"/>
<Filename Value="Units/MMLCore/input.pas"/> <Caret Line="7" Column="140" TopLine="1"/>
<Caret Line="138" Column="31" TopLine="113"/> </Position4>
</Position16> <Position5>
<Position17> <Filename Value="Units/MMLCore/window.pas"/>
<Filename Value="Units/MMLCore/input.pas"/> <Caret Line="18" Column="30" TopLine="1"/>
<Caret Line="131" Column="45" TopLine="117"/> </Position5>
</Position17> <Position6>
<Position18> <Filename Value="../Compilertje/Units/CogatUnits/comptypes.pas"/>
<Filename Value="Units/MMLCore/input.pas"/> <Caret Line="11" Column="138" TopLine="6"/>
<Caret Line="92" Column="13" TopLine="75"/> </Position6>
</Position18> <Position7>
<Position19> <Filename Value="Units/MMLCore/window.pas"/>
<Filename Value="testunit.pas"/> <Caret Line="156" Column="10" TopLine="146"/>
<Caret Line="51" Column="40" TopLine="34"/> </Position7>
</Position19> <Position8>
<Position20> <Filename Value="testunit.pas"/>
<Filename Value="Units/MMLCore/input.pas"/> <Caret Line="58" Column="34" TopLine="43"/>
<Caret Line="142" Column="1" TopLine="120"/> </Position8>
</Position20> <Position9>
<Position21> <Filename Value="testunit.pas"/>
<Filename Value="../cogat/Units/CogatUnits/compinput.pas"/> <Caret Line="28" Column="59" TopLine="1"/>
<Caret Line="51" Column="35" TopLine="31"/> </Position9>
</Position21> <Position10>
<Position22> <Filename Value="project1.lpr"/>
<Filename Value="../cogat/Units/CogatUnits/compinput.pas"/> <Caret Line="16" Column="60" TopLine="1"/>
<Caret Line="32" Column="35" TopLine="19"/> </Position10>
</Position22> <Position11>
<Position23> <Filename Value="project1.lpr"/>
<Filename Value="testunit.pas"/> <Caret Line="19" Column="1" TopLine="1"/>
<Caret Line="75" Column="47" TopLine="58"/> </Position11>
</Position23> <Position12>
<Position24> <Filename Value="testunit.pas"/>
<Filename Value="testunit.pas"/> <Caret Line="50" Column="42" TopLine="35"/>
<Caret Line="71" Column="19" TopLine="56"/> </Position12>
</Position24> <Position13>
<Position25> <Filename Value="testunit.pas"/>
<Filename Value="testunit.pas"/> <Caret Line="62" Column="32" TopLine="59"/>
<Caret Line="60" Column="3" TopLine="38"/> </Position13>
</Position25> <Position14>
<Position26> <Filename Value="testunit.pas"/>
<Filename Value="Units/MMLCore/window.pas"/> <Caret Line="57" Column="22" TopLine="41"/>
<Caret Line="280" Column="20" TopLine="259"/> </Position14>
</Position26> <Position15>
<Position27> <Filename Value="../Compilertje/Units/CogatUnits/comptypes.pas"/>
<Filename Value="Units/MMLCore/window.pas"/> <Caret Line="5" Column="109" TopLine="1"/>
<Caret Line="279" Column="7" TopLine="261"/> </Position15>
</Position27> <Position16>
<Position28> <Filename Value="Units/MMLCore/window.pas"/>
<Filename Value="testunit.pas"/> <Caret Line="18" Column="27" TopLine="14"/>
<Caret Line="47" Column="46" TopLine="31"/> </Position16>
</Position28> <Position17>
<Position29> <Filename Value="Units/MMLCore/window.pas"/>
<Filename Value="testunit.pas"/> <Caret Line="169" Column="16" TopLine="159"/>
<Caret Line="29" Column="5" TopLine="15"/> </Position17>
</Position29> <Position18>
<Position30> <Filename Value="Units/MMLCore/window.pas"/>
<Filename Value="project1.lpr"/> <Caret Line="170" Column="16" TopLine="159"/>
<Caret Line="13" Column="56" TopLine="1"/> </Position18>
</Position30> <Position19>
</JumpHistory> <Filename Value="Units/MMLCore/window.pas"/>
</ProjectOptions> <Caret Line="176" Column="14" TopLine="159"/>
<CompilerOptions> </Position19>
<Version Value="8"/> <Position20>
<SearchPaths> <Filename Value="Units/MMLCore/window.pas"/>
<IncludeFiles Value="$(ProjOutDir)/"/> <Caret Line="180" Column="17" TopLine="171"/>
<OtherUnitFiles Value="$(ProjPath)/Units/MMLCore/"/> </Position20>
</SearchPaths> <Position21>
<Linking> <Filename Value="Units/MMLCore/window.pas"/>
<Options> <Caret Line="181" Column="16" TopLine="171"/>
<Win32> </Position21>
<GraphicApplication Value="True"/> <Position22>
</Win32> <Filename Value="Units/MMLCore/window.pas"/>
</Options> <Caret Line="210" Column="16" TopLine="205"/>
</Linking> </Position22>
<Other> <Position23>
<CustomOptions Value="-dUseCThreads"/> <Filename Value="Units/MMLCore/window.pas"/>
<CompilerPath Value="$(CompPath)"/> <Caret Line="215" Column="10" TopLine="205"/>
</Other> </Position23>
</CompilerOptions> <Position24>
<Debugging> <Filename Value="Units/MMLCore/window.pas"/>
<Exceptions Count="3"> <Caret Line="225" Column="19" TopLine="215"/>
<Item1> </Position24>
<Name Value="EAbort"/> <Position25>
</Item1> <Filename Value="Units/MMLCore/window.pas"/>
<Item2> <Caret Line="239" Column="19" TopLine="229"/>
<Name Value="ECodetoolError"/> </Position25>
</Item2> <Position26>
<Item3> <Filename Value="Units/MMLCore/window.pas"/>
<Name Value="EFOpenError"/> <Caret Line="261" Column="17" TopLine="251"/>
</Item3> </Position26>
</Exceptions> <Position27>
</Debugging> <Filename Value="testunit.pas"/>
</CONFIG> <Caret Line="68" Column="20" TopLine="53"/>
</Position27>
<Position28>
<Filename Value="../Compilertje/Units/CogatUnits/compinput.pas"/>
<Caret Line="9" Column="20" TopLine="1"/>
</Position28>
<Position29>
<Filename Value="../Compilertje/Units/CogatUnits/compinput.pas"/>
<Caret Line="40" Column="52" TopLine="29"/>
</Position29>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="8"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)/"/>
<OtherUnitFiles Value="$(ProjPath)/Units/MMLCore/"/>
</SearchPaths>
<Other>
<CustomOptions Value="-dUseCThreads"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -1,20 +1,20 @@
object Form1: TForm1 object Form1: TForm1
Left = 293 Left = 966
Height = 516 Height = 527
Top = 200 Top = 461
Width = 779 Width = 779
ActiveControl = Button1 ActiveControl = Button1
Caption = 'Form1' Caption = 'Form1'
ClientHeight = 516 ClientHeight = 527
ClientWidth = 779 ClientWidth = 779
LCLVersion = '0.9.29' LCLVersion = '0.9.29'
object Button1: TButton object Button1: TButton
Left = 69 Left = 69
Height = 25 Height = 25
Top = 32 Top = 32
Width = 75 Width = 75
Caption = 'Button1' Caption = 'Button1'
OnClick = Button1Click OnClick = Button1Click
TabOrder = 0 TabOrder = 0
end end
end end

View File

@ -1,9 +1,9 @@
{ This is an automatically generated lazarus resource file } { This is an automatically generated lazarus resource file }
LazarusResources.Add('TForm1','FORMDATA',[ LazarusResources.Add('TForm1','FORMDATA',[
'TPF0'#6'TForm1'#5'Form1'#4'Left'#3'%'#1#6'Height'#3#4#2#3'Top'#3#200#0#5'Wid' 'TPF0'#6'TForm1'#5'Form1'#4'Left'#3#198#3#6'Height'#3#15#2#3'Top'#3#205#1#5'W'
+'th'#3#11#3#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'ClientHe' +'idth'#3#11#3#13'ActiveControl'#7#7'Button1'#7'Caption'#6#5'Form1'#12'Client'
+'ight'#3#4#2#11'ClientWidth'#3#11#3#10'LCLVersion'#6#6'0.9.29'#0#7'TButton'#7 +'Height'#3#15#2#11'ClientWidth'#3#11#3#10'LCLVersion'#6#6'0.9.29'#0#7'TButto'
+'Button1'#4'Left'#2'E'#6'Height'#2#25#3'Top'#2' '#5'Width'#2'K'#7'Caption'#6 +'n'#7'Button1'#4'Left'#2'E'#6'Height'#2#25#3'Top'#2' '#5'Width'#2'K'#7'Capti'
+#7'Button1'#7'OnClick'#7#12'Button1Click'#8'TabOrder'#2#0#0#0#0 +'on'#6#7'Button1'#7'OnClick'#7#12'Button1Click'#8'TabOrder'#2#0#0#0#0
]); ]);

View File

@ -1,113 +1,119 @@
unit TestUnit; unit TestUnit;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Client, MufasaTypes; StdCtrls, Client, MufasaTypes;
type type
{ TForm1 } { TForm1 }
TForm1 = class(TForm) TForm1 = class(TForm)
Button1: TButton; Button1: TButton;
procedure Button1Click(Sender: TObject); procedure Button1Click(Sender: TObject);
private private
{ private declarations } { private declarations }
public public
{ public declarations } { public declarations }
end; end;
var var
Form1: TForm1; Form1: TForm1;
implementation implementation
type type
TMyThread = class(TThread) TMyThread = class(TThread)
private private
protected protected
procedure Execute; override; procedure Execute; override;
public public
Constructor Create(CreateSuspended : boolean); Constructor Create(CreateSuspended : boolean);
end; end;
constructor TMyThread.Create(CreateSuspended : boolean); constructor TMyThread.Create(CreateSuspended : boolean);
begin begin
FreeOnTerminate := True; FreeOnTerminate := True;
inherited Create(CreateSuspended); inherited Create(CreateSuspended);
end; end;
procedure TMyThread.Execute; procedure TMyThread.Execute;
Var Var
Client: TClient; Client: TClient;
w,h, x, y, xx, yy:integer; w,h, x, y, xx, yy:integer;
bmp: TBitmap; bmp: TBitmap;
ptr: PRGB32; ptr: PRGB32;
begin begin
while (not Terminated) do while (not Terminated) do
begin begin
Client := TClient.Create;
Client.MWindow.GetDimensions(w, h); Writeln('Creating the client');
writeln(inttostr(w) + ' , ' + inttostr(h)); Client := TClient.Create;
Writeln('Getting the dimensions');
//Client.MWindow.SetTarget(77736320); Client.MWindow.GetDimensions(w, h);
writeln(inttostr(w) + ' , ' + inttostr(h));
bmp := Client.MWindow.CopyClientToBitmap(0, 0, w, h); Writeln('Setting target');
bmp.SaveToFile('/tmp/test.bmp'); Client.MWindow.SetTarget(132840,w_window);
bmp.Free; Client.MWindow.ActivateClient;
Client.MWindow.GetDimensions(w, h);
//Sleep(1000); Writeln('Copying BMP');
Client.MInput.GetMousePos(x, y); bmp := Client.MWindow.CopyClientToBitmap(0, 0, w, h);
writeln(inttostr(x) + ' , ' + inttostr(y)); bmp.SaveToFile('c:\test.bmp');
bmp.Free;
Client.MInput.SetMousePos(50, 50);
Client.MInput.GetMousePos(x, y); //Sleep(1000);
writeln(inttostr(x) + ' , ' + inttostr(y)); Client.MInput.GetMousePos(x, y);
writeln(inttostr(x) + ' , ' + inttostr(y));
Client.MInput.ClickMouse(60, 60, mouse_Right);
Client.MInput.SetMousePos(50, 50);
ptr := Client.MWindow.ReturnData(0, 0, w, h); Client.MInput.GetMousePos(x, y);
for yy := 0 to h - 1 do writeln(inttostr(x) + ' , ' + inttostr(y));
for xx := 0 to w - 1 do
begin Client.MInput.ClickMouse(60, 60, mouse_Right);
{ Do comparison here }
inc(ptr); ptr := Client.MWindow.ReturnData(0, 0, w, h);
end; for yy := 0 to h - 1 do
Client.MWindow.FreeReturnData; for xx := 0 to w - 1 do
begin
Client.MInput.IsMouseButtonDown(mouse_Left); { Do comparison here }
Sleep(1000); inc(ptr);
if Client.MInput.IsMouseButtonDown(mouse_Left) then end;
writeln('Left mouse is down!');
if Client.MInput.IsMouseButtonDown(mouse_Right) then Client.MWindow.FreeReturnData;
writeln('Right mouse is down!');
if Client.MInput.IsMouseButtonDown(mouse_Middle) then Client.MInput.IsMouseButtonDown(mouse_Left);
writeln('Middle mouse is down!'); Sleep(1000);
Client.Destroy; if Client.MInput.IsMouseButtonDown(mouse_Left) then
writeln('Test completed successfully'); writeln('Left mouse is down!');
break; if Client.MInput.IsMouseButtonDown(mouse_Right) then
end; writeln('Right mouse is down!');
end; if Client.MInput.IsMouseButtonDown(mouse_Middle) then
writeln('Middle mouse is down!');
Client.Destroy;
{ TForm1 } writeln('Test completed successfully');
break;
procedure TForm1.Button1Click(Sender: TObject); end;
Var end;
MyThread: TMyThread;
begin { TForm1 }
MyThread := TMyThread.Create(True);
MyThread.Resume; procedure TForm1.Button1Click(Sender: TObject);
end; Var
MyThread: TMyThread;
initialization
{$I testunit.lrs} begin
MyThread := TMyThread.Create(True);
end. MyThread.Resume;
end;
initialization
{$I testunit.lrs}
end.