Working BFilePanel, BAlert and updated BApplication (see BPDemo project)
This commit is contained in:
@@ -50,6 +50,14 @@ class BPApplication : public BApplication, public BPLooper
|
|||||||
virtual void DispatchMessage(BMessage *message, BHandler *target);
|
virtual void DispatchMessage(BMessage *message, BHandler *target);
|
||||||
virtual void AppActivated_hookCall(bool active);
|
virtual void AppActivated_hookCall(bool active);
|
||||||
virtual void ReadyToRun_hookCall(void);
|
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:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,10 @@
|
|||||||
// definition of callback function in BApplication
|
// definition of callback function in BApplication
|
||||||
typedef void (*BApplication_AppActivated_hook) (TPasObject PasObject, bool active);
|
typedef void (*BApplication_AppActivated_hook) (TPasObject PasObject, bool active);
|
||||||
typedef void (*BApplication_ReadyToRun_hook) (TPasObject PasObject);
|
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 bool (*BApplication_QuitRequested_hook) (TPasObject PasObject);
|
||||||
// typedef void (*BApplication_MessageReceived_hook) (TPasObject PasObject, TCPlusObject message);
|
// typedef void (*BApplication_MessageReceived_hook) (TPasObject PasObject, TCPlusObject message);
|
||||||
|
|
||||||
@@ -50,6 +54,10 @@ extern "C" {
|
|||||||
|
|
||||||
BApplication_AppActivated_hook Application_AppActivated_hook;
|
BApplication_AppActivated_hook Application_AppActivated_hook;
|
||||||
BApplication_ReadyToRun_hook Application_ReadyToRun_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_QuitRequested_hook Application_QuitRequested_hook;
|
||||||
//BApplication_MessageReceived_hook Application_MessageReceived_hook;
|
//BApplication_MessageReceived_hook Application_MessageReceived_hook;
|
||||||
|
|
||||||
@@ -118,6 +126,51 @@ void BPApplication::DispatchMessage(BMessage *message, BHandler *target)
|
|||||||
BApplication::DispatchMessage(message, 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)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -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)
|
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
|
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)
|
(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)
|
TCPlusObject BAlert_Create_2(TPasObject PasObject, BMessage *data)
|
||||||
{
|
{
|
||||||
return new BPAlert(PasObject, data);
|
// return new BPAlert(PasObject, data);
|
||||||
|
return new BAlert(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ unit Application;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
BeObj, Looper, OS, Roster, SupportDefs;
|
BeObj, Looper, OS, Roster, Message, SupportDefs;
|
||||||
|
|
||||||
type
|
type
|
||||||
BApplication = class(BLooper)
|
BApplication = class(BLooper)
|
||||||
@@ -39,6 +39,10 @@ type
|
|||||||
// Hook functions
|
// Hook functions
|
||||||
procedure AppActivated(Active : Boolean); virtual;
|
procedure AppActivated(Active : Boolean); virtual;
|
||||||
procedure ReadyToRun; virtual;
|
procedure ReadyToRun; virtual;
|
||||||
|
procedure RefsReceived(aMessage : BMessage); virtual;
|
||||||
|
procedure ArgvReceived(argc : integer; argv : PPChar); virtual;
|
||||||
|
procedure AboutRequested; virtual;
|
||||||
|
procedure Pulse; virtual;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function BApplication_Create(AObject : TObject) : TCPlusObject;
|
function BApplication_Create(AObject : TObject) : TCPlusObject;
|
||||||
@@ -69,11 +73,15 @@ var
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Message, Messenger;
|
Messenger;
|
||||||
|
|
||||||
var
|
var
|
||||||
Application_AppActivated_hook : Pointer; cvar; external;
|
Application_AppActivated_hook : Pointer; cvar; external;
|
||||||
Application_ReadyToRun_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
|
// start BApplication
|
||||||
constructor BApplication.Create;
|
constructor BApplication.Create;
|
||||||
@@ -153,6 +161,37 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
procedure BApplication.ReadyToRun;
|
||||||
begin
|
begin
|
||||||
{$IFDEF DEBUG}
|
{$IFDEF DEBUG}
|
||||||
@@ -160,6 +199,22 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
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;
|
procedure BApplication.ShowCursor;
|
||||||
begin
|
begin
|
||||||
BApplication_ShowCursor(CPlusObject);
|
BApplication_ShowCursor(CPlusObject);
|
||||||
@@ -191,9 +246,17 @@ initialization
|
|||||||
be_app := nil;
|
be_app := nil;
|
||||||
Application_AppActivated_hook := @Application_AppActivated_hook_func;
|
Application_AppActivated_hook := @Application_AppActivated_hook_func;
|
||||||
Application_ReadyToRun_hook := @Application_ReadyToRun_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
|
finalization
|
||||||
Application_AppActivated_hook := nil;
|
Application_AppActivated_hook := nil;
|
||||||
Application_ReadyToRun_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;
|
be_app := nil;
|
||||||
end.
|
end.
|
||||||
@@ -45,6 +45,7 @@ type
|
|||||||
destructor UnWrap; virtual;
|
destructor UnWrap; virtual;
|
||||||
property CPlusObject : TCPlusObject read FCPlusObject write FCPlusObject;
|
property CPlusObject : TCPlusObject read FCPlusObject write FCPlusObject;
|
||||||
end;
|
end;
|
||||||
|
function GetCPlusObj(anObject : TBeObject) : TCPlusObject;
|
||||||
|
|
||||||
type
|
type
|
||||||
TSendTextProc = procedure(aText : string);
|
TSendTextProc = procedure(aText : string);
|
||||||
@@ -95,6 +96,14 @@ begin
|
|||||||
Result := Longword(Num);
|
Result := Longword(Num);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetCPlusObj(anObject : TBeObject) : TCPlusObject;
|
||||||
|
begin
|
||||||
|
if Assigned(anObject) then
|
||||||
|
Result := anObject.CPlusObject
|
||||||
|
else
|
||||||
|
Result := nil;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
PasObject_GetPasClassName_hook : Pointer; cvar; external;
|
PasObject_GetPasClassName_hook : Pointer; cvar; external;
|
||||||
SendTextProc : TSendTextProc;
|
SendTextProc : TSendTextProc;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ uses
|
|||||||
BeObj, Classes, OS, Entry, StorageDefs, Message, Messenger, Window, SupportDefs;
|
BeObj, Classes, OS, Entry, StorageDefs, Message, Messenger, Window, SupportDefs;
|
||||||
|
|
||||||
type
|
type
|
||||||
BRefFilter = class
|
BRefFilter = class(TBeObject)
|
||||||
private
|
private
|
||||||
public
|
public
|
||||||
procedure Filter;
|
procedure Filter;
|
||||||
@@ -79,10 +79,10 @@ type
|
|||||||
|
|
||||||
procedure BRefFilter_Filter(AObject : TCPlusObject);
|
procedure BRefFilter_Filter(AObject : TCPlusObject);
|
||||||
cdecl; external BePascalLibName name 'BRefFilter_Filter';
|
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;
|
const start_directory : entry_ref; node_flavors : integer;
|
||||||
allow_multiple_selection : Boolean; message : BMessage;
|
allow_multiple_selection : Boolean; message : TCPlusObject;
|
||||||
filter : BRefFilter; modal, hide_when_done : Boolean)
|
filter : TCPlusObject; modal, hide_when_done : Boolean)
|
||||||
: TCPlusObject; cdecl; external BePascalLibName name 'BFilePanel_Create';
|
: TCPlusObject; cdecl; external BePascalLibName name 'BFilePanel_Create';
|
||||||
|
|
||||||
procedure BFilePanel_Free(AObject : TCPlusObject); cdecl; external BePascalLibName name 'BFilePanel_Free';
|
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);
|
hide_when_done : Boolean);
|
||||||
begin
|
begin
|
||||||
CreatePas;
|
CreatePas;
|
||||||
CPlusObject := BFilePanel_Create(Self, mode, target, start_directory,
|
CPlusObject := BFilePanel_Create(Self, mode, GetCPlusObj(target), start_directory,
|
||||||
node_flavors, allow_multiple_selection,
|
node_flavors, allow_multiple_selection,
|
||||||
message, filter, modal, hide_when_done);
|
GetCPlusObj(message), GetCPlusObj(filter), modal, hide_when_done);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor BFilePanel.Destroy;
|
destructor BFilePanel.Destroy;
|
||||||
|
|||||||
Reference in New Issue
Block a user