/**** ファイル名 : MainWindow.cpp ****/
BAppMainView::BAppMainView(BRect frame) :BView(frame,"bappmainview",B_FOLLOW_ALL,B_WILL_DRAW) { BRect viewrect(Bounds()); textview=new BTextView(viewrect,"textview", BRect(0,0,viewrect.Width(),viewrect.Height()), B_FOLLOW_ALL,B_WILL_DRAW); AddChild(textview); }
/**** ファイル名 : MainWindow.cpp ****/
BAppMainView::BAppMainView(BRect frame) :BView(frame,"bappmainview",B_FOLLOW_ALL,B_WILL_DRAW) { BAppMainView::BAppMainView(BRect frame) :BView(frame,"bappmainview",B_FOLLOW_ALL,B_WILL_DRAW) { BRect viewrect(Bounds()); BRect f(8,8,viewrect.right-8-B_V_SCROLL_BAR_WIDTH, viewrect.bottom-40-B_H_SCROLL_BAR_HEIGHT); textview=new BTextView(f,"textview",BRect(0,0,f.Width(),f.Height()), B_FOLLOW_ALL,B_WILL_DRAW); BScrollView *scr=new BScrollView("memoscroll",textview, B_FOLLOW_ALL,0,false,true); AddChild(scr); }
/**** ファイル名 : MainWindow.h ****/
//--------------------------------------------------------------------- #define MSG_COPY 'cpyb' #define MSG_CUT 'cutb' #define MSG_PASTE 'pstb' #define MSG_UNDO 'udob' //---------------------------------------------------------------------
/**** ファイル名 : MainWindow.cpp ****/
//--------------------------------------------------------------------- void BAppMainWindow::MessageReceived(BMessage *msg) { switch(msg->what) { case MSG_COPY: mainview->textview->Copy(be_clipboard); break; case MSG_CUT: mainview->textview->Cut(be_clipboard); break; case MSG_PASTE: mainview->textview->Paste(be_clipboard); break; case MSG_UNDO: mainview->textview->Undo(be_clipboard); break; default: BWindow::MessageReceived(msg); } } //--------------------------------------------------------------------- BAppMainView::BAppMainView(BRect frame) :BView(frame,"bappmainview",B_FOLLOW_ALL,B_WILL_DRAW) { BRect viewrect(Bounds()); BButton *btn; BMessage *cpymsg=new BMessage(MSG_COPY); BMessage *cutmsg=new BMessage(MSG_CUT); BMessage *pstmsg=new BMessage(MSG_PASTE); BMessage *udomsg=new BMessage(MSG_UNDO); BRect f(8,8,viewrect.right-8-B_V_SCROLL_BAR_WIDTH, viewrect.bottom-40-B_H_SCROLL_BAR_HEIGHT); textview=new BTextView(f,"textview",BRect(0,0,f.Width(),f.Height()), B_FOLLOW_ALL,B_WILL_DRAW); BScrollView *scr=new BScrollView("memoscroll",textview, B_FOLLOW_ALL,0,false,true); AddChild(scr); btn=new BButton(BRect(viewrect.right-68,viewrect.bottom-32, viewrect.right-8,viewrect.bottom-8), "undobtn","UNDO",udomsg); AddChild(btn); btn=new BButton(BRect(viewrect.right-136,viewrect.bottom-32, viewrect.right-76,viewrect.bottom-8), "pastebtn","PASTE",pstmsg); AddChild(btn); btn=new BButton(BRect(viewrect.right-204,viewrect.bottom-32, viewrect.right-144,viewrect.bottom-8), "cutbtn","CUT",cutmsg); AddChild(btn); btn=new BButton(BRect(viewrect.right-272,viewrect.bottom-32, viewrect.right-212,viewrect.bottom-8), "copybtn","COPY",cpymsg); AddChild(btn); } //---------------------------------------------------------------------
を追加します。textview->SetDoesUndo(true);
圧縮ファイル R5 Intel環境で確認 |
Be4thApp20000120.zip |
ソースファイル | |
BaseApp.h | |
main.cpp | |
MainWindow.cpp | |
MainWindow.h |