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 //##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 begin
end; end;

View File

@ -33,9 +33,10 @@
******************************************************************************} ******************************************************************************}
//##apiwiz##sps## // Do not remove //##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 begin
WidgetSet.AddEventHandler(AHandle, AFlags, AEventHandler); WidgetSet.AddEventHandler(AHandle, AFlags, AEventHandler, AData);
end; end;
procedure AttachMenuToWindow(AMenuObject: TComponent); procedure AttachMenuToWindow(AMenuObject: TComponent);

View File

@ -37,7 +37,7 @@
******************************************************************************} ******************************************************************************}
//##apiwiz##sps## // Do not remove //##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 AttachMenuToWindow(AMenuObject: TComponent); {$IFDEF IF_BASE_MEMBER}virtual;{$ENDIF}
procedure CallDefaultWndHandler(Sender: TObject; var Message); {$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 type
TApplicationMainLoop = procedure of object; TApplicationMainLoop = procedure of object;
TWaitHandleEvent = procedure(AHandle: THandle; AFlags: dword) of object; TWaitHandleEvent = procedure(AData: PtrInt; AFlags: dword) of object;
{ TWidgetSet } { TWidgetSet }

View File

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

View File

@ -29,7 +29,8 @@
} }
//##apiwiz##sps## // Do not remove //##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 DrawSplitter(DC: HDC; const ARect: TRect; Horizontal: boolean): boolean; override;
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;

View File

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

View File

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

View File

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

View File

@ -29,7 +29,8 @@
//##apiwiz##sps## // Do not remove //##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; 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 if (WAIT_OBJECT_0 <= retVal) and (retVal < WAIT_OBJECT_0 + FWaitHandleCount) then
begin begin
index := retVal-WAIT_OBJECT_0; 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 end else if retVal = WAIT_OBJECT_0 + FWaitHandleCount then
done := true; done := true;
until done; until done;