/**** ファイル名 : MainWindow.cpp ****/
BAppMainView::BAppMainView(BRect frame) :BView(frame,"bappmainview",B_FOLLOW_ALL,B_WILL_DRAW) { BRect viewrect(Bounds()); BTextControl *textctrl=new BTextControl( BRect(8,8,viewrect.right-8,28),"textctrl", NULL,"Default",NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); AddChild(textctrl); BStringView *strview=new BStringView( BRect(8,38,viewrect.right-8,58),"strview", "NoData", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); AddChild(strview); }
/**** ファイル名 : BaseApp.h ****/
#ifndef BASEAPP #define BASEAPP //--------------------------------------------------------------------- #include <Be.h> #include "MainWindow.h" //--------------------------------------------------------------------- #define APPLICATION_SIGNATURE "application/x-vnd.vow-be1stapp" //--------------------------------------------------------------------- class BaseApp : public BApplication { public: BaseApp() :BApplication(APPLICATION_SIGNATURE) { BAppMainWindow *mainwnd=new BAppMainWindow( BRect(MAINWINDOW_POSITION_LEFT,MAINWINDOW_POSITION_TOP, MAINWINDOW_POSITION_WIDTH+MAINWINDOW_POSITION_LEFT-1, MAINWINDOW_POSITION_HEIGHT+MAINWINDOW_POSITION_TOP-1), MAINWINDOW_TITLE); mainwnd->Show(); }; }; //--------------------------------------------------------------------- #endif
/**** ファイル名 : MainWindow.h ****/
#ifndef MAINWINDOW #define MAINWINDOW //--------------------------------------------------------------------- #include <Be.h> //--------------------------------------------------------------------- #define MAINWINDOW_TITLE "Button,TextControl,StringView Application" #define MAINWINDOW_POSITION_LEFT 100 #define MAINWINDOW_POSITION_TOP 100 #define MAINWINDOW_POSITION_WIDTH 400 #define MAINWINDOW_POSITION_HEIGHT 120 #define MAINWINDOW_WINDOWSTYLE (B_TITLED_WINDOW) //--------------------------------------------------------------------- #define MSG_COPY 'cpyb' //--------------------------------------------------------------------- class BAppMainView : public BView { public: BStringView *strview; BTextControl *textctrl; BAppMainView(BRect frame); }; //--------------------------------------------------------------------- class BAppMainWindow : public BWindow { public: BAppMainView *mainview; //----------------------------------------------------------------- BAppMainWindow(BRect frame,const char *title); virtual void MessageReceived(BMessage *msg); //----------------------------------------------------------------- bool QuitRequested() { be_app->PostMessage(B_QUIT_REQUESTED); return true; }; }; //--------------------------------------------------------------------- #endif
/**** ファイル名 : MainWindow.cpp ****/
//--------------------------------------------------------------------- #include "MainWindow.h" //--------------------------------------------------------------------- BAppMainWindow::BAppMainWindow(BRect frame,const char *title) :BWindow(frame,title,MAINWINDOW_WINDOWSTYLE,0) { mainview=new BAppMainView(Bounds()); AddChild(mainview); } //--------------------------------------------------------------------- void BAppMainWindow::MessageReceived(BMessage *msg) { switch(msg->what) { case MSG_COPY: mainview->strview->SetText(mainview->textctrl->Text()); break; default: BWindow::MessageReceived(msg); } } //--------------------------------------------------------------------- BAppMainView::BAppMainView(BRect frame) :BView(frame,"bappmainview",B_FOLLOW_ALL,B_WILL_DRAW) { BRect viewrect(Bounds()); BButton *copybtn=new BButton(BRect(viewrect.right-72,68, viewrect.right-8,88),"copybtn", "COPY!!",new BMessage(MSG_COPY), B_FOLLOW_RIGHT | B_FOLLOW_TOP); AddChild(copybtn); textctrl=new BTextControl(BRect(8,8,viewrect.right-8,28),"textctrl", NULL,"Default",NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); AddChild(textctrl); strview=new BStringView(BRect(8,38,viewrect.right-8,58),"strview", "NoData", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); AddChild(strview); } //---------------------------------------------------------------------
/**** ファイル名 : main.cpp ****/
//--------------------------------------------------------------------- #include "BaseApp.h" //--------------------------------------------------------------------- int main(void) { new BaseApp(); be_app->Run(); delete be_app; return true; } //---------------------------------------------------------------------
と、APPLICATION_SIGNATUREを変更して、アプリケーションのMIMEタイプを前回までに使用していたものとは違うものに変更しています。こうしておくことで、前回までのアプリケーションと今回のアプリケーションが違うものであることを明示します。#define APPLICATION_SIGNATURE "application/x-vnd.vow-be1stapp"
圧縮ファイル R5 Intel環境で確認 |
Be1stApp19991201.zip |
ソースファイル | |
BaseApp.h | |
main.cpp | |
MainWindow.cpp | |
MainWindow.h |