minor fix.

This commit is contained in:
oscarl-2
2003-11-14 11:44:45 +00:00
parent 18f37bd113
commit 006b643af3
7 changed files with 508 additions and 513 deletions

View File

@@ -5,4 +5,4 @@ fi
ppc386 -FE./ -FU./units ./sources/main.pp -oBPDemo ppc386 -FE./ -FU./units ./sources/main.pp -oBPDemo
mergeres ./sources/Resource.rsrc BPDemo mergeres ./sources/Resource.rsrc BPDemo
mimeset BPCalculator mimeset BPDemo

View File

@@ -1,5 +1,5 @@
{ BePascal - A pascal wrapper around the BeOS API { BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere Copyright (C) 2002-2003 Olivier Coursiere
Eric Jourde Eric Jourde
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@@ -16,16 +16,15 @@
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
} }
unit Button_View;
unit button_view;
{$M+} {$M+}
interface interface
uses
classes,beobj, application, message, _beep, roster, SysUtils,interfacedefs,
archivable, handler, rect, window, view, graphicdefs, dataio,box,
invoker, messenger, Control, Button,listview,listitem,outlinelistview,common;
uses
Box, Button, GraphicDefs, InterfaceDefs, ListView, ListItem, Message,
OutlineListView, Rect, View,
Common;
type type
TButton_View = class(BView) TButton_View = class(BView)
@@ -40,17 +39,15 @@ type
outlineListView : BOutlineListView; outlineListView : BOutlineListView;
Box1 : BBox; Box1 : BBox;
Box2 : BBox; Box2 : BBox;
end; end;
implementation implementation
constructor TButton_View.Create(frame : BRect; name : PChar; resizingMode, flags : Cardinal); constructor TButton_View.Create(frame : BRect; name : PChar; resizingMode, flags : Cardinal);
Var var
aRect2 : BRect; aRect2 : BRect;
mess : BMessage; mess : BMessage;
rgb : RGB_color; rgb : RGB_color;
begin begin
inherited; inherited;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -89,15 +86,14 @@ begin
// ListView1 // ListView1
aRect2 := BRect.Create(10, 15, 120, 250); aRect2 := BRect.Create(10, 15, 120, 250);
ListView1 := BListView.create(aRect2,'toto', ListView1 := BListView.create(aRect2,'toto', B_SINGLE_SELECTION_LIST,
B_SINGLE_SELECTION_LIST,
B_FOLLOW_LEFT or B_FOLLOW_TOP, B_FOLLOW_LEFT or B_FOLLOW_TOP,
B_WILL_DRAW or B_NAVIGABLE or B_FRAME_EVENTS); B_WILL_DRAW or B_NAVIGABLE or B_FRAME_EVENTS);
Box1.AddChild(ListView1, nil); Box1.AddChild(ListView1, nil);
aRect2.Free; aRect2.Free;
{
{ ItemString := BStringItem.create('test 1',0,true); ItemString := BStringItem.create('test 1',0,true);
ListView1.AddItem(ItemString); ListView1.AddItem(ItemString);
ItemString := BStringItem.create('test 2',1,true); ItemString := BStringItem.create('test 2',1,true);
ListView1.AddItem(ItemString); ListView1.AddItem(ItemString);
@@ -121,7 +117,6 @@ begin
Box2.AddChild(outlineListView, nil); Box2.AddChild(outlineListView, nil);
aRect2.Free; aRect2.Free;
ItemString := BStringItem.create('test 1',0,true); ItemString := BStringItem.create('test 1',0,true);
outlineListView.AddItem(ItemString); outlineListView.AddItem(ItemString);
ItemString := BStringItem.create('test 1.1',1,true); ItemString := BStringItem.create('test 1.1',1,true);
@@ -134,8 +129,6 @@ begin
outlineListView.AddItem(ItemString); outlineListView.AddItem(ItemString);
ItemString := BStringItem.create('test 3',0,true); ItemString := BStringItem.create('test 3',0,true);
outlineListView.AddItem(ItemString); outlineListView.AddItem(ItemString);
end; end;
end. end.

View File

@@ -1,5 +1,7 @@
unit common; unit Common;
interface interface
const const
MSG_TEST_APP_BASE = 79000; MSG_TEST_APP_BASE = 79000;
MSG_BUTTON_BASE = MSG_TEST_APP_BASE + 100; MSG_BUTTON_BASE = MSG_TEST_APP_BASE + 100;
@@ -10,4 +12,5 @@ const
MSG_STATUSBAR_BASE = MSG_TEST_APP_BASE + 600; MSG_STATUSBAR_BASE = MSG_TEST_APP_BASE + 600;
implementation implementation
end. end.

View File

@@ -1,5 +1,5 @@
{ BePascal - A pascal wrapper around the BeOS API { BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere Copyright (C) 2002-2003 Olivier Coursiere
Eric Jourde Eric Jourde
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@@ -16,8 +16,7 @@
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
} }
unit Edit_View;
unit edit_view;
{$M+} {$M+}
interface interface
@@ -50,7 +49,7 @@ type
implementation implementation
constructor TEdit_View.Create(frame : BRect; name : PChar; resizingMode, flags : Cardinal); constructor TEdit_View.Create(frame : BRect; name : PChar; resizingMode, flags : Cardinal);
Var var
aRect2,aRect3 : BRect; aRect2,aRect3 : BRect;
mess : BMessage; mess : BMessage;
rgb : RGB_color; rgb : RGB_color;
@@ -149,7 +148,6 @@ begin
B_FOLLOW_LEFT or B_FOLLOW_TOP, B_WILL_DRAW or B_NAVIGABLE); B_FOLLOW_LEFT or B_FOLLOW_TOP, B_WILL_DRAW or B_NAVIGABLE);
Box4.AddChild(RadioButton4, nil); Box4.AddChild(RadioButton4, nil);
aRect2.Free; aRect2.Free;
end; end;
end. end.

View File

@@ -1,5 +1,5 @@
{ BePascal - A pascal wrapper around the BeOS API { BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere Copyright (C) 2002-2003 Olivier Coursiere
Eric Jourde Eric Jourde
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@@ -16,29 +16,23 @@
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
} }
program Main; program Main;
{$M+} {$M+}
uses uses
beobj, application, message, _beep, roster, SysUtils, Application, Message, Roster, Rect, Window,
archivable, handler, rect, window, view, graphicdefs, dataio, Main_Window;
invoker, messenger, Control, Button,stringview,textcontrol,checkbox,
main_window;
type type
TMonApplication = class(BApplication) TMonApplication = class(BApplication)
public public
procedure ReadyToRun; override; procedure ReadyToRun; override;
function QuitRequested : boolean; override; function QuitRequested : Boolean; override;
end; end;
function TMonApplication.QuitRequested : Boolean;
function TMonApplication.QuitRequested : boolean;
begin begin
Result := inherited; Result := inherited;
be_app.Free; be_app.Free;
@@ -59,11 +53,9 @@ begin
end; end;
var var
aRect : BRect; aRect : BRect;
win : TMyWindow; win : TMyWindow;
begin begin
TMonApplication.Create; TMonApplication.Create;
try try
@@ -78,5 +70,3 @@ begin
win.Free; win.Free;
end; end;
end. end.

View File

@@ -1,5 +1,5 @@
{ BePascal - A pascal wrapper around the BeOS API { BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere Copyright (C) 2002-2003 Olivier Coursiere
Eric Jourde Eric Jourde
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@@ -16,28 +16,23 @@
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
} }
unit Main_Window;
unit main_window;
interface interface
{$M+} {$M+}
uses uses
beobj, application, message, _beep, roster, SysUtils,appdefs, SysUtils,
archivable, handler, rect, window, view, graphicdefs, dataio, interfacedefs,textView,alert, Alert, InterfaceDefs, ListItem, Menu, Menubar, Message, Rect, StringView,
invoker, messenger, Control, Button,stringview,textcontrol,checkbox,TabView,listitem, TabView, View, Window,
menu, menubar, Common, Button_View, Edit_View, Other_View;
button_view,edit_view,common,other_view;
type
Type
TMyWindow = class(BWindow) TMyWindow = class(BWindow)
private private
aView : BView; aView : BView;
TabView : BTabView; TabView : BTabView;
Tab1 : BTab; Tab1 : BTab;
Tab2 : BTab; Tab2 : BTab;
public public
constructor Create(aFrame : BRect; title : PChar; atype, aFlags, aWorkspaces : Cardinal); override; constructor Create(aFrame : BRect; title : PChar; atype, aFlags, aWorkspaces : Cardinal); override;
destructor Destroy; override; destructor Destroy; override;
@@ -48,7 +43,8 @@ TMyWindow = class(BWindow)
VOther : TOther_View; VOther : TOther_View;
end; end;
Const Message1='Message : '; const
Message1 = 'Message : ';
implementation implementation
@@ -65,15 +61,14 @@ var
sepItem, sepItem2 : BSeparatorItem; sepItem, sepItem2 : BSeparatorItem;
item : BMenuItem; item : BMenuItem;
item1 : BMenuItem; item1 : BMenuItem;
begin begin
inherited; inherited;
try try
try try
// menu // menu
aRect2 := BRect.Create(0, 0, 300, 300); aRect2 := BRect.Create(0, 0, 300, 300);
menubar := BMenuBar.Create(aRect2, 'Bonjour', B_FOLLOW_LEFT_RIGHT or B_FOLLOW_TOP, B_ITEMS_IN_COLUMN, True); menubar := BMenuBar.Create(aRect2, 'Bonjour', B_FOLLOW_LEFT_RIGHT
or B_FOLLOW_TOP, B_ITEMS_IN_COLUMN, True);
AddChild(menubar, nil); AddChild(menubar, nil);
aRect2.Free; aRect2.Free;
Menu := BMenu.Create('File', B_ITEMS_IN_COLUMN); Menu := BMenu.Create('File', B_ITEMS_IN_COLUMN);
@@ -95,17 +90,16 @@ begin
// Show text Message // Show text Message
aRect:= BRect.Create(20, 400, 200, 420); aRect:= BRect.Create(20, 400, 200, 420);
Explain := BStringView.Create(aRect,'explain','Message : ',B_FOLLOW_LEFT or B_FOLLOW_TOP, B_WILL_DRAW or B_NAVIGABLE); Explain := BStringView.Create(aRect,'explain','Message : ', B_FOLLOW_LEFT
or B_FOLLOW_TOP, B_WILL_DRAW or B_NAVIGABLE);
aView.AddChild(Explain, nil); aView.AddChild(Explain, nil);
aRect.Free; aRect.Free;
// TabView // TabView
aRect := BRect.Create(20, 25, 700, 400); aRect := BRect.Create(20, 25, 700, 400);
TabView:=BTabview.Create(aRect,'test', TabView := BTabview.Create(aRect,'test', B_WIDTH_AS_USUAL, B_FOLLOW_TOP,
B_WIDTH_AS_USUAL, B_FULL_UPDATE_ON_RESIZE or B_WILL_DRAW or
B_FOLLOW_TOP, B_NAVIGABLE_JUMP or B_FRAME_EVENTS or B_NAVIGABLE);
B_FULL_UPDATE_ON_RESIZE or B_WILL_DRAW or B_NAVIGABLE_JUMP or B_FRAME_EVENTS or B_NAVIGABLE);
aView.AddChild(TabView, nil); aView.AddChild(TabView, nil);
aRect.Free; aRect.Free;
@@ -139,14 +133,11 @@ begin
TabView.AddTab(VOther, Tab1); TabView.AddTab(VOther, Tab1);
TabView.Select(0); TabView.Select(0);
finally finally
end; end;
finally finally
end; end;
end; end;
destructor TMyWindow.Destroy; destructor TMyWindow.Destroy;
@@ -154,66 +145,89 @@ begin
inherited; inherited;
end; end;
procedure TMyWindow.MessageReceived(aMessage : BMessage); procedure TMyWindow.MessageReceived(aMessage : BMessage);
Var S : String; var
p : pchar; S : String;
p : PChar;
Alert : BAlert; Alert : BAlert;
begin begin
inherited; inherited;
Case aMessage.what of case aMessage.what of
MSG_BUTTON_BASE+1 : Begin
MSG_BUTTON_BASE + 1 :
begin
Explain.SetText(Message1 + 'button 1 clic'); Explain.SetText(Message1 + 'button 1 clic');
End; end;
MSG_BUTTON_BASE+2 : Begin
MSG_BUTTON_BASE + 2 :
begin
Explain.SetText(Message1 + 'button Add Item click'); Explain.SetText(Message1 + 'button Add Item click');
VButton.ItemString := BStringItem.create('new Item', 0, true); VButton.ItemString := BStringItem.create('new Item', 0, true);
VButton.ListView1.AddItem(VButton.ItemString); VButton.ListView1.AddItem(VButton.ItemString);
End; end;
MSG_BUTTON_BASE+3 : Begin
MSG_BUTTON_BASE + 3 :
begin
Explain.SetText(Message1 + 'button Add OutlineListItem clic'); Explain.SetText(Message1 + 'button Add OutlineListItem clic');
VButton.ItemString := BStringItem.create('New Item', 0, true); VButton.ItemString := BStringItem.create('New Item', 0, true);
VButton.outlineListView.AddItem(VButton.ItemString); VButton.outlineListView.AddItem(VButton.ItemString);
End;
MSG_BUTTON_BASE+4 : Begin
VOther.StatusBar1.Update(10, nil, nil);
S:='Position: '+FloatToStr(VOther.StatusBar1.CurrentValue)+' \ '+FloatToStr(VOther.StatusBar1.MaxValue);
p:=stralloc(length(s)+1);
strpcopy(p,s);
VOther.Value.SetText(p);
strdispose(p);
End;
MSG_BUTTON_BASE+5 : Begin
VOther.StatusBar1.Update(-10, nil, nil);
S:='Position: '+FloatToStr(VOther.StatusBar1.CurrentValue)+' \ '+FloatToStr(VOther.StatusBar1.MaxValue);
p:=stralloc(length(s)+1);
strpcopy(p,s);
VOther.Value.SetText(p);
strdispose(p);
End;
MSG_BUTTON_BASE+6 : Begin
Alert:=BAlert.Create('Attention','You have request a alert ?','Help','Cancel','OK',B_WIDTH_AS_USUAL,B_WARNING_ALERT);
Alert.go;
End;
MSG_RADIOBUTTON_BASE + 1 : Begin
VEdit.Edit.setalignment(B_ALIGN_LEFT,B_ALIGN_LEFT);
End;
MSG_RADIOBUTTON_BASE + 2 : Begin
VEdit.Edit.setalignment(B_ALIGN_RIGHT,B_ALIGN_RIGHT);
End;
MSG_RADIOBUTTON_BASE + 3 : Begin
VEdit.Edit.SetEnabled(true);
End;
MSG_RADIOBUTTON_BASE + 4 : Begin
VEdit.Edit.SetEnabled(false);
End;
MSG_MENU_BASE +2 : Begin
quit;
End;
end; end;
MSG_BUTTON_BASE + 4 :
begin
VOther.StatusBar1.Update(10, nil, nil);
S := 'Position: ' + FloatToStr(VOther.StatusBar1.CurrentValue) + ' \ '
+ FloatToStr(VOther.StatusBar1.MaxValue);
p := stralloc(length(s) + 1);
strpcopy(p,s);
VOther.Value.SetText(p);
strdispose(p);
end;
MSG_BUTTON_BASE + 5 :
begin
VOther.StatusBar1.Update(-10, nil, nil);
S := 'Position: ' + FloatToStr(VOther.StatusBar1.CurrentValue) + ' \ '
+ FloatToStr(VOther.StatusBar1.MaxValue);
p := stralloc(length(s) + 1);
strpcopy(p,s);
VOther.Value.SetText(p);
strdispose(p);
end;
MSG_BUTTON_BASE + 6 :
begin
Alert := BAlert.Create('Attention','You have request a alert ?','Help',
'Cancel','OK', B_WIDTH_AS_USUAL, B_WARNING_ALERT);
Alert.go;
end;
MSG_RADIOBUTTON_BASE + 1 :
begin
VEdit.Edit.setalignment(B_ALIGN_LEFT,B_ALIGN_LEFT);
end;
MSG_RADIOBUTTON_BASE + 2 :
begin
VEdit.Edit.setalignment(B_ALIGN_RIGHT,B_ALIGN_RIGHT);
end;
MSG_RADIOBUTTON_BASE + 3 :
begin
VEdit.Edit.SetEnabled(true);
end;
MSG_RADIOBUTTON_BASE + 4 :
begin
VEdit.Edit.SetEnabled(false);
end;
MSG_MENU_BASE + 2 :
begin
Quit;
end;
end; // case
end; end;
end. end.

View File

@@ -1,5 +1,5 @@
{ BePascal - A pascal wrapper around the BeOS API { BePascal - A pascal wrapper around the BeOS API
Copyright (C) 2002 Olivier Coursiere Copyright (C) 2002-2003 Olivier Coursiere
Eric Jourde Eric Jourde
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
@@ -16,16 +16,15 @@
License along with this library; if not, write to the Free License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
} }
unit Other_View;
unit other_view;
{$M+} {$M+}
interface interface
uses
classes,beobj, application, message, _beep, roster, SysUtils,interfacedefs,
archivable, handler, rect, window, view, graphicdefs, dataio,box, scrollview,statusbar,button,stringview,
invoker, messenger, Control,textview,font,textcontrol,radiobutton,common;
uses
Box, Button, GraphicDefs, InterfaceDefs, Message, Rect, StatusBar,
Stringview, View,
Common;
type type
Tother_View = class(BView) Tother_View = class(BView)
@@ -44,11 +43,10 @@ type
implementation implementation
constructor Tother_View.Create(frame : BRect; name : PChar; resizingMode, flags : Cardinal); constructor Tother_View.Create(frame : BRect; name : PChar; resizingMode, flags : Cardinal);
Var var
aRect2, aRect3 : BRect; aRect2, aRect3 : BRect;
mess : BMessage; mess : BMessage;
rgb : RGB_color; rgb : RGB_color;
begin begin
inherited; inherited;
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
@@ -106,7 +104,6 @@ begin
Button3.SetViewColor(rgb); Button3.SetViewColor(rgb);
Box1.AddChild(Button3, nil); Box1.AddChild(Button3, nil);
aRect2.Free; aRect2.Free;
end; end;
end. end.