Added MMemo_Text and MMemo_TextLength. Updated the testfile demo to save

text from a MMemo when button clicked.
This commit is contained in:
memson
2002-04-13 00:32:16 +00:00
parent 434b2f7566
commit 8317aa12bf
6 changed files with 53 additions and 7 deletions

View File

@@ -1,9 +1,18 @@
/*
$Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiAPI.cpp,v 1.3 2002-04-12 23:32:56 memson Exp $
$Header: /home/haiku/befpc/begui/begui/libbegui/BeGuiAPI.cpp,v 1.4 2002-04-13 00:32:16 memson Exp $
$Revision: 1.3 $
$Revision: 1.4 $
$Log: not supported by cvs2svn $
Revision 1.3 2002/04/12 23:32:56 memson
Added quite a bit.
Got basic file handling soeted out. Also got the FilePanel's working (see
example project)
Popup menu now only responds to a right click (at last!!)
Revision 1.2 2002/04/02 20:42:15 memson
updated for Eric
@@ -422,6 +431,14 @@ void MMemo_AttachKeyUpDispatcher(MMemo *memo, keyAction_Message msg){
memo->AttachKeyDownDispatcher(msg);
}
const char* MMemo_Text(MMemo *memo){
return memo->getTextView()->Text();
}
int32 MMemo_TextLength(MMemo *memo){
return memo->getTextView()->TextLength();
}
///
MCheckBox* MForm_AddMCheckBox(MForm* frm, float left, float top, float right, float bottom, char *name){

View File

@@ -100,6 +100,8 @@ 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);
const char* MMemo_Text(MMemo *memo);
int32 MMemo_TextLength(MMemo *memo);
//panel
MPanel* MForm_AddMPanel(MForm* frm, float left, float top, float right, float bottom, char *name);

Binary file not shown.

Binary file not shown.

View File

@@ -3,7 +3,9 @@
#include <stdlib.h>
#include <string.h>
//nasty global..
void *savepanel; // MSavePanel reference
void *memo;
void file_io(void* sender, uint32 msg, const char *path){
char *buffer; //for output
@@ -18,17 +20,42 @@ void file_io(void* sender, uint32 msg, const char *path){
MFile_Free((MFile*)file); //clear the file pointer
}
void file_io2(void* sender, uint32 msg, const char *path){
void *file; //for MFile reference
//file output...
file = MFile_Create(path, B_READ_WRITE | B_CREATE_FILE); //file read/write and create if not already there
MFile_Write( (MFile*)file, MMemo_Text((MMemo*)memo), MMemo_TextLength((MMemo*)memo) ); //output buffer contents
MFile_Free((MFile*)file); //clear the file pointer
}
/* save button click */
void doclick(void* Sender, uint32 msg){
MSavePanel_Show((MSavePanel*) savepanel); //show the panel (this is modal)
}
int main(){
void *savepanel; // MSavePanel reference
void *app; // MApplication reference
void *btn;
void *frm;
// Matt 11/04/2002 : Must have a MApplication to use a MFilePanel of descendents
app = MApplication_Create(); //create an MApplication reference
savepanel = MSavePanel_Create(); //create a MSavePanel reference
MFilePanel_AttachDialogEvent((MFilePanel*)savepanel, file_io); //attach callback for event
frm = MApplication_GetMainForm((MApplication*)app);
MForm_setWidth((MForm*)frm, 250);
MForm_setHeight((MForm*)frm, 250);
MSavePanel_Show((MSavePanel*) savepanel); //show the panel (this is modal)
btn = MButton_Create(5, 25, 35, 20, "save");
MForm_AddChild((MForm*)frm, (BControl*)btn);
MButton_AttachClickDispatcher((MButton*)btn, doclick);
savepanel = MSavePanel_Create(); //create a MSavePanel reference
//MFilePanel_AttachDialogEvent((MFilePanel*)savepanel, file_io); //attach callback for event
MFilePanel_AttachDialogEvent((MFilePanel*)savepanel, file_io2); //attach callback for event
/* create a memo - like edit, must be done in main form's thread */
memo = MForm_AddMMemo((MForm*)frm, 30, 100, 150, 150, "test5");
MApplication_Run((MApplication*)app); //run the application