add user data parameter to addeventhandler, that is passed to the given callback

git-svn-id: trunk@8188 -
This commit is contained in:
micha 2005-11-18 18:56:30 +00:00
parent 66fe5731bf
commit c85ee92754
11 changed files with 28 additions and 15 deletions

View File

@ -26,7 +26,8 @@
}
//##apiwiz##sps## // Do not remove
procedure TWidgetSet.AddEventHandler(AHandle: THandle; AFlags: dword; AEventHandler: TWaitHandleEvent);
procedure TWidgetSet.AddEventHandler(AHandle: THandle; AFlags: dword;
AEventHandler: TWaitHandleEvent; AData: PtrInt);
begin
end;

View File

@ -33,9 +33,10 @@
******************************************************************************}
//##apiwiz##sps## // Do not remove
procedure AddEventHandler(AHandle: THandle; AFlags: dword; AEventHandler: TWaitHandleEvent);
procedure AddEventHandler(AHandle: THandle; AFlags: dword;
AEventHandler: TWaitHandleEvent; AData: PtrInt = 0);
begin
WidgetSet.AddEventHandler(AHandle, AFlags, AEventHandler);
WidgetSet.AddEventHandler(AHandle, AFlags, AEventHandler, AData);
end;
procedure AttachMenuToWindow(AMenuObject: TComponent);

View File

@ -37,7 +37,7 @@
******************************************************************************}
//##apiwiz##sps## // Do not remove
procedure AddEventHandler(AHandle: THandle; AFlags: dword; AEventHandler: TWaitHandleEvent); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure AddEventHandler(AHandle: THandle; AFlags: dword; AEventHandler: TWaitHandleEvent; AData: PtrInt); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure AttachMenuToWindow(AMenuObject: TComponent); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure CallDefaultWndHandler(Sender: TObject; var Message); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}

View File

@ -38,7 +38,7 @@ uses
type
TApplicationMainLoop = procedure of object;
TWaitHandleEvent = procedure(AHandle: THandle; AFlags: dword) of object;
TWaitHandleEvent = procedure(AData: PtrInt; AFlags: dword) of object;
{ TWidgetSet }

View File

@ -34,12 +34,12 @@ function waithandle_iocallback(source: PGIOChannel; condition: TGIOCondition;
var
lEventHandler: PWaitHandleEventHandler absolute data;
begin
lEventHandler^.OnEvent(lEventHandler^.Handle, condition);
lEventHandler^.OnEvent(lEventHandler^.UserData, condition);
result := true;
end;
procedure TGtkWidgetSet.AddEventHandler(AHandle: THandle; AFlags: dword;
AEventHandler: TWaitHandleEvent);
AEventHandler: TWaitHandleEvent; AData: PtrInt);
var
giochannel: pgiochannel;
lEventHandler: PWaitHandleEventHandler;
@ -48,6 +48,7 @@ begin
New(lEventHandler);
giochannel := g_io_channel_unix_new(AHandle);
lEventHandler^.Handle := AHandle;
lEventHandler^.UserData := AData;
lEventHandler^.GIOChannel := giochannel;
lEventHandler^.OnEvent := AEventHandler;
lEventHandler^.GSourceID := g_io_add_watch(giochannel,

View File

@ -29,7 +29,8 @@
}
//##apiwiz##sps## // Do not remove
procedure AddEventHandler(AHandle: THandle; AFlags: dword; AEventHandler: TWaitHandleEvent); override;
procedure AddEventHandler(AHandle: THandle; AFlags: dword;
AEventHandler: TWaitHandleEvent; AData: PtrInt); override;
function DrawSplitter(DC: HDC; const ARect: TRect; Horizontal: boolean): boolean; override;
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;

View File

@ -64,6 +64,7 @@ type
Handle: THandle;
GIOChannel: pgiochannel;
GSourceID: guint;
UserData: PtrInt;
OnEvent: TWaitHandleEvent;
NextHandler: PWaitHandleEventHandler;
end;

View File

@ -101,6 +101,11 @@ Type
dwICC: dword;
end;
TWaitHandler = record
UserData: PtrInt;
OnEvent: TWaitHandleEvent;
end;
{ Win32 interface-object class }
TWin32WidgetSet = Class(TWidgetSet)
Private
@ -124,7 +129,7 @@ Type
FWaitHandleCount: dword;
FWaitHandles: array of HANDLE;
FWaitHandleCallbacks: array of TWaitHandleEvent;
FWaitHandlers: array of TWaitHandler;
FThemesActive: boolean;
FThemeLibrary: HMODULE;

View File

@ -29,7 +29,8 @@
//##apiwiz##sps## // Do not remove
procedure TWin32WidgetSet.AddEventHandler(AHandle: THandle; AFlags: dword; AEventHandler: TWaitHandleEvent);
procedure TWin32WidgetSet.AddEventHandler(AHandle: THandle; AFlags: dword;
AEventHandler: TWaitHandleEvent; AData: PtrInt);
var
listlen: dword;
begin
@ -38,10 +39,11 @@ begin
begin
inc(listlen, 16);
SetLength(FWaitHandles, listlen);
SetLength(FWaitHandleCallbacks, listlen);
SetLength(FWaitHandlers, listlen);
end;
FWaitHandles[FWaitHandleCount] := AHandle;
FWaitHandleCallbacks[FWaitHandleCount] := AEventHandler;
FWaitHandlers[FWaitHandleCount].UserData := AData;
FWaitHandlers[FWaitHandleCount].OnEvent := AEventHandler;
Inc(FWaitHandleCount);
end;
@ -56,7 +58,7 @@ begin
if FWaitHandleCount >= 2 then
begin
FWaitHandles[I] := FWaitHandles[FWaitHandleCount-1];
FWaitHandleCallbacks[I] := FWaitHandleCallbacks[FWaitHandleCount-1];
FWaitHandlers[I] := FWaitHandlers[FWaitHandleCount-1];
end;
Dec(FWaitHandleCount);
exit;

View File

@ -29,7 +29,8 @@
//##apiwiz##sps## // Do not remove
procedure AddEventHandler(AHandle: THandle; AFlags: dword; AEventHandler: TWaitHandleEvent); override;
procedure AddEventHandler(AHandle: THandle; AFlags: dword;
AEventHandler: TWaitHandleEvent; AData: PtrInt); override;
procedure DrawArrow(Arrow: TComponent; Canvas: TPersistent); override;

View File

@ -335,7 +335,7 @@ begin
if (WAIT_OBJECT_0 <= retVal) and (retVal < WAIT_OBJECT_0 + FWaitHandleCount) then
begin
index := retVal-WAIT_OBJECT_0;
FWaitHandleCallbacks[index](FWaitHandles[index], 0);
FWaitHandlers[index].OnEvent(FWaitHandlers[index].UserData, 0);
end else if retVal = WAIT_OBJECT_0 + FWaitHandleCount then
done := true;
until done;