initial import into sourceforge
This commit is contained in:
166
begui/begui/imports/pascal/begui.pas
Normal file
166
begui/begui/imports/pascal/begui.pas
Normal file
@@ -0,0 +1,166 @@
|
||||
unit BeGUI;
|
||||
|
||||
{
|
||||
|
||||
$Header $
|
||||
|
||||
$Revision $
|
||||
|
||||
$Log $
|
||||
|
||||
}
|
||||
|
||||
interface
|
||||
|
||||
type
|
||||
MApplicationH = pointer;
|
||||
MFormH = pointer;
|
||||
MButtonH = pointer;
|
||||
MEditH = pointer;
|
||||
MPanelH = pointer;
|
||||
MMemoH = pointer;
|
||||
|
||||
uint32 = longword;
|
||||
int32 = longint;
|
||||
|
||||
var
|
||||
Application: MApplicationH;
|
||||
|
||||
type
|
||||
|
||||
base_Message = procedure (sender:pointer; msg:uint32);cdecl;
|
||||
mouseMoved_Message = procedure (sender:pointer; x:double; y:double; code:uint32; msg:uint32);cdecl;
|
||||
mouseAction_Message = procedure (sender:pointer; x:double; y:double);cdecl;
|
||||
keyAction_Message = procedure (sender:pointer; bytes:Pchar; numBytes:int32);cdecl;
|
||||
drawAction_Message = procedure (sender:pointer; left:double; top:double; right:double; bottom:double);cdecl;
|
||||
|
||||
const
|
||||
//Memson 30/03/2002 : changed this for FPC1.06 compatibility
|
||||
BEGUILIB = 'begui'; //must be in /boot/home/config/lib and /boot/develop/lib/x86
|
||||
|
||||
{$PACKRECORDS C}
|
||||
|
||||
|
||||
function MApplication_Create: MApplicationH; cdecl; external BEGUILIB;
|
||||
|
||||
procedure MApplication_Free(app:MApplicationH); cdecl; external BEGUILIB;
|
||||
|
||||
procedure MApplication_Run(app:MApplicationH); cdecl; external BEGUILIB;
|
||||
|
||||
function MApplication_GetMainForm(app:MApplicationH):MFormH; cdecl; external BEGUILIB;
|
||||
|
||||
function MApplication_AddForm(app:MApplicationH; left:double; top:double; right:double; bottom:double;
|
||||
name:Pchar; caption:Pchar):MFormH; cdecl; external BEGUILIB;
|
||||
|
||||
function MApplication_AddForm_int32(app:MApplicationH; left:int32; top:int32; right:int32; bottom:int32;
|
||||
name:Pchar; caption:Pchar):MFormH; cdecl; external BEGUILIB;
|
||||
|
||||
{added to get round fpc's inability to pass 'float' params...}
|
||||
|
||||
function MButton_Create_int32(left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MButtonH; external BEGUILIB;
|
||||
|
||||
function MForm_AddMEdit_int32(form:MFormH; left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MEditH; external BEGUILIB;
|
||||
|
||||
function MForm_AddMMemo_int32(form:MFormH; left:int32; top:int32; right:int32; bottom:int32; caption:Pchar):MMemoH; cdecl; external BEGUILIB;
|
||||
|
||||
function MForm_AddMPanel_int32(frm:MFormH; left:int32; top:int32; right:int32; bottom:int32; name:Pchar):MPanelH;cdecl; external BEGUILIB;
|
||||
|
||||
{form }
|
||||
procedure MForm_AddChild(form:MFormH; ctrl:pointer); cdecl; external BEGUILIB;
|
||||
|
||||
procedure MForm_AttachMouseMovedDispatcher(form:MFormH; msg:mouseMoved_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MForm_AttachMouseDownDispatcher(form:MFormH; msg:mouseAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MForm_AttachMouseUpDispatcher(form:MFormH; msg:mouseAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MForm_AttachKeyDownDispatcher(form:MFormH; msg:keyAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MForm_AttachKeyUpDispatcher(form:MFormH; msg:keyAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MForm_AttachDrawDispatcher(form:MFormH; msg:drawAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MForm_Show(frm:MFormH);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MForm_Hide(frm:MFormH);cdecl; external BEGUILIB;
|
||||
|
||||
{button }
|
||||
function MButton_Create(left:double; top:double; right:double; bottom:double; caption:Pchar):MButtonH;cdecl; external BEGUILIB;
|
||||
|
||||
procedure MButton_AttachClickDispatcher(btn:MButtonH; msg:base_Message);cdecl; external BEGUILIB;
|
||||
|
||||
function MButton_getCaption(btn:MButtonH):pchar;cdecl; external BEGUILIB;
|
||||
|
||||
procedure MButton_setCaption(btn:MButtonH; caption:Pchar);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MButton_AttachMouseMovedDispatcher(btn:MButtonH; msg:mouseMoved_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MButton_AttachMouseDownDispatcher(btn:MButtonH; msg:mouseAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MButton_AttachMouseUpDispatcher(btn:MButtonH; msg:mouseAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MButton_AttachKeyDownDispatcher(btn:MButtonH; msg:keyAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MButton_AttachKeyUpDispatcher(btn:MButtonH; msg:keyAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MButton_AttachDrawDispatcher(btn:MButtonH; msg:drawAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
{edit }
|
||||
function MForm_AddMEdit(form:MFormH; left:double; top:double; right:double; bottom:double;
|
||||
caption:Pchar):MEditH;cdecl; external BEGUILIB;
|
||||
|
||||
function MEdit_getText(edt:MEditH):Pchar;cdecl; external BEGUILIB;
|
||||
|
||||
procedure MEdit_setText(edt:MEditH; text:Pchar);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MEdit_AttachClickDispatcher(edt:MEditH; msg:base_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MEdit_AttachMouseMovedDispatcher(edt:MEditH; msg:mouseMoved_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MEdit_AttachMouseDownDispatcher(edt:MEditH; msg:mouseAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MEdit_AttachMouseUpDispatcher(edt:MEditH; msg:mouseAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MEdit_AttachKeyDownDispatcher(edt:MEditH; msg:keyAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MEdit_AttachKeyUpDispatcher(edt:MEditH; msg:keyAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MEdit_AttachDrawDispatcher(edt:MEditH; msg:drawAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
{memo }
|
||||
function MForm_AddMMemo(form:MFormH; left:double; top:double; right:double; bottom:double;
|
||||
caption:Pchar):MMemoH;cdecl; external BEGUILIB;
|
||||
|
||||
procedure MMemo_AttachMouseMovedDispatcher(memo:MMemoH; msg:mouseMoved_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MMemo_AttachMouseDownDispatcher(memo:MMemoH; msg:mouseAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MMemo_AttachMouseUpDispatcher(memo:MMemoH; msg:mouseAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MMemo_AttachKeyDownDispatcher(memo:MMemoH; msg:keyAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MMemo_AttachKeyUpDispatcher(memo:MMemoH; msg:keyAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
procedure MMemo_AttachDrawDispatcher(memo:MMemoH; msg:drawAction_Message);cdecl; external BEGUILIB;
|
||||
|
||||
{panel }
|
||||
function MForm_AddMPanel(frm:MFormH; left:double; top:double; right:double; bottom:double;
|
||||
name:Pchar):MPanelH;cdecl; external BEGUILIB;
|
||||
|
||||
{needed?? }
|
||||
function GetBaseMessage:uint32;cdecl; external BEGUILIB;
|
||||
|
||||
function GetNextMessage:uint32;cdecl; external BEGUILIB;
|
||||
|
||||
(* Const before type ignored *)
|
||||
procedure GenericAlert(message:Pchar);cdecl; external BEGUILIB;
|
||||
|
||||
procedure testfloat(f: integer);cdecl; external BEGUILIB;
|
||||
|
||||
implementation
|
||||
|
||||
initialization
|
||||
Application := MApplication_create;
|
||||
finalization
|
||||
MApplication_free(Application);
|
||||
end.
|
||||
3
begui/begui/imports/pascal/examples/build.sh
Normal file
3
begui/begui/imports/pascal/examples/build.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
fpc testapp.pas -Fu.. -Fl..
|
||||
fpc testapp3.pas -Fu.. -Fl..
|
||||
rm *.o
|
||||
31
begui/begui/imports/pascal/examples/testapp.pas
Normal file
31
begui/begui/imports/pascal/examples/testapp.pas
Normal file
@@ -0,0 +1,31 @@
|
||||
program TespApp;
|
||||
|
||||
uses BeGUI;
|
||||
|
||||
procedure EventTest(sender: pointer; msg: uint32);
|
||||
begin
|
||||
if sender <> nil then
|
||||
GenericAlert(MButton_getCaption(sender));
|
||||
end;
|
||||
|
||||
var
|
||||
TestMsg: array[0..10] of char;
|
||||
|
||||
Button1: MButtonH;
|
||||
Edit1: MEditH;
|
||||
MainForm: MFormH;
|
||||
a: integer;
|
||||
begin
|
||||
TestMsg := 'Test'#0;
|
||||
|
||||
MainForm := MApplication_GetMainForm(Application);
|
||||
|
||||
Button1 := MButton_Create_int32(10, 10, 50, 20, @TestMsg);
|
||||
MButton_AttachClickDispatcher(Button1, base_Message(@EventTest));
|
||||
|
||||
MForm_AddChild(MainForm, Button1);
|
||||
|
||||
Edit1 := MForm_AddMEdit_int32(MainForm, 30, 100, 150, 150, @TestMsg);
|
||||
|
||||
MApplication_Run(Application);
|
||||
end.
|
||||
305
begui/begui/imports/pascal/examples/testapp3.pas
Normal file
305
begui/begui/imports/pascal/examples/testapp3.pas
Normal file
@@ -0,0 +1,305 @@
|
||||
program TespApp3;
|
||||
|
||||
uses BeGUI, strings;
|
||||
|
||||
Var
|
||||
Calculator : MFormH;
|
||||
Button: Array[1..10] Of MButtonH;
|
||||
Button_Clear : MButtonH;
|
||||
Button_Point : MButtonH;
|
||||
Button_Egal : MButtonH;
|
||||
Button_Plus : MButtonH;
|
||||
Button_Minus : MButtonH;
|
||||
Button_Multi : MButtonH;
|
||||
Button_Divi : MButtonH;
|
||||
Edit: MEditH;
|
||||
Mem_Edit : String[20];
|
||||
Mem_Op : String[20];
|
||||
Mem_Operande : integer;
|
||||
|
||||
Calculator_Visible : Boolean;
|
||||
|
||||
Const
|
||||
Pos_X : Array[1..3] of integer=(10,50,90);
|
||||
Pos_Y : Array[1..4] of integer=(35,60,85,110);
|
||||
weith = 30;
|
||||
heigth = 10;
|
||||
|
||||
procedure EventTest(sender: pointer; msg: uint32);
|
||||
begin
|
||||
if sender <> nil then
|
||||
GenericAlert(MButton_getCaption(sender));
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Procedure EventButton(sender: pointer; msg: uint32);
|
||||
var
|
||||
Test: array[0..20] of char;
|
||||
value: char;
|
||||
value_real : real;
|
||||
value_real2: real;
|
||||
value_result: real;
|
||||
er : Integer;
|
||||
Begin
|
||||
If sender <> nil Then
|
||||
Begin
|
||||
value := strPas(MButton_getCaption(sender))[1];
|
||||
|
||||
// For digit
|
||||
If ( value ='1') Or ( value ='2') Or ( value ='3') or ( value ='4')
|
||||
or ( value ='5') Or ( value ='6') Or ( value ='7') or ( value ='8') or (value='9') or (value='0')Then
|
||||
Begin
|
||||
//=C2=A0Add Value to the sting
|
||||
Mem_Edit:=Mem_Edit+strPas(MButton_getCaption(sender));
|
||||
StrPCopy(test,Mem_Edit);
|
||||
MEdit_setText(Edit,Test);
|
||||
End;
|
||||
Val(Mem_Edit,value_real,er);
|
||||
// Clear
|
||||
if ( value='C') Then
|
||||
Begin
|
||||
Mem_Op:='';
|
||||
Mem_Operande:=0;
|
||||
Mem_Edit:='';
|
||||
MEdit_setText(Edit,nil);
|
||||
End;
|
||||
|
||||
// dot
|
||||
If (Value='.') Then
|
||||
Begin
|
||||
If (Frac(value_real) = 0) Then
|
||||
Begin
|
||||
Mem_Edit:=Mem_Edit+'.';
|
||||
StrPCopy(test,Mem_Edit);
|
||||
MEdit_setText(Edit,Test);
|
||||
End;
|
||||
End;
|
||||
|
||||
// Egal
|
||||
If (Value='=') Then
|
||||
Begin
|
||||
If (Mem_Op = '' ) Then
|
||||
Begin
|
||||
Str(value_real:6:2,Mem_Edit);
|
||||
End Else
|
||||
Begin
|
||||
Val(Mem_Op,value_real2,er);
|
||||
Case Mem_Operande of
|
||||
1 : Value_result:=value_real2+value_real;
|
||||
2 : Value_result:=value_real2-value_real;
|
||||
3 : Value_result:=value_real2*value_real;
|
||||
4 : Value_result:=value_real2/value_real;
|
||||
End;
|
||||
Str(value_result:6:2,Mem_Edit);
|
||||
End;
|
||||
StrPCopy(test,Mem_Edit);
|
||||
MEdit_setText(Edit,Test);
|
||||
End;
|
||||
|
||||
// Plus
|
||||
If (Value='+') Then
|
||||
Begin
|
||||
Mem_Op:=Mem_Edit;
|
||||
Mem_Operande:=1;
|
||||
Mem_Edit:='';
|
||||
StrPCopy(test,Mem_Edit);
|
||||
MEdit_setText(Edit,Test);
|
||||
End;
|
||||
|
||||
// Minus
|
||||
If (Value='-') Then
|
||||
Begin
|
||||
Mem_Op:=Mem_Edit;
|
||||
Mem_Operande:=2;
|
||||
Mem_Edit:='';
|
||||
StrPCopy(test,Mem_Edit);
|
||||
MEdit_setText(Edit,Test);
|
||||
End;
|
||||
|
||||
// Multi
|
||||
If (Value='*') Then
|
||||
Begin
|
||||
Mem_Op:=Mem_Edit;
|
||||
Mem_Operande:=3;
|
||||
Mem_Edit:='';
|
||||
StrPCopy(test,Mem_Edit);
|
||||
MEdit_setText(Edit,Test);
|
||||
End;
|
||||
|
||||
// Division
|
||||
If (Value='/') Then
|
||||
Begin
|
||||
Mem_Op:=Mem_Edit;
|
||||
Mem_Operande:=4;
|
||||
Mem_Edit:='';
|
||||
StrPCopy(test,Mem_Edit);
|
||||
MEdit_setText(Edit,Test);
|
||||
End;
|
||||
|
||||
End;
|
||||
End;
|
||||
|
||||
procedure Create_Calculator;
|
||||
var
|
||||
Edit1: MEditH;
|
||||
No_Button : Integer;
|
||||
Begin
|
||||
Mem_Edit:='';
|
||||
Mem_Op:='';
|
||||
Calculator_Visible:=false;
|
||||
{ create the form of the calculator }
|
||||
{ ??? - MApplication_AddForm don't take the value of size and position }
|
||||
Calculator := MApplication_AddForm_int32(Application,250, 100, 500, 300, pchar('Calculator'),pchar('Calculator'));
|
||||
|
||||
{ create the 9 digits of the calculator }
|
||||
{ it's make error if i used a array of MButtonH
|
||||
for No_Button:=1 to 9 Do
|
||||
Begin
|
||||
Button[No_Button] := MButton_Create_int32(10+(No_Button*10), 10, 50+(No_Button*10), 20, pchar('1'));
|
||||
{MButton_AttachClickDispatcher(Button1, base_Message(@EventTest));}
|
||||
MForm_AddChild(Calculator, Button[No_Button]);
|
||||
End;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Initialisation for the digit number
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Button[1] := MButton_Create_int32(Pos_X[1], Pos_Y[1], Pos_X[1]+weith, Pos_Y[1]+heigth, pchar('1'));
|
||||
MForm_AddChild(Calculator, Button[1]);
|
||||
MButton_AttachClickDispatcher(Button[1], base_Message(@EventButton));
|
||||
|
||||
Button[2] := MButton_Create_int32(Pos_X[2],Pos_Y[1], Pos_X[2]+weith, Pos_Y[1]+heigth, pchar('2'));
|
||||
MForm_AddChild(Calculator, Button[2]);
|
||||
MButton_AttachClickDispatcher(Button[2], base_Message(@EventButton));
|
||||
|
||||
Button[3] := MButton_Create_int32(Pos_X[3],Pos_Y[1], Pos_X[3]+weith, Pos_Y[1]+heigth, pchar('3'));
|
||||
MForm_AddChild(Calculator, Button[3]);
|
||||
MButton_AttachClickDispatcher(Button[3], base_Message(@EventButton));
|
||||
|
||||
Button[4] := MButton_Create_int32(Pos_X[1],Pos_Y[2], Pos_X[1]+weith, Pos_Y[2]+heigth, pchar('4'));
|
||||
MForm_AddChild(Calculator, Button[4]);
|
||||
MButton_AttachClickDispatcher(Button[4], base_Message(@EventButton));
|
||||
|
||||
Button[5] := MButton_Create_int32(Pos_X[2], Pos_Y[2], Pos_X[2]+weith, Pos_Y[2]+heigth, pchar('5'));
|
||||
MForm_AddChild(Calculator, Button[5]);
|
||||
MButton_AttachClickDispatcher(Button[5], base_Message(@EventButton));
|
||||
|
||||
Button[6] := MButton_Create_int32(Pos_X[3],Pos_Y[2], Pos_X[3]+weith, Pos_Y[2]+heigth, pchar('6'));
|
||||
MForm_AddChild(Calculator, Button[6]);
|
||||
MButton_AttachClickDispatcher(Button[6], base_Message(@EventButton));
|
||||
|
||||
Button[7] := MButton_Create_int32(Pos_X[1],Pos_Y[3], Pos_X[1]+weith, Pos_Y[3]+heigth, pchar('7'));
|
||||
MForm_AddChild(Calculator, Button[7]);
|
||||
MButton_AttachClickDispatcher(Button[7], base_Message(@EventButton));
|
||||
|
||||
Button[8] := MButton_Create_int32(Pos_X[2],Pos_Y[3], Pos_X[2]+weith, Pos_Y[3]+heigth, pchar('8'));
|
||||
MForm_AddChild(Calculator, Button[8]);
|
||||
MButton_AttachClickDispatcher(Button[8], base_Message(@EventButton));
|
||||
|
||||
Button[9] := MButton_Create_int32(Pos_X[3],Pos_Y[3], Pos_X[3]+weith, Pos_Y[3]+heigth, pchar('9'));
|
||||
MForm_AddChild(Calculator, Button[9]);
|
||||
MButton_AttachClickDispatcher(Button[9], base_Message(@EventButton));
|
||||
|
||||
Button[10] := MButton_Create_int32(Pos_X[1],Pos_Y[4], Pos_X[1]+weith, Pos_Y[4]+heigth, pchar('0'));
|
||||
MForm_AddChild(Calculator, Button[10]);
|
||||
MButton_AttachClickDispatcher(Button[10], base_Message(@EventButton));
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Initialisation for the edit
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Edit := MForm_AddMEdit_int32(Calculator, 9, 10, 160, 20, pchar('toto'));
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Initialisation for operation button
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Button_Clear:=MButton_Create_int32(170,10,190,20, pchar('C'));
|
||||
MForm_AddChild(Calculator, Button_clear);
|
||||
MButton_AttachClickDispatcher(Button_Clear, base_Message(@EventButton));
|
||||
|
||||
Button_Egal:=MButton_Create_int32(170,35,190,45, pchar('='));
|
||||
MForm_AddChild(Calculator, Button_Egal);
|
||||
MButton_AttachClickDispatcher(Button_Egal, base_Message(@EventButton));
|
||||
|
||||
Button_Plus:=MButton_Create_int32(170,60,190,65, pchar('+'));
|
||||
MForm_AddChild(Calculator, Button_Plus);
|
||||
MButton_AttachClickDispatcher(Button_Plus, base_Message(@EventButton));
|
||||
|
||||
Button_Minus:=MButton_Create_int32(170,85,190,95, pchar('-'));
|
||||
MForm_AddChild(Calculator, Button_Minus);
|
||||
MButton_AttachClickDispatcher(Button_Minus, base_Message(@EventButton));
|
||||
|
||||
Button_Multi:=MButton_Create_int32(170,110,190,120, pchar('*'));
|
||||
MForm_AddChild(Calculator, Button_Multi);
|
||||
MButton_AttachClickDispatcher(Button_Multi, base_Message(@EventButton));
|
||||
|
||||
Button_Divi:=MButton_Create_int32(170,135,190,145, pchar('/'));
|
||||
MForm_AddChild(Calculator, Button_Divi);
|
||||
MButton_AttachClickDispatcher(Button_Divi, base_Message(@EventButton));
|
||||
|
||||
Button_Point := MButton_Create_int32(Pos_X[2],Pos_Y[4], Pos_X[2]+weith, Pos_Y[4]+heigth, pchar('.'));
|
||||
MForm_AddChild(Calculator, Button_Point);
|
||||
MButton_AttachClickDispatcher(Button_Point, base_Message(@EventButton));
|
||||
|
||||
End;
|
||||
|
||||
procedure Show_Calculator;
|
||||
Begin
|
||||
MForm_Show(Calculator);
|
||||
Calculator_Visible:=true;
|
||||
End;
|
||||
|
||||
procedure Hide_Calculator;
|
||||
Begin
|
||||
MForm_Hide(Calculator);
|
||||
Calculator_Visible:=false;
|
||||
End;
|
||||
|
||||
Procedure End_Calculator;
|
||||
Begin
|
||||
End;
|
||||
|
||||
procedure Launch(sender: pointer; msg: uint32);
|
||||
begin
|
||||
if sender <> nil then
|
||||
Begin
|
||||
If Not Calculator_Visible Then Show_Calculator
|
||||
Else Hide_Calculator;
|
||||
End;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
var
|
||||
TestMsg: array[0..10] of char;
|
||||
|
||||
Button1: MButtonH;
|
||||
Launch_calc: MButtonH;
|
||||
Edit1: MEditH;
|
||||
MainForm: MFormH;
|
||||
i,a: integer;
|
||||
|
||||
|
||||
begin
|
||||
TestMsg := 'Test'#0;
|
||||
|
||||
MainForm := MApplication_GetMainForm(Application);
|
||||
|
||||
Button1 := MButton_Create_int32(10, 10, 50, 20, @TestMsg);
|
||||
MButton_AttachClickDispatcher(Button1, base_Message(@EventTest));
|
||||
MForm_AddChild(MainForm, Button1);
|
||||
|
||||
Launch_calc := MButton_Create_int32(10, 30, 100, 40, pchar('Calculator'));
|
||||
MButton_AttachClickDispatcher(Launch_calc, base_Message(@launch));
|
||||
MForm_AddChild(MainForm, Launch_calc);
|
||||
|
||||
|
||||
Edit1 := MForm_AddMEdit_int32(MainForm, 30, 100, 150, 150, @TestMsg);
|
||||
|
||||
|
||||
{ test for MDI}
|
||||
Create_Calculator;
|
||||
|
||||
MApplication_Run(Application);
|
||||
end.
|
||||
|
||||
530
begui/begui/libbegui/BeGuiAPI.cpp
Normal file
530
begui/begui/libbegui/BeGuiAPI.cpp
Normal file
@@ -0,0 +1,530 @@
|
||||
/*
|
||||
$Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiAPI.cpp,v 1.1.1.1 2002-03-31 10:36:07 memson Exp $
|
||||
|
||||
$Revision: 1.1.1.1 $
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.20 2002/03/28 08:41:02 memson
|
||||
|
||||
Commited to main tree by the above on behalf of :
|
||||
|
||||
2002/03/26 21:47:13 Jourde
|
||||
Adding MApplication_AddForm_int32 to create form with correct position (for
|
||||
Pascal)
|
||||
|
||||
Revision 1.19 2002/03/26 13:28:51 memson
|
||||
|
||||
added in combobox support - flawed at the moment.
|
||||
|
||||
Revision 1.18 2002/03/14 22:31:41 memson
|
||||
|
||||
Got the Menubar/menu/menuitem and popupmenu/menuitem both working... Had a
|
||||
bit of a slack night, so didn't really do much else.
|
||||
|
||||
Revision 1.17 2002/03/14 00:12:38 memson
|
||||
|
||||
Revised the event and property class hierarchies... hopefully makes more
|
||||
sense.
|
||||
|
||||
Started to add in the Menu functionality. PopUpMenu is done and 'tested',
|
||||
but the BMenuBar/BMenu (mainmenu) stuff is there but untested.
|
||||
|
||||
Added in an OnCreate and OnDestroy event to the events, plust a wierd
|
||||
offshoot class to handle the menuitem click.
|
||||
|
||||
Revision 1.16 2002/03/12 23:12:37 memson
|
||||
|
||||
hashed out some details - stopped child windows from screwing up app, and
|
||||
also added the close action to form and terminating functionality to the app.
|
||||
|
||||
Revision 1.15 2002/03/12 18:39:16 memson
|
||||
|
||||
Revision 1.14 2002/03/11 23:54:06 memson
|
||||
|
||||
the form works more happily, also sorted out form canvas issues.
|
||||
|
||||
lost hours of work pissing about with pascal - needs quite a bit of revision
|
||||
to get it happily working with fpc.
|
||||
|
||||
Revision 1.13 2002/03/11 23:22:11 memson
|
||||
|
||||
Revision 1.12 2002/03/03 11:31:38 memson
|
||||
|
||||
began adding a class to hold additional properties (Owner and Tag for now).
|
||||
|
||||
Revision 1.11 2002/02/19 17:49:53 memson
|
||||
|
||||
Added half arsed support for multiple windows - not working quite right yet,
|
||||
but at least they seem to 'work' in so much as they don't wipe the app out.
|
||||
The secondary forms Canvas is screwed up a little.. that is a priority I
|
||||
guess.
|
||||
|
||||
|
||||
Revision 1.10 2002/02/18 19:28:34 memson
|
||||
No *major* changes, cleaned things up a lot. Created MEventPlugin and now
|
||||
use multiple inheritence to implement most of the event pointer storage.
|
||||
This makes things a lot neater and also ensures that I don't have to write
|
||||
the same code loads of time (mostly).
|
||||
|
||||
Revision 1.9 2002/02/14 23:39:53 memson
|
||||
I've now added most of the events to the MButton, MCanvas, MMemo and MEdit..
|
||||
started a MPanel component. Again, the MCanvas is *not* tread safe!!!
|
||||
This means the calling thread must create it.
|
||||
|
||||
NB. Before I add much more functionality, I'm going to look at other GUI
|
||||
libs to see if there are any controls worth borrowing.
|
||||
|
||||
Next control will probably be a MLabel followed by a MMenuBar and MMenuItem.
|
||||
MForm will own a MMenuBar.
|
||||
|
||||
Revision 1.8 2002/02/14 20:33:19 memson
|
||||
Got the MButton OnClick, OnMouseDown/Up, OnKeyDown/Up and OnMouseMoved
|
||||
events working. Started to add the required code to the rest of the classes
|
||||
(should be a cut/paste job).
|
||||
|
||||
Revision 1.7 2002/02/14 14:00:16 memson
|
||||
fiddled a bit.. nothing major.
|
||||
|
||||
Revision 1.6 2002/02/13 23:26:25 memson
|
||||
Got the MMemo working.
|
||||
Got the MEdit working, including OnClick event signal
|
||||
Got the MButton working with a signal
|
||||
Added a few get/set accessor routined for captions/text.
|
||||
|
||||
Revision 1.5 2002/02/13 00:02:02 memson
|
||||
Got the MTextControl basic functionality - annoying fact is that a text
|
||||
control has to be added inside the thread that will display it!!!!
|
||||
|
||||
Revision 1.4 2002/02/12 19:40:59 memson
|
||||
Removed the Sender param for the MButton::DoClick()
|
||||
|
||||
Revision 1.3 2002/02/11 23:26:44 memson
|
||||
Revision 1.2 2002/01/17 20:32:54 memson
|
||||
|
||||
*/
|
||||
|
||||
#define BEGUI_EXPORTS 1
|
||||
|
||||
#define MENU_BAR_HEIGHT 36.0
|
||||
|
||||
#include "MList.h"
|
||||
#include "BeGuiAPI.h"
|
||||
#include <stdio.h>
|
||||
|
||||
//clik - control click
|
||||
#define ClickMessage 'clik'
|
||||
#define ChangeMessage 'chng'
|
||||
|
||||
#define TEXT_INSET 3.0
|
||||
|
||||
////////////////////////////////////////
|
||||
//
|
||||
// API routines...
|
||||
//
|
||||
////////////////////////////////////////
|
||||
|
||||
MApplication *M_App = 0;
|
||||
|
||||
MApplication* MApplication_Create(void){
|
||||
M_App = new MApplication();
|
||||
return M_App;
|
||||
}
|
||||
|
||||
void MApplication_Free(MApplication *app){
|
||||
app->Terminate();
|
||||
}
|
||||
|
||||
void MApplication_Run(MApplication *app){
|
||||
app->Run();
|
||||
}
|
||||
|
||||
MForm* MApplication_GetMainForm(MApplication *app){
|
||||
return app->GetMainForm();
|
||||
}
|
||||
|
||||
MForm* MApplication_AddForm(MApplication *app, float left, float top, float right, float bottom, char *name, char *caption){
|
||||
BRect ClientArea(left, top, right, bottom);
|
||||
return app->AddForm(ClientArea, BString(name), false);
|
||||
}
|
||||
|
||||
MForm* MApplication_AddForm_int32(MApplication *app, int32 left, int32 top, int32 right, int32 bottom, char *name, char *caption){
|
||||
BRect ClientArea(left, top, right, bottom);
|
||||
return app->AddForm(ClientArea, BString(name), false);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void MForm_AddChild(MForm *form, BControl *ctrl){
|
||||
form->Canvas()->AddChild(ctrl);
|
||||
ctrl->SetTarget(form);
|
||||
}
|
||||
|
||||
MEdit* MForm_AddMEdit(MForm *form, float left, float top, float right, float bottom, char *caption){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
return form->Canvas()->AddEdit(btnRect, caption);
|
||||
}
|
||||
|
||||
MEdit* MForm_AddMEdit_int32(MForm *form, int32 left, int32 top, int32 right, int32 bottom, char *caption){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
return form->Canvas()->AddEdit(btnRect, caption);
|
||||
}
|
||||
|
||||
MMemo* MForm_AddMMemo(MForm *form, float left, float top, float right, float bottom, char *caption){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
return form->Canvas()->AddMemo(btnRect, caption);
|
||||
}
|
||||
|
||||
MMemo* MForm_AddMMemo(MForm *form, int32 left, int32 top, int32 right, int32 bottom, char *caption){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
return form->Canvas()->AddMemo(btnRect, caption);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
BButton* BButton_Create(float left, float top, float right, float bottom, char *caption, uint32 msg){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
|
||||
return new BButton(btnRect, "testbutton", caption, new BMessage(msg));
|
||||
}
|
||||
|
||||
MButton* MButton_Create(float left, float top, float right, float bottom, char *caption){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
|
||||
return new MButton( btnRect, caption );
|
||||
}
|
||||
|
||||
MButton* MButton_Create_int32(int32 left, int32 top, int32 right, int32 bottom, char *caption){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
|
||||
return new MButton( btnRect, caption );
|
||||
}
|
||||
|
||||
void MButton_AttachClickDispatcher(MButton *btn, base_Message msg){
|
||||
btn->AttachClickDispatcher(msg);
|
||||
}
|
||||
|
||||
char* MButton_getCaption(MButton *btn){
|
||||
return const_cast<char*>(btn->Label());
|
||||
}
|
||||
|
||||
void MButton_setCaption(MButton *btn, char* caption){
|
||||
btn->SetLabel(caption);
|
||||
}
|
||||
|
||||
void MButton_AttachMouseMovedDispatcher(MButton *btn, mouseMoved_Message msg){
|
||||
btn->AttachMouseMovedDispatcher(msg);
|
||||
}
|
||||
|
||||
void MButton_AttachMouseDownDispatcher(MButton *btn, mouseAction_Message msg){
|
||||
btn->AttachMouseDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MButton_AttachMouseUpDispatcher(MButton *btn, mouseAction_Message msg){
|
||||
btn->AttachMouseUpDispatcher(msg);
|
||||
}
|
||||
|
||||
void MButton_AttachDrawDispatcher(MButton *btn, drawAction_Message msg){
|
||||
btn->AttachDrawDispatcher(msg);
|
||||
}
|
||||
|
||||
void MButton_AttachKeyDownDispatcher(MButton *btn, keyAction_Message msg){
|
||||
btn->AttachKeyDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MButton_AttachKeyUpDispatcher(MButton *btn, keyAction_Message msg){
|
||||
btn->AttachKeyUpDispatcher(msg);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
MCheckBox* MCheckBox_Create(float left, float top, float right, float bottom, char *caption){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
|
||||
return new MCheckBox( btnRect, caption );
|
||||
}
|
||||
|
||||
MCheckBox* MCheckBox_Create_int32(int32 left, int32 top, int32 right, int32 bottom, char *caption){
|
||||
BRect btnRect(left, top, right, bottom);
|
||||
|
||||
return new MCheckBox( btnRect, caption );
|
||||
}
|
||||
|
||||
char* MCheckBox_getCaption(MCheckBox *cbx){
|
||||
return const_cast<char*>(cbx->Label());
|
||||
}
|
||||
|
||||
void MCheckBox_setCaption(MCheckBox *cbx, char* caption){
|
||||
cbx->SetLabel(caption);
|
||||
}
|
||||
|
||||
void MCheckBox_AttachMouseMovedDispatcher(MCheckBox *cbx, mouseMoved_Message msg){
|
||||
cbx->AttachMouseMovedDispatcher(msg);
|
||||
}
|
||||
|
||||
void MCheckBox_AttachMouseDownDispatcher(MCheckBox *cbx, mouseAction_Message msg){
|
||||
cbx->AttachMouseDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MCheckBox_AttachMouseUpDispatcher(MCheckBox *cbx, mouseAction_Message msg){
|
||||
cbx->AttachMouseUpDispatcher(msg);
|
||||
}
|
||||
|
||||
void MCheckBox_AttachKeyDownDispatcher(MCheckBox *cbx, keyAction_Message msg){
|
||||
cbx->AttachKeyDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MCheckBox_AttachKeyUpDispatcher(MCheckBox *cbx, keyAction_Message msg){
|
||||
cbx->AttachKeyUpDispatcher(msg);
|
||||
}
|
||||
|
||||
void MCheckBox_AttachDrawDispatcher(MCheckBox *cbx, drawAction_Message msg){
|
||||
cbx->AttachDrawDispatcher(msg);
|
||||
}
|
||||
|
||||
bool MCheckBox_Checked(MCheckBox *cbx){
|
||||
return cbx->Checked();
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void MForm_AttachMouseMovedDispatcher(MForm *form, mouseMoved_Message msg){
|
||||
form->Canvas()->AttachMouseMovedDispatcher(msg);
|
||||
}
|
||||
|
||||
void MForm_AttachMouseDownDispatcher(MForm *form, mouseAction_Message msg){
|
||||
form->Canvas()->AttachMouseDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MForm_AttachMouseUpDispatcher(MForm *form, mouseAction_Message msg){
|
||||
form->Canvas()->AttachMouseUpDispatcher(msg);
|
||||
}
|
||||
|
||||
void MForm_AttachDrawDispatcher(MForm *form, drawAction_Message msg){
|
||||
form->Canvas()->AttachDrawDispatcher(msg);
|
||||
}
|
||||
|
||||
void MForm_AttachKeyDownDispatcher(MForm *form, keyAction_Message msg){
|
||||
form->Canvas()->AttachKeyDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MForm_AttachKeyUpDispatcher(MForm *form, keyAction_Message msg){
|
||||
form->Canvas()->AttachKeyUpDispatcher(msg);
|
||||
}
|
||||
|
||||
void MForm_Show(MForm *frm){
|
||||
printf("about to lock\n");
|
||||
if (frm->Lock()) {
|
||||
frm->Show();
|
||||
printf("after show\n");
|
||||
frm->Unlock();
|
||||
printf("unlocked\n");
|
||||
}
|
||||
else printf("lock failed\n");
|
||||
}
|
||||
|
||||
void MForm_Hide(MForm *frm){
|
||||
frm->Hide();
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void MEdit_AttachClickDispatcher(MEdit *edt, base_Message msg){
|
||||
edt->AttachClickDispatcher(msg);
|
||||
}
|
||||
|
||||
void MEdit_AttachMouseMovedDispatcher(MEdit *edt, mouseMoved_Message msg){
|
||||
edt->AttachMouseMovedDispatcher(msg);
|
||||
}
|
||||
|
||||
void MEdit_AttachMouseDownDispatcher(MEdit *edt, mouseAction_Message msg){
|
||||
edt->AttachMouseDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MEdit_AttachMouseUpDispatcher(MEdit *edt, mouseAction_Message msg){
|
||||
edt->AttachMouseUpDispatcher(msg);
|
||||
}
|
||||
|
||||
void MEdit_AttachDrawDispatcher(MEdit *edt, drawAction_Message msg){
|
||||
edt->AttachDrawDispatcher(msg);
|
||||
}
|
||||
|
||||
void MEdit_AttachKeyDownDispatcher(MEdit *edt, keyAction_Message msg){
|
||||
edt->AttachKeyDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MEdit_AttachKeyUpDispatcher(MEdit *edt, keyAction_Message msg){
|
||||
edt->AttachKeyUpDispatcher(msg);
|
||||
}
|
||||
|
||||
char* MEdit_getText(MEdit* edt){
|
||||
return const_cast<char*>(edt->Text());
|
||||
}
|
||||
|
||||
void MEdit_setText(MEdit* edt, char* text){
|
||||
edt->SetText(text);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void MMemo_AttachMouseMovedDispatcher(MMemo *memo, mouseMoved_Message msg){
|
||||
memo->AttachMouseMovedDispatcher(msg);
|
||||
}
|
||||
|
||||
void MMemo_AttachMouseDownDispatcher(MMemo *memo, mouseAction_Message msg){
|
||||
memo->AttachMouseDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MMemo_AttachMouseUpDispatcher(MMemo *memo, mouseAction_Message msg){
|
||||
memo->AttachMouseUpDispatcher(msg);
|
||||
}
|
||||
|
||||
void MMemo_AttachDrawDispatcher(MMemo *memo, drawAction_Message msg){
|
||||
memo->AttachDrawDispatcher(msg);
|
||||
}
|
||||
|
||||
void MMemo_AttachKeyDownDispatcher(MMemo *memo, keyAction_Message msg){
|
||||
memo->AttachKeyDownDispatcher(msg);
|
||||
}
|
||||
|
||||
void MMemo_AttachKeyUpDispatcher(MMemo *memo, keyAction_Message msg){
|
||||
memo->AttachKeyDownDispatcher(msg);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
MCheckBox* MForm_AddMCheckBox(MForm* frm, float left, float top, float right, float bottom, char *name){
|
||||
BRect cbxRect(left, top, right, bottom);
|
||||
|
||||
return frm->Canvas()->AddCheckBox( cbxRect, name );
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
MPanel* MForm_AddMPanel(MForm* frm, float left, float top, float right, float bottom, char *name){
|
||||
BRect pnlRect(left, top, right, bottom);
|
||||
|
||||
return frm->Canvas()->AddPanel( pnlRect, name );
|
||||
}
|
||||
|
||||
MPanel* MForm_AddMPanel_int32(MForm* frm, int32 left, int32 top, int32 right, int32 bottom, char *name){
|
||||
BRect pnlRect(left, top, right, bottom);
|
||||
|
||||
return frm->Canvas()->AddPanel( pnlRect, name );
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void MForm_AddPopUpMenu(MForm *frm, MPopUpMenu *mni){
|
||||
frm->Lock();
|
||||
frm->Canvas()->setPopUpMenu(mni);
|
||||
frm->Unlock();
|
||||
}
|
||||
|
||||
MPopUpMenu* MPopUpMenu_Create(const char *name){
|
||||
return new MPopUpMenu(name);
|
||||
}
|
||||
|
||||
void MPopUpMenu_AddItem(MPopUpMenu *mnu, MMenuItem *itm){
|
||||
mnu->AddItem(dynamic_cast<BMenuItem*>(itm));
|
||||
}
|
||||
|
||||
MMenuItem* MMenuItem_Create(const char *name)
|
||||
{
|
||||
return new MMenuItem(name);
|
||||
}
|
||||
|
||||
void MMenuItem_AttachMenuClickDispatcher(MMenuItem *mni, base_Message msg)
|
||||
{
|
||||
mni->AttachMenuClickDispatcher(msg);
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
BMenuBar* BMenuBar_Create(MForm* frm, const char *name)
|
||||
{
|
||||
//BRect frame;
|
||||
//frame.Set(0, MENU_BAR_HEIGHT, frm->Bounds().right, frm->Bounds().bottom + MENU_BAR_HEIGHT);
|
||||
BRect menuBarRect;
|
||||
menuBarRect.Set(0.0, 0.0, 32000.0, MENU_BAR_HEIGHT);
|
||||
BMenuBar *mb = new BMenuBar(menuBarRect, "mainmenubar");
|
||||
frm->Lock();
|
||||
frm->ResizeBy(0.0, MENU_BAR_HEIGHT);
|
||||
frm->Canvas()->AddChild(mb);
|
||||
frm->Unlock();
|
||||
return mb;
|
||||
}
|
||||
|
||||
void BMenuBar_AddItem(BMenuBar *mnu, BMenu *itm)
|
||||
{
|
||||
mnu->AddItem(itm);
|
||||
}
|
||||
|
||||
BMenu* BMenu_Create(const char *name)
|
||||
{
|
||||
return new BMenu(name);
|
||||
}
|
||||
|
||||
void BMenu_AddItem(BMenu *mnu, MMenuItem *itm)
|
||||
{
|
||||
mnu->AddItem(itm);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
//utility
|
||||
|
||||
uint32 _BASE_MESSAGE = 0;
|
||||
|
||||
uint32 GetNextMessage(void){
|
||||
if (_BASE_MESSAGE == 0){
|
||||
_BASE_MESSAGE = GetBaseMessage();
|
||||
}
|
||||
return _BASE_MESSAGE++;
|
||||
}
|
||||
|
||||
uint32 GetBaseMessage(void){
|
||||
return 'bgui';
|
||||
}
|
||||
|
||||
void GenericAlert(const char *message){
|
||||
BAlert *alert;
|
||||
|
||||
alert = new BAlert("Info", message, "OK");
|
||||
alert->Go();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
|
||||
//Test the API
|
||||
int test(void)
|
||||
{
|
||||
return 33;
|
||||
}
|
||||
|
||||
//Private Local var for test
|
||||
CTest* FTest;
|
||||
|
||||
//Init the test class
|
||||
CTest* CTest_Create(void){
|
||||
FTest = new CTest();
|
||||
return FTest;
|
||||
}
|
||||
|
||||
//GetValue
|
||||
int CTest_GetValue(CTest* ptr){
|
||||
int ReturnValue;
|
||||
ReturnValue = ptr->GetValue();
|
||||
return ReturnValue;
|
||||
}
|
||||
|
||||
//SetValue
|
||||
void CTest_SetValue(CTest* ptr, int val){
|
||||
ptr->SetValue(val);
|
||||
}
|
||||
|
||||
//Destroy the variable
|
||||
void CTest_Free(CTest* ptr){
|
||||
delete &ptr;
|
||||
}
|
||||
|
||||
|
||||
143
begui/begui/libbegui/BeGuiAPI.h
Normal file
143
begui/begui/libbegui/BeGuiAPI.h
Normal file
@@ -0,0 +1,143 @@
|
||||
#ifndef BEGUIAPI_H
|
||||
#define BEGUIAPI_H
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
#include <Control.h>
|
||||
#include <Button.h>
|
||||
#include <TextControl.h>
|
||||
#include <ScrollView.h>
|
||||
#include <Rect.h>
|
||||
#include <String.h>
|
||||
#include <Message.h>
|
||||
#include <Alert.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <MenuBar.h>
|
||||
#include "MList.h"
|
||||
#include "BeGuiClasses.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef void (*base_Message)(void* sender, uint32 msg); //callback event
|
||||
typedef void (*mouseMoved_Message)(void* sender, float x, float y, uint32 code, uint32 msg);
|
||||
typedef void (*mouseAction_Message)(void* sender, float x, float y);
|
||||
typedef void (*keyAction_Message)(void* sender, const char *bytes, int32 numBytes);
|
||||
typedef void (*drawAction_Message)(void* sender, float left, float top, float right, float bottom);
|
||||
|
||||
//Exports...
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int test(void);
|
||||
CTest* CTest_Create(void);
|
||||
int CTest_GetValue(CTest* ptr);
|
||||
void CTest_Free(CTest* ptr);
|
||||
void CTest_SetValue(CTest* ptr, int val);
|
||||
|
||||
//application
|
||||
MApplication* MApplication_Create(void);
|
||||
void MApplication_Free(MApplication *app);
|
||||
void MApplication_Run(MApplication *app);
|
||||
MForm* MApplication_GetMainForm(MApplication *app);
|
||||
MForm* MApplication_AddForm(MApplication *app, float left, float top, float right, float bottom, char *name, char *caption);
|
||||
//eric 27/03/2002
|
||||
MForm* MApplication_AddForm_int32(MApplication *app, int32 left, int32 top, int32 right, int32 bottom, char *name, char *caption);
|
||||
|
||||
//form
|
||||
void MForm_AddChild(MForm *form, BControl* ctrl);
|
||||
void MForm_AttachMouseMovedDispatcher(MForm *form, mouseMoved_Message msg);
|
||||
void MForm_AttachMouseDownDispatcher(MForm *form, mouseAction_Message msg);
|
||||
void MForm_AttachMouseUpDispatcher(MForm *form, mouseAction_Message msg);
|
||||
void MForm_AttachKeyDownDispatcher(MForm *form, keyAction_Message msg);
|
||||
void MForm_AttachKeyUpDispatcher(MForm *form, keyAction_Message msg);
|
||||
void MForm_AttachDrawDispatcher(MForm *form, drawAction_Message msg);
|
||||
void MForm_Show(MForm *frm);
|
||||
void MForm_Hide(MForm *frm);
|
||||
void MForm_AddPopUpMenu(MForm *frm, MPopUpMenu *mni);
|
||||
|
||||
//button
|
||||
MButton* MButton_Create(float left, float top, float right, float bottom, char *caption);
|
||||
MButton* MButton_Create_int32(int32 left, int32 top, int32 right, int32 bottom, char *caption);
|
||||
void MButton_AttachClickDispatcher(MButton *btn, base_Message msg);
|
||||
char* MButton_getCaption(MButton *btn);
|
||||
void MButton_setCaption(MButton *btn, char* caption);
|
||||
void MButton_AttachMouseMovedDispatcher(MButton *btn, mouseMoved_Message msg);
|
||||
void MButton_AttachMouseDownDispatcher(MButton *btn, mouseAction_Message msg);
|
||||
void MButton_AttachMouseUpDispatcher(MButton *btn, mouseAction_Message msg);
|
||||
void MButton_AttachKeyDownDispatcher(MButton *btn, keyAction_Message msg);
|
||||
void MButton_AttachKeyUpDispatcher(MButton *btn, keyAction_Message msg);
|
||||
void MButton_AttachDrawDispatcher(MButton *btn, drawAction_Message msg);
|
||||
|
||||
//edit
|
||||
MEdit* MForm_AddMEdit(MForm *form, float left, float top, float right, float bottom, char *caption);
|
||||
MEdit* MForm_AddMEdit_int32(MForm *form, int32 left, int32 top, int32 right, int32 bottom, char *caption);
|
||||
char* MEdit_getText(MEdit* edt);
|
||||
void MEdit_setText(MEdit* edt, char* text);
|
||||
void MEdit_AttachClickDispatcher(MEdit *edt, base_Message msg);
|
||||
void MEdit_AttachMouseMovedDispatcher(MEdit *edt, mouseMoved_Message msg);
|
||||
void MEdit_AttachMouseDownDispatcher(MEdit *edt, mouseAction_Message msg);
|
||||
void MEdit_AttachMouseUpDispatcher(MEdit *edt, mouseAction_Message msg);
|
||||
void MEdit_AttachKeyDownDispatcher(MEdit *edt, keyAction_Message msg);
|
||||
void MEdit_AttachKeyUpDispatcher(MEdit *edt, keyAction_Message msg);
|
||||
void MEdit_AttachDrawDispatcher(MEdit *edt, drawAction_Message msg);
|
||||
|
||||
//memo
|
||||
MMemo* MForm_AddMMemo(MForm *form, float left, float top, float right, float bottom, char *caption);
|
||||
MMemo* MForm_AddMMemo_int32(MForm *form, int32 left, int32 top, int32 right, int32 bottom, char *caption);
|
||||
void MMemo_AttachMouseMovedDispatcher(MMemo *memo, mouseMoved_Message msg);
|
||||
void MMemo_AttachMouseDownDispatcher(MMemo *memo, mouseAction_Message msg);
|
||||
void MMemo_AttachMouseUpDispatcher(MMemo *memo, mouseAction_Message msg);
|
||||
void MMemo_AttachKeyDownDispatcher(MMemo *memo, keyAction_Message msg);
|
||||
void MMemo_AttachKeyUpDispatcher(MMemo *memo, keyAction_Message msg);
|
||||
void MMemo_AttachDrawDispatcher(MMemo *memo, drawAction_Message msg);
|
||||
|
||||
//panel
|
||||
MPanel* MForm_AddMPanel(MForm* frm, float left, float top, float right, float bottom, char *name);
|
||||
MPanel* MForm_AddMPanel_int32(MForm* frm, int32 left, int32 top, int32 right, int32 bottom, char *name);
|
||||
|
||||
//popupmenu
|
||||
MPopUpMenu* MPopUpMenu_Create(const char *name);
|
||||
void MPopUpMenu_AddItem(MPopUpMenu *mnu, MMenuItem *itm);
|
||||
|
||||
//menuitem
|
||||
MMenuItem* MMenuItem_Create(const char *name);
|
||||
void MMenuItem_AttachMenuClickDispatcher(MMenuItem *mni, base_Message msg);
|
||||
|
||||
//menubar
|
||||
BMenuBar* BMenuBar_Create(MForm* frm, const char *name);
|
||||
void BMenuBar_AddItem(BMenuBar *mnu, BMenu *itm);
|
||||
|
||||
//BMenu
|
||||
BMenu* BMenu_Create(const char *name);
|
||||
void BMenu_AddItem(BMenu *mnu, MMenuItem *itm);
|
||||
|
||||
//checkbox
|
||||
MCheckBox* MCheckBox_Create(float left, float top, float right, float bottom, char *caption);
|
||||
MCheckBox* MCheckBox_Create_int32(int32 left, int32 top, int32 right, int32 bottom, char *caption);
|
||||
MCheckBox* MForm_AddMCheckBox(MForm* frm, float left, float top, float right, float bottom, char *name);
|
||||
char* MCheckBox_getCaption(MCheckBox *cbx);
|
||||
void MCheckBox_setCaption(MCheckBox *cbx, char* caption);
|
||||
void MCheckBox_AttachMouseMovedDispatcher(MCheckBox *cbx, mouseMoved_Message msg);
|
||||
void MCheckBox_AttachMouseDownDispatcher(MCheckBox *cbx, mouseAction_Message msg);
|
||||
void MCheckBox_AttachMouseUpDispatcher(MCheckBox *cbx, mouseAction_Message msg);
|
||||
void MCheckBox_AttachKeyDownDispatcher(MCheckBox *cbx, keyAction_Message msg);
|
||||
void MCheckBox_AttachKeyUpDispatcher(MCheckBox *cbx, keyAction_Message msg);
|
||||
void MCheckBox_AttachDrawDispatcher(MCheckBox *cbx, drawAction_Message msg);
|
||||
bool MCheckBox_Checked(MCheckBox *cbx);
|
||||
|
||||
//needed??
|
||||
uint32 GetBaseMessage(void);
|
||||
uint32 GetNextMessage(void);
|
||||
void GenericAlert(const char *message);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
1192
begui/begui/libbegui/BeGuiClasses.cpp
Normal file
1192
begui/begui/libbegui/BeGuiClasses.cpp
Normal file
File diff suppressed because it is too large
Load Diff
336
begui/begui/libbegui/BeGuiClasses.h
Normal file
336
begui/begui/libbegui/BeGuiClasses.h
Normal file
@@ -0,0 +1,336 @@
|
||||
#ifndef BEGUICLASSES_H
|
||||
#define BEGUICLASSES_H
|
||||
|
||||
#include <Application.h>
|
||||
#include <Window.h>
|
||||
#include <View.h>
|
||||
#include <Control.h>
|
||||
#include <Button.h>
|
||||
#include <TextControl.h>
|
||||
#include <ScrollView.h>
|
||||
#include <Rect.h>
|
||||
#include <String.h>
|
||||
#include <Message.h>
|
||||
#include <Alert.h>
|
||||
#include <MenuItem.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Menu.h>
|
||||
#include <CheckBox.h>
|
||||
#include "MList.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
enum MCloseAction {caNone=0, caHide, caFree};
|
||||
|
||||
typedef void (*base_Message)(void* sender, uint32 msg); //callback event
|
||||
typedef void (*genericEvent_Message)(void* sender);
|
||||
typedef void (*mouseMoved_Message)(void* sender, float x, float y, uint32 code, uint32 msg);
|
||||
typedef void (*mouseAction_Message)(void* sender, float x, float y);
|
||||
typedef void (*keyAction_Message)(void* sender, const char *bytes, int32 numBytes);
|
||||
typedef void (*drawAction_Message)(void* sender, float left, float top, float right, float bottom);
|
||||
typedef void (*closeAction_Message)(void* sender, MCloseAction &closeAction);
|
||||
typedef void (*closeQueryAction_Message)(void* sender, bool &canClose);
|
||||
|
||||
|
||||
//Classes...
|
||||
|
||||
class CTest {
|
||||
private:
|
||||
int FValue;
|
||||
public:
|
||||
CTest(void);
|
||||
int GetValue(void);
|
||||
void SetValue(int);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
class MGUIListItem : public MListItem {
|
||||
public:
|
||||
MGUIListItem(BString name, void *item);
|
||||
virtual BString getName(void);
|
||||
virtual void setName(BString name);
|
||||
private:
|
||||
BString fName;
|
||||
};
|
||||
|
||||
// GUI Item store....
|
||||
|
||||
class MGUIList : public MList {
|
||||
public:
|
||||
MGUIList() : MList(){ /*nothing*/ };
|
||||
virtual MGUIListItem* GetItem(int32 index);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
class MPropertyPlugin{
|
||||
protected:
|
||||
BArchivable *FOwner;
|
||||
uint32 FTag;
|
||||
public:
|
||||
MPropertyPlugin(BArchivable *AOwner);
|
||||
MPropertyPlugin();
|
||||
virtual ~MPropertyPlugin();
|
||||
virtual void setTag(uint32 ATag);
|
||||
virtual uint32 getTag(void);
|
||||
virtual BArchivable* getOwner(void);
|
||||
virtual void setOwner(BArchivable *AOwner);
|
||||
};
|
||||
|
||||
class MPopUpMenu; //forward
|
||||
|
||||
class MMenuPropertyPlugin: public MPropertyPlugin{
|
||||
protected:
|
||||
MPopUpMenu *fPopUpMenu;
|
||||
public:
|
||||
MMenuPropertyPlugin(BArchivable *AOwner);
|
||||
virtual ~MMenuPropertyPlugin();
|
||||
virtual void setPopUpMenu(MPopUpMenu *menu);
|
||||
virtual MPopUpMenu* getPopUpMenu(void);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
class MEventPlugin{
|
||||
protected:
|
||||
genericEvent_Message fOnCreate;
|
||||
genericEvent_Message fOnDestroy;
|
||||
public:
|
||||
MEventPlugin();
|
||||
virtual ~MEventPlugin();
|
||||
//event stuff: Dispatchers
|
||||
virtual void AttachCreateDispatcher(genericEvent_Message value);
|
||||
virtual void AttachDestroyDispatcher(genericEvent_Message value);
|
||||
//event stuff: Events
|
||||
virtual void DoCreate(BControl *self);
|
||||
virtual void DoDestroy(BControl *self);
|
||||
};
|
||||
|
||||
class MMenuItem; //forward
|
||||
|
||||
class MMenuEventPlugin{
|
||||
protected:
|
||||
base_Message fOnMenuClick;
|
||||
public:
|
||||
MMenuEventPlugin();
|
||||
virtual ~MMenuEventPlugin();
|
||||
//
|
||||
virtual void DoMenuClick(MMenuItem *self);
|
||||
//
|
||||
virtual void AttachMenuClickDispatcher(base_Message value);
|
||||
|
||||
};
|
||||
|
||||
class MBasicEventPlugin: public MEventPlugin{
|
||||
protected:
|
||||
base_Message fOnClick;
|
||||
base_Message fOnChange;
|
||||
public:
|
||||
MBasicEventPlugin();
|
||||
virtual ~MBasicEventPlugin();
|
||||
//
|
||||
virtual void DoClick(BControl *self);
|
||||
virtual void DoChange(BControl *self);
|
||||
//
|
||||
virtual void AttachClickDispatcher(base_Message value);
|
||||
virtual void AttachChangeDispatcher(base_Message value);
|
||||
};
|
||||
|
||||
class MControlEventPlugin: public MBasicEventPlugin{
|
||||
protected:
|
||||
mouseMoved_Message fOnMouseMove;
|
||||
mouseAction_Message fOnMouseUp;
|
||||
mouseAction_Message fOnMouseDown;
|
||||
keyAction_Message fOnKeyUp;
|
||||
keyAction_Message fOnKeyDown;
|
||||
keyAction_Message fOnKeyPress;
|
||||
drawAction_Message fOnDraw;
|
||||
public:
|
||||
MControlEventPlugin();
|
||||
virtual ~MControlEventPlugin();
|
||||
//event stuff: Dispatchers
|
||||
virtual void AttachMouseDownDispatcher(mouseAction_Message value);
|
||||
virtual void AttachMouseUpDispatcher(mouseAction_Message value);
|
||||
virtual void AttachMouseMovedDispatcher(mouseMoved_Message value);
|
||||
virtual void AttachKeyDownDispatcher(keyAction_Message value);
|
||||
virtual void AttachKeyUpDispatcher(keyAction_Message value);
|
||||
virtual void AttachKeyPressDispatcher(keyAction_Message value);
|
||||
virtual void AttachDrawDispatcher(drawAction_Message value);
|
||||
//event stuff: Events
|
||||
virtual void DoKeyPress(BControl *self, const char *bytes, int32 numBytes);
|
||||
};
|
||||
|
||||
class MFormEventPlugin: public MEventPlugin{
|
||||
protected:
|
||||
closeAction_Message fOnClose;
|
||||
public:
|
||||
MFormEventPlugin();
|
||||
virtual ~MFormEventPlugin();
|
||||
virtual void AttachCloseDispatcher(closeAction_Message value);
|
||||
virtual void DoClose(BView *self, MCloseAction &closeAction);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
class MMemo : public BScrollView,
|
||||
public MControlEventPlugin,
|
||||
public MPropertyPlugin{
|
||||
private:
|
||||
BTextView* fTextArea;
|
||||
public:
|
||||
MMemo(char *name);
|
||||
MMemo(BRect frame, char *name);
|
||||
BTextView* getTextView(void);
|
||||
virtual void AttachedToWindow();
|
||||
//event stuff: Events
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void KeyUp(const char *bytes, int32 numBytes);
|
||||
virtual void MouseDown(BPoint pt);
|
||||
virtual void MouseUp(BPoint pt);
|
||||
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
||||
virtual void Draw(BRect updateArea);
|
||||
};
|
||||
|
||||
|
||||
class MEdit : public BTextControl,
|
||||
public MControlEventPlugin,
|
||||
public MPropertyPlugin{
|
||||
public:
|
||||
MEdit(char *name);
|
||||
MEdit(BRect frame, char *name);
|
||||
virtual ~MEdit();
|
||||
//event stuff: Events
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void KeyUp(const char *bytes, int32 numBytes);
|
||||
virtual void MouseDown(BPoint pt);
|
||||
virtual void MouseUp(BPoint pt);
|
||||
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
||||
virtual void Draw(BRect updateArea);
|
||||
};
|
||||
|
||||
class MButton : public BButton,
|
||||
public MControlEventPlugin,
|
||||
public MPropertyPlugin{
|
||||
private:
|
||||
uint32 fMessage;
|
||||
public:
|
||||
MButton(char *name);
|
||||
MButton(BRect frame, char *name);
|
||||
virtual ~MButton();
|
||||
//event stuff: Events
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void KeyUp(const char *bytes, int32 numBytes);
|
||||
virtual void MouseDown(BPoint pt);
|
||||
virtual void MouseUp(BPoint pt);
|
||||
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
||||
virtual void Draw(BRect updateArea);
|
||||
};
|
||||
|
||||
class MCheckBox : public BCheckBox,
|
||||
public MControlEventPlugin,
|
||||
public MPropertyPlugin{
|
||||
public:
|
||||
MCheckBox(BRect frame, char *name);
|
||||
virtual ~MCheckBox();
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void KeyUp(const char *bytes, int32 numBytes);
|
||||
virtual void MouseDown(BPoint pt);
|
||||
virtual void MouseUp(BPoint pt);
|
||||
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
||||
virtual void Draw(BRect updateArea);
|
||||
virtual bool Checked(void);
|
||||
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
class MMenuItem: public BMenuItem,
|
||||
public MMenuEventPlugin{
|
||||
public:
|
||||
MMenuItem(const char *label);
|
||||
virtual ~MMenuItem();
|
||||
};
|
||||
|
||||
class MPopUpMenu: public BPopUpMenu{
|
||||
public:
|
||||
MPopUpMenu(const char *name);
|
||||
virtual ~MPopUpMenu(){};
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
class MPanel; //forward
|
||||
class MComboBox;
|
||||
|
||||
class MCanvas : public BView,
|
||||
public MControlEventPlugin,
|
||||
public MMenuPropertyPlugin{
|
||||
public:
|
||||
MCanvas(BRect ClientArea, char *name);
|
||||
virtual ~MCanvas();
|
||||
virtual void AttachedToWindow();
|
||||
virtual MEdit* AddEdit(BRect ClientArea, char *name);
|
||||
virtual MMemo* AddMemo(BRect ClientArea, char *name);
|
||||
virtual MPanel* AddPanel(BRect ClientArea, char *name);
|
||||
virtual MCheckBox* AddCheckBox(BRect ClientArea, char *name);
|
||||
//event stuff: Events
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void KeyUp(const char *bytes, int32 numBytes);
|
||||
virtual void MouseDown(BPoint pt);
|
||||
virtual void MouseUp(BPoint pt);
|
||||
virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg);
|
||||
virtual void Draw(BRect updateArea);
|
||||
};
|
||||
|
||||
class MPanel : public MCanvas{
|
||||
public:
|
||||
MPanel(BRect ClientArea, char *name);
|
||||
virtual void Draw(BRect updateArea);
|
||||
};
|
||||
|
||||
class MForm : public BWindow,
|
||||
public MFormEventPlugin{
|
||||
protected:
|
||||
BRect fClientArea;
|
||||
MCanvas *fCanvas;
|
||||
MCloseAction fCloseAction;
|
||||
private:
|
||||
void UpdateBounds(void);
|
||||
public:
|
||||
MForm(BRect ClientArea);
|
||||
virtual ~MForm();
|
||||
virtual bool QuitRequested();
|
||||
virtual float getWidth(void);
|
||||
virtual float getHeight(void);
|
||||
virtual void setWidth(float w);
|
||||
virtual void setHeight(float h);
|
||||
virtual float getLeft(void);
|
||||
virtual float getTop(void);
|
||||
virtual float getBottom(void);
|
||||
virtual float getRight(void);
|
||||
virtual MCanvas* Canvas(void);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual MCloseAction getCloseAction(void);
|
||||
virtual void setCloseAction(MCloseAction ca);
|
||||
};
|
||||
|
||||
class MApplication : public BApplication,
|
||||
public MEventPlugin{
|
||||
protected:
|
||||
MForm *fMainForm, *fecker;
|
||||
MGUIList *fForms;
|
||||
bool fTerminating;
|
||||
public:
|
||||
MApplication();
|
||||
MApplication(MForm* mainForm);
|
||||
virtual ~MApplication();
|
||||
virtual void Terminate(void);
|
||||
virtual MForm* AddForm(BRect ClientArea, BString name, bool showForm = false);
|
||||
virtual MForm* GetMainForm(void){ return fMainForm; };
|
||||
virtual bool Terminating(void){ return fTerminating; };
|
||||
virtual void setTerminating(bool Value){ fTerminating = Value; };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
210
begui/begui/libbegui/BeTestApp.cpp
Normal file
210
begui/begui/libbegui/BeTestApp.cpp
Normal file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
$Header: /home/haiku/befpc/begui/begui/libbegui/BeTestApp.cpp,v 1.1.1.1 2002-03-31 10:36:21 memson Exp $
|
||||
|
||||
$Revision: 1.1.1.1 $
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.15 2002/03/26 13:28:51 memson
|
||||
added in combobox support - flawed at the moment.
|
||||
|
||||
Revision 1.14 2002/03/14 22:31:41 memson
|
||||
Got the Menubar/menu/menuitem and popupmenu/menuitem both working... Had a
|
||||
bit of a slack night, so didn't really do much else.
|
||||
|
||||
Revision 1.13 2002/03/14 00:12:38 memson
|
||||
Revised the event and property class hierarchies... hopefully makes more
|
||||
sense.
|
||||
|
||||
Started to add in the Menu functionality. PopUpMenu is done and 'tested',
|
||||
but the BMenuBar/BMenu (mainmenu) stuff is there but untested.
|
||||
|
||||
Added in an OnCreate and OnDestroy event to the events, plust a wierd
|
||||
offshoot class to handle the menuitem click.
|
||||
|
||||
Revision 1.12 2002/03/12 23:12:37 memson
|
||||
hashed out some details - stopped child windows from screwing up app, and
|
||||
also added the close action to form and terminating functionality to the app.
|
||||
|
||||
Revision 1.11 2002/03/12 18:39:16 memson
|
||||
|
||||
Revision 1.10 2002/03/11 23:22:11 memson
|
||||
|
||||
Revision 1.9 2002/02/19 17:49:54 memson
|
||||
Added half arsed support for multiple windows - not working quite right yet,
|
||||
but at least they seem to 'work' in so much as they don't wipe the app out.
|
||||
The secondary forms Canvas is screwed up a little.. that is a priority I
|
||||
guess.
|
||||
|
||||
Revision 1.8 2002/02/14 23:39:53 memson
|
||||
I've now added most of the events to the MButton, MCanvas, MMemo and MEdit..
|
||||
started a MPanel component. Again, the MCanvas is *not* tread safe!!!
|
||||
This means the calling thread must create it.
|
||||
|
||||
NB. Before I add much more functionality, I'm going to look at other GUI
|
||||
libs to see if there are any controls worth borrowing.
|
||||
|
||||
Next control will probably be a MLabel followed by a MMenuBar and MMenuItem.
|
||||
MForm will own a MMenuBar.
|
||||
|
||||
Revision 1.7 2002/02/14 20:33:19 memson
|
||||
Got the MButton OnClick, OnMouseDown/Up, OnKeyDown/Up and OnMouseMoved
|
||||
events working. Started to add the required code to the rest of the classes
|
||||
(should be a cut/paste job).
|
||||
|
||||
Revision 1.6 2002/02/14 14:00:16 memson
|
||||
fiddled a bit.. nothing major.
|
||||
|
||||
Revision 1.5 2002/02/13 23:26:25 memson
|
||||
Got the MMemo working.
|
||||
Got the MEdit working, including OnClick event signal
|
||||
Got the MButton working with a signal
|
||||
Added a few get/set accessor routined for captions/text.
|
||||
|
||||
|
||||
Revision 1.4 2002/02/13 00:02:02 memson
|
||||
Got the MTextControl basic functionality - annoying fact is that a text
|
||||
control has to be added inside the thread that will display it!!!!
|
||||
|
||||
Revision 1.3 2002/02/11 23:26:44 memson
|
||||
Revision 1.2 2002/01/17 20:32:54 memson
|
||||
|
||||
*/
|
||||
|
||||
#include "BeGuiAPI.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void *frm2 = 0; //need to add a 'parent' property?? Does BeAPI have equiv?
|
||||
|
||||
/* button callback */
|
||||
void callback(void* Sender, uint32 msg){
|
||||
if (msg == 'clik')
|
||||
if (Sender) {
|
||||
GenericAlert(MButton_getCaption((MButton*)Sender));
|
||||
MButton_setCaption((MButton*)Sender, "X");
|
||||
}
|
||||
}
|
||||
|
||||
/* edit callback */
|
||||
void callback2(void* Sender, uint32 msg){
|
||||
if (msg == 'clik')
|
||||
if (Sender) {
|
||||
GenericAlert( MEdit_getText( (MEdit*)Sender ) );
|
||||
}
|
||||
}
|
||||
|
||||
void menuClick(void* Sender, uint32 msg){
|
||||
if (msg == 'clik')
|
||||
GenericAlert( "Menu click" );
|
||||
}
|
||||
|
||||
/* test mousemove */
|
||||
void mousemoved(void* Sender, float x, float y, uint32 code, uint32 msg){
|
||||
printf("mousemoved - x: %f, y: %f, code: %u\n", x, y, code);
|
||||
}
|
||||
|
||||
/* test mousedown */
|
||||
void mousedown(void* Sender, float x, float y){
|
||||
printf("mousedown - x: %f, y: %f\n", x, y);
|
||||
}
|
||||
|
||||
/* test mouseup */
|
||||
void mouseup(void* Sender, float x, float y){
|
||||
printf("mouseup - x: %f, y: %f\n", x, y);
|
||||
}
|
||||
|
||||
/* test button click */
|
||||
void doclick(void* Sender, uint32 msg){
|
||||
if (msg == 'clik')
|
||||
if (Sender) {
|
||||
printf("%s clicked\n", MButton_getCaption((MButton*)Sender));
|
||||
}
|
||||
|
||||
if (frm2 != NULL){
|
||||
MForm_Show((MForm*)frm2);
|
||||
}
|
||||
|
||||
//dynamic_cast<MApplication*>(be_app)->Terminate();
|
||||
}
|
||||
|
||||
/* test form click */
|
||||
void doformclick(void* Sender, float x, float y){
|
||||
printf("mousedown - x: %f, y: %f\n", x, y);
|
||||
}
|
||||
|
||||
|
||||
int main(void){
|
||||
/* variables */
|
||||
void *app;
|
||||
void *frm;
|
||||
void *btn, *btn2;
|
||||
void *edt, *edt2;
|
||||
void *pnl;
|
||||
void *mni, *mni2, *mnu;
|
||||
void *pm, *mb;
|
||||
void *cbx;
|
||||
void *btncbx;
|
||||
|
||||
/* must create application first!! */
|
||||
app = MApplication_Create();
|
||||
|
||||
/* application automatically creates main form
|
||||
so call this to get a reference to it.. */
|
||||
frm = MApplication_GetMainForm((MApplication*)app);
|
||||
MForm_AttachMouseDownDispatcher((MForm*)frm, doformclick);
|
||||
|
||||
/* create a second hidded form */
|
||||
frm2 = MApplication_AddForm((MApplication*)app, 100, 100, 100, 100, "testfrm", "testfrm");
|
||||
//MForm_Show((MForm*)frm2);
|
||||
|
||||
/* create 2 buttons */
|
||||
btn = MButton_Create(5, 25, 30, 20, "test");
|
||||
btn2 = MButton_Create(5, 50, 30, 30, "test2");
|
||||
cbx = MForm_AddMCheckBox((MForm*)frm, 20, 20, 100, 50, "test cbx");
|
||||
|
||||
/* add buttons to main form */
|
||||
MForm_AddChild((MForm*)frm, (BControl*)btn);
|
||||
MForm_AddChild((MForm*)frm, (BControl*)btn2);
|
||||
//MForm_AddChild((MForm*)frm, (BControl*)cbx);
|
||||
|
||||
pm = MPopUpMenu_Create("testmenu");
|
||||
mni = MMenuItem_Create("Test Item");
|
||||
MMenuItem_AttachMenuClickDispatcher((MMenuItem*)mni, menuClick);
|
||||
MPopUpMenu_AddItem((MPopUpMenu*)pm, (MMenuItem*)mni);
|
||||
MForm_AddPopUpMenu((MForm*)frm, (MPopUpMenu*)pm);
|
||||
|
||||
|
||||
mb = BMenuBar_Create((MForm*)frm, "testmenubar");
|
||||
mni2 = MMenuItem_Create("Test mb item");
|
||||
MMenuItem_AttachMenuClickDispatcher((MMenuItem*)mni2, menuClick);
|
||||
mnu = BMenu_Create("Form");
|
||||
BMenu_AddItem((BMenu*)mnu, (MMenuItem*)mni2);
|
||||
BMenuBar_AddItem((BMenuBar*)mb, (BMenu*)mnu);
|
||||
|
||||
/* set the button event callback routines */
|
||||
MButton_AttachClickDispatcher((MButton*)btn, callback);
|
||||
MButton_AttachClickDispatcher((MButton*)btn2, doclick);
|
||||
MButton_AttachMouseMovedDispatcher((MButton*)btn, mousemoved);
|
||||
MButton_AttachMouseUpDispatcher((MButton*)btn2, mouseup);
|
||||
MButton_AttachMouseDownDispatcher((MButton*)btn2, mousedown);
|
||||
|
||||
/* add an edit - must be done in thread of main form */
|
||||
edt2 = MForm_AddMEdit((MForm*)frm, 30, 50, 100, 50, "test4");
|
||||
|
||||
/* set the edit event callback routines */
|
||||
MEdit_AttachClickDispatcher((MEdit*)edt2, callback2);
|
||||
|
||||
/* create a memo - like edit, must be done in main form's thread */
|
||||
edt = MForm_AddMMemo((MForm*)frm, 30, 100, 150, 150, "test5");
|
||||
|
||||
/* create a panel */
|
||||
//pnl = MForm_AddMPanel((MForm*)frm, 250, 200, 400, 400, "panel1");
|
||||
|
||||
//MForm_Hide((MForm*)frm);
|
||||
//MForm_Show((MForm*)frm);
|
||||
|
||||
/* start things rolling */
|
||||
MApplication_Run((MApplication*)app);
|
||||
|
||||
/* clean up after execution */
|
||||
MApplication_Free((MApplication*)app);
|
||||
}
|
||||
BIN
begui/begui/libbegui/BeTestApp.proj
Normal file
BIN
begui/begui/libbegui/BeTestApp.proj
Normal file
Binary file not shown.
65
begui/begui/libbegui/MList.cpp
Normal file
65
begui/begui/libbegui/MList.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
$Header: /home/haiku/befpc/begui/begui/libbegui/MList.cpp,v 1.1.1.1 2002-03-31 10:36:25 memson Exp $
|
||||
|
||||
$Revision: 1.1.1.1 $
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.7 2002/03/12 18:39:17 memson
|
||||
|
||||
Revision 1.8 2002/03/11 23:22:11 memson
|
||||
|
||||
Revision 1.6 2002/02/14 23:39:53 memson
|
||||
|
||||
I've now added most of the events to the MButton, MCanvas, MMemo and MEdit..
|
||||
started a MPanel component. Again, the MCanvas is *not* tread safe!!!
|
||||
This means the calling thread must create it.
|
||||
|
||||
NB. Before I add much more functionality, I'm going to look at other GUI
|
||||
libs to see if there are any controls worth borrowing.
|
||||
|
||||
Next control will probably be a MLabel followed by a MMenuBar and MMenuItem.
|
||||
MForm will own a MMenuBar.
|
||||
|
||||
Revision 1.5 2002/02/14 14:00:16 memson
|
||||
fiddled a bit.. nothing major.
|
||||
|
||||
Revision 1.4 2002/02/13 23:26:25 memson
|
||||
Got the MMemo working.
|
||||
Got the MEdit working, including OnClick event signal
|
||||
Got the MButton working with a signal
|
||||
Added a few get/set accessor routined for captions/text.
|
||||
|
||||
Revision 1.3 2002/02/11 23:26:44 memson
|
||||
Revision 1.2 2002/01/17 20:32:54 memson
|
||||
|
||||
*/
|
||||
|
||||
#include "MList.h"
|
||||
|
||||
bool MList::AddItem(MListItem* item){
|
||||
return BList::AddItem((void*)item);
|
||||
}
|
||||
|
||||
MListItem* MList::GetItem(int32 index){
|
||||
return (MListItem*)BList::ItemAt(index);
|
||||
}
|
||||
|
||||
MListItem::MListItem(void *item){
|
||||
fItem = item;
|
||||
}
|
||||
|
||||
MListItem::~MListItem(){
|
||||
fItem = NULL;
|
||||
}
|
||||
|
||||
void* MListItem::getItem(void){
|
||||
return fItem;
|
||||
}
|
||||
|
||||
void MListItem::setItem(void *item){
|
||||
if (fItem) {
|
||||
fItem = NULL;
|
||||
}
|
||||
|
||||
fItem = item;
|
||||
}
|
||||
60
begui/begui/libbegui/MList.h
Normal file
60
begui/begui/libbegui/MList.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
$Header: /home/haiku/befpc/begui/begui/libbegui/MList.h,v 1.1.1.1 2002-03-31 10:36:25 memson Exp $
|
||||
|
||||
$Revision: 1.1.1.1 $
|
||||
|
||||
$Log: not supported by cvs2svn $
|
||||
Revision 1.8 2002/03/12 18:39:17 memson
|
||||
|
||||
Revision 1.7 2002/03/11 23:22:11 memson
|
||||
|
||||
Revision 1.6 2002/02/14 23:39:53 memson
|
||||
I've now added most of the events to the MButton, MCanvas, MMemo and MEdit..
|
||||
started a MPanel component. Again, the MCanvas is *not* tread safe!!!
|
||||
This means the calling thread must create it.
|
||||
|
||||
NB. Before I add much more functionality, I'm going to look at other GUI
|
||||
libs to see if there are any controls worth borrowing.
|
||||
|
||||
Next control will probably be a MLabel followed by a MMenuBar and MMenuItem.
|
||||
MForm will own a MMenuBar.
|
||||
|
||||
|
||||
Revision 1.5 2002/02/14 14:00:17 memson
|
||||
fiddled a bit.. nothing major.
|
||||
|
||||
Revision 1.4 2002/02/13 23:26:25 memson
|
||||
Got the MMemo working.
|
||||
Got the MEdit working, including OnClick event signal
|
||||
Got the MButton working with a signal
|
||||
Added a few get/set accessor routined for captions/text.
|
||||
|
||||
Revision 1.3 2002/02/11 23:26:44 memson
|
||||
Revision 1.2 2002/01/17 20:32:54 memson
|
||||
|
||||
*/
|
||||
|
||||
#ifndef MLIST_H
|
||||
#define MLIST_H
|
||||
|
||||
#include <List.h>
|
||||
|
||||
class MListItem {
|
||||
public:
|
||||
MListItem(void *item);
|
||||
virtual ~MListItem();
|
||||
virtual void* getItem(void);
|
||||
virtual void setItem(void *item);
|
||||
private:
|
||||
void *fItem;
|
||||
};
|
||||
|
||||
class MList: public BList {
|
||||
public:
|
||||
MList(): BList(20){/*nothing*/};
|
||||
virtual bool AddItem(MListItem* item);
|
||||
virtual MListItem* GetItem(int32 index);
|
||||
};
|
||||
|
||||
#endif MLIST_H
|
||||
|
||||
BIN
begui/begui/libbegui/libbegui.proj
Normal file
BIN
begui/begui/libbegui/libbegui.proj
Normal file
Binary file not shown.
Reference in New Issue
Block a user