Working BFilePanel, BAlert and updated BApplication (see BPDemo project)

This commit is contained in:
ocoursiere
2004-01-11 17:58:47 +00:00
parent d0ed37202d
commit 66acd35741
6 changed files with 149 additions and 13 deletions

View File

@@ -50,6 +50,14 @@ class BPApplication : public BApplication, public BPLooper
virtual void DispatchMessage(BMessage *message, BHandler *target);
virtual void AppActivated_hookCall(bool active);
virtual void ReadyToRun_hookCall(void);
virtual void RefsReceived(BMessage *message);
virtual void RefsReceived_hookCall(BMessage *message);
virtual void AboutRequested(void);
virtual void AboutRequested_hookCall(void);
virtual void ArgvReceived(int32 argc, char **argv);
virtual void ArgvReceived_hookCall(int32 argc, char **argv);
virtual void Pulse(void);
virtual void Pulse_hookCall(void);
private:
};

View File

@@ -41,6 +41,10 @@
// definition of callback function in BApplication
typedef void (*BApplication_AppActivated_hook) (TPasObject PasObject, bool active);
typedef void (*BApplication_ReadyToRun_hook) (TPasObject PasObject);
typedef void (*BApplication_RefsReceived_hook) (TPasObject PasObject, BMessage *message);
typedef void (*BApplication_ArgvReceived_hook) (TPasObject PasObject, int32 argc, char **argv);
typedef void (*BApplication_AboutRequested_hook) (TPasObject PasObject);
typedef void (*BApplication_Pulse_hook) (TPasObject PasObject);
// typedef bool (*BApplication_QuitRequested_hook) (TPasObject PasObject);
// typedef void (*BApplication_MessageReceived_hook) (TPasObject PasObject, TCPlusObject message);
@@ -50,6 +54,10 @@ extern "C" {
BApplication_AppActivated_hook Application_AppActivated_hook;
BApplication_ReadyToRun_hook Application_ReadyToRun_hook;
BApplication_RefsReceived_hook Application_RefsReceived_hook;
BApplication_ArgvReceived_hook Application_ArgvReceived_hook;
BApplication_AboutRequested_hook Application_AboutRequested_hook;
BApplication_Pulse_hook Application_Pulse_hook;
//BApplication_QuitRequested_hook Application_QuitRequested_hook;
//BApplication_MessageReceived_hook Application_MessageReceived_hook;
@@ -118,6 +126,51 @@ void BPApplication::DispatchMessage(BMessage *message, BHandler *target)
BApplication::DispatchMessage(message, target);
}
void BPApplication::RefsReceived(BMessage *message)
{
RefsReceived_hookCall(message);
// message->PrintToStream();
BApplication::RefsReceived(message);
}
void BPApplication::RefsReceived_hookCall(BMessage *message)
{
Application_RefsReceived_hook(GetPasObject(), message);
}
void BPApplication::ArgvReceived(int32 argc, char **argv)
{
ArgvReceived_hookCall(argc, argv);
BApplication::ArgvReceived(argc, argv);
}
void BPApplication::ArgvReceived_hookCall(int32 argc, char **argv)
{
Application_ArgvReceived_hook(GetPasObject(), argc, argv);
}
void BPApplication::AboutRequested(void)
{
AboutRequested_hookCall();
BApplication::AboutRequested();
}
void BPApplication::AboutRequested_hookCall(void)
{
Application_AboutRequested_hook(GetPasObject());
}
void BPApplication::Pulse(void)
{
Pulse_hookCall();
BApplication::Pulse();
}
void BPApplication::Pulse_hookCall(void)
{
Application_Pulse_hook(GetPasObject());
}
#if defined(__cplusplus)
extern "C" {
#endif

View File

@@ -240,7 +240,8 @@ extern "C" {
*/
TCPlusObject BAlert_Create(TPasObject PasObject, const char *title, const char *text, const char *button1, const char *button2, const char *button3, button_width width, alert_type type)
{
return new BPAlert(PasObject, title, text, button1, button2, button3, width, type);
// return new BPAlert(PasObject, title, text, button1, button2, button3, width, type);
return new BAlert(title, text, button1, button2, button3, width, type);
}
@@ -251,7 +252,8 @@ TCPlusObject BAlert_Create(TPasObject PasObject, const char *title, const char *
TCPlusObject BAlert_Create_1
(TPasObject PasObject, const char *title, const char *text, const char *button1, const char *button2, const char *button3, button_width width, button_spacing spacing, alert_type type)
{
return new BPAlert(PasObject, title, text, button1, button2, button3, width, spacing, type);
// return new BPAlert(PasObject, title, text, button1, button2, button3, width, spacing, type);
return new BAlert(title, text, button1, button2, button3, width, spacing, type);
}
/*
@@ -260,7 +262,8 @@ TCPlusObject BAlert_Create_1
*/
TCPlusObject BAlert_Create_2(TPasObject PasObject, BMessage *data)
{
return new BPAlert(PasObject, data);
// return new BPAlert(PasObject, data);
return new BAlert(data);
}

View File

@@ -21,7 +21,7 @@ unit Application;
interface
uses
BeObj, Looper, OS, Roster, SupportDefs;
BeObj, Looper, OS, Roster, Message, SupportDefs;
type
BApplication = class(BLooper)
@@ -39,6 +39,10 @@ type
// Hook functions
procedure AppActivated(Active : Boolean); virtual;
procedure ReadyToRun; virtual;
procedure RefsReceived(aMessage : BMessage); virtual;
procedure ArgvReceived(argc : integer; argv : PPChar); virtual;
procedure AboutRequested; virtual;
procedure Pulse; virtual;
end;
function BApplication_Create(AObject : TObject) : TCPlusObject;
@@ -69,11 +73,15 @@ var
implementation
uses
Message, Messenger;
Messenger;
var
Application_AppActivated_hook : Pointer; cvar; external;
Application_ReadyToRun_hook : Pointer; cvar; external;
Application_RefsReceived_hook : Pointer; cvar; external;
Application_ArgvReceived_hook : Pointer; cvar; external;
Application_AboutRequested_hook : Pointer; cvar; external;
Application_Pulse_hook : Pointer; cvar; external;
// start BApplication
constructor BApplication.Create;
@@ -153,6 +161,37 @@ begin
end;
end;
procedure Application_RefsReceived_hook_func(Application : BApplication; aMessage : TCPlusObject); cdecl;
var
Message : BMessage;
begin
Message := BMessage.Wrap(aMessage);
try
if Application <> nil then
Application.RefsReceived(Message);
finally
Message.UnWrap;
end;
end;
procedure Application_AboutRequested_hook_func(Application : BApplication); cdecl;
begin
if Application <> nil then
Application.AboutRequested;
end;
procedure Application_ArgvReceived_hook_func(Application : BApplication; argc : integer; argv : PPChar); cdecl;
begin
if Application <> nil then
Application.ArgvReceived(argc, argv);
end;
procedure Application_Pulse_hook_func(Application : BApplication); cdecl;
begin
if Application <> nil then
Application.Pulse;
end;
procedure BApplication.ReadyToRun;
begin
{$IFDEF DEBUG}
@@ -160,6 +199,22 @@ begin
{$ENDIF}
end;
procedure BApplication.RefsReceived(aMessage : BMessage);
begin
end;
procedure BApplication.ArgvReceived(argc : integer; argv : PPChar);
begin
end;
procedure BApplication.AboutRequested;
begin
end;
procedure BApplication.Pulse;
begin
end;
procedure BApplication.ShowCursor;
begin
BApplication_ShowCursor(CPlusObject);
@@ -191,9 +246,17 @@ initialization
be_app := nil;
Application_AppActivated_hook := @Application_AppActivated_hook_func;
Application_ReadyToRun_hook := @Application_ReadyToRun_hook_func;
Application_RefsReceived_hook := @Application_RefsReceived_hook_func;
Application_AboutRequested_hook := @Application_AboutRequested_hook_func;
Application_ArgvReceived_hook := @Application_ArgvReceived_hook_func;
Application_Pulse_hook := @Application_Pulse_hook_func;
finalization
Application_AppActivated_hook := nil;
Application_ReadyToRun_hook := nil;
Application_RefsReceived_hook := nil;
Application_AboutRequested_hook := nil;
Application_ArgvReceived_hook := nil;
Application_Pulse_hook := nil;
be_app := nil;
end.
end.

View File

@@ -45,6 +45,7 @@ type
destructor UnWrap; virtual;
property CPlusObject : TCPlusObject read FCPlusObject write FCPlusObject;
end;
function GetCPlusObj(anObject : TBeObject) : TCPlusObject;
type
TSendTextProc = procedure(aText : string);
@@ -95,6 +96,14 @@ begin
Result := Longword(Num);
end;
function GetCPlusObj(anObject : TBeObject) : TCPlusObject;
begin
if Assigned(anObject) then
Result := anObject.CPlusObject
else
Result := nil;
end;
var
PasObject_GetPasClassName_hook : Pointer; cvar; external;
SendTextProc : TSendTextProc;
@@ -182,4 +191,4 @@ initialization
finalization
PasObject_GetPasClassName_hook := nil;
end.
end.

View File

@@ -25,7 +25,7 @@ uses
BeObj, Classes, OS, Entry, StorageDefs, Message, Messenger, Window, SupportDefs;
type
BRefFilter = class
BRefFilter = class(TBeObject)
private
public
procedure Filter;
@@ -79,10 +79,10 @@ type
procedure BRefFilter_Filter(AObject : TCPlusObject);
cdecl; external BePascalLibName name 'BRefFilter_Filter';
function BFilePanel_Create(AObject : TBeObject; mode : file_panel_mode; target : BMessenger;
function BFilePanel_Create(AObject : TBeObject; mode : file_panel_mode; target : TCPlusObject;
const start_directory : entry_ref; node_flavors : integer;
allow_multiple_selection : Boolean; message : BMessage;
filter : BRefFilter; modal, hide_when_done : Boolean)
allow_multiple_selection : Boolean; message : TCPlusObject;
filter : TCPlusObject; modal, hide_when_done : Boolean)
: TCPlusObject; cdecl; external BePascalLibName name 'BFilePanel_Create';
procedure BFilePanel_Free(AObject : TCPlusObject); cdecl; external BePascalLibName name 'BFilePanel_Free';
@@ -148,9 +148,9 @@ constructor BFilePanel.Create(mode : file_panel_mode; target : BMessenger;
hide_when_done : Boolean);
begin
CreatePas;
CPlusObject := BFilePanel_Create(Self, mode, target, start_directory,
CPlusObject := BFilePanel_Create(Self, mode, GetCPlusObj(target), start_directory,
node_flavors, allow_multiple_selection,
message, filter, modal, hide_when_done);
GetCPlusObj(message), GetCPlusObj(filter), modal, hide_when_done);
end;
destructor BFilePanel.Destroy;