/**** ファイル名 : MainWindow.h ****/
#define MAINWINDOW_TITLE "BTinyEditor" #define MAINWINDOW_POSITION_LEFT 20 #define MAINWINDOW_POSITION_TOP 40 #define MAINWINDOW_POSITION_WIDTH 600 #define MAINWINDOW_POSITION_HEIGHT 400 #define MAINWINDOW_WINDOWSTYLE (B_DOCUMENT_WINDOW) #define RESOURCEFILEPATH "/boot/home/config/settings/BTinyEditor.cfg" #define R_FRAME_WIDTH 1 #define R_FRAME_HEIGHT 2
/**** ファイル名 : MainWindow.cpp ****/
//-------------------------------------------------------------------- void BEditorWindow::SaveDataToResource(void) { BResources res; BFile file(RESOURCEFILEPATH, B_READ_WRITE | B_CREATE_FILE); int32 wk; res.SetTo(&file); wk=Frame().IntegerWidth(); res.AddResource(B_INT32_TYPE,R_FRAME_WIDTH,&wk,sizeof(wk)); wk=Frame().IntegerHeight(); res.AddResource(B_INT32_TYPE,R_FRAME_HEIGHT,&wk,sizeof(wk)); res.Sync(); file.Unset(); } //--------------------------------------------------------------------
SaveDataToResource(); BMessage *msg_closed=new BMessage(MSG_CLOSED); msg_closed->AddPointer("wnd",this); be_app->PostMessage(msg_closed); return true;
元々は、このようにMainWindow.hで定義した定数でウィンドウの表示位置を指定しています。これを作成する毎に位置をずらすようにします。BEditorWindow *mainwnd=new BEditorWindow( BRect(MAINWINDOW_POSITION_LEFT,MAINWINDOW_POSITION_TOP, MAINWINDOW_POSITION_WIDTH+MAINWINDOW_POSITION_LEFT-1, MAINWINDOW_POSITION_HEIGHT+MAINWINDOW_POSITION_TOP-1), MAINWINDOW_TITLE);
/**** ファイル名 : BTinyEditor.cpp ****/
//--------------------------------------------------------------------- BEditorWindow *BTinyEditor::AddEditor(void) { BEditorWindow *mainwnd; BEditorWindow *targetwnd=NULL; BRect wndpos(MAINWINDOW_POSITION_LEFT,MAINWINDOW_POSITION_TOP, MAINWINDOW_POSITION_WIDTH+MAINWINDOW_POSITION_LEFT-1, MAINWINDOW_POSITION_HEIGHT+MAINWINDOW_POSITION_TOP-1); float width,height; width=wndpos.Width(); height=wndpos.Height(); if(EditorList->CountItems()>0) targetwnd=(BEditorWindow *)EditorList->ItemAt( EditorList->CountItems()-1); if(targetwnd!=NULL) wndpos.Set(targetwnd->Frame().left+B_V_SCROLL_BAR_WIDTH, targetwnd->Frame().top+B_H_SCROLL_BAR_HEIGHT, targetwnd->Frame().right+B_V_SCROLL_BAR_WIDTH, targetwnd->Frame().bottom+B_H_SCROLL_BAR_HEIGHT); else { BResources res; BFile file; if(file.SetTo(RESOURCEFILEPATH, B_READ_ONLY)==B_OK) { size_t siz; int32 *wk; res.SetTo(&file); siz=sizeof(int32); wk=(int32 *)res.LoadResource(B_INT32_TYPE,R_FRAME_WIDTH,&siz); width=(float)*wk; siz=sizeof(int32); wk=(int32 *)res.LoadResource(B_INT32_TYPE,R_FRAME_HEIGHT,&siz); height=(float)*wk; file.Unset(); } wndpos.Set(wndpos.left,wndpos.top, wndpos.left+width,wndpos.top+height); } mainwnd=new BEditorWindow(wndpos,MAINWINDOW_TITLE); EditorList->AddItem((void *)mainwnd); mainwnd->Show(); return mainwnd; } //---------------------------------------------------------------------
/**** ファイル名 : BTinyEditor.cpp ****/
//--------------------------------------------------------------------- BEditorWindow *BTinyEditorApp::AddEditor(void) { BEditorWindow *mainwnd; BEditorWindow *targetwnd=NULL; BRect wndpos(MAINWINDOW_POSITION_LEFT,MAINWINDOW_POSITION_TOP, MAINWINDOW_POSITION_WIDTH+MAINWINDOW_POSITION_LEFT-1, MAINWINDOW_POSITION_HEIGHT+MAINWINDOW_POSITION_TOP-1); BScreen mainscreen; float width,height; width=wndpos.Width(); height=wndpos.Height(); if(EditorList->CountItems()>0) targetwnd=(BEditorWindow *)EditorList->ItemAt( EditorList->CountItems()-1); if(targetwnd!=NULL) wndpos.Set(targetwnd->Frame().left+B_V_SCROLL_BAR_WIDTH, targetwnd->Frame().top+B_H_SCROLL_BAR_HEIGHT, targetwnd->Frame().right+B_V_SCROLL_BAR_WIDTH, targetwnd->Frame().bottom+B_H_SCROLL_BAR_HEIGHT); else { BResources res; BFile file; if(file.SetTo(RESOURCEFILEPATH, B_READ_ONLY)==B_OK) { size_t siz; int32 *wk; res.SetTo(&file); siz=sizeof(int32); wk=(int32 *)res.LoadResource(B_INT32_TYPE,R_FRAME_WIDTH,&siz); width=(float)*wk; siz=sizeof(int32); wk=(int32 *)res.LoadResource(B_INT32_TYPE,R_FRAME_HEIGHT,&siz); height=(float)*wk; file.Unset(); } wndpos.Set(wndpos.left,wndpos.top, wndpos.left+width,wndpos.top+height); } if(wndpos.right>mainscreen.Frame().right) wndpos.Set(6,wndpos.top,width,wndpos.bottom); if(wndpos.bottom>mainscreen.Frame().bottom) wndpos.Set(wndpos.left,be_plain_font->Size()*2+4, wndpos.right,height); mainwnd=new BEditorWindow(wndpos,MAINWINDOW_TITLE); EditorList->AddItem((void *)mainwnd); mainwnd->Show(); return mainwnd; } //---------------------------------------------------------------------
圧縮ファイル R5 Intel環境で確認 |
BTinyEditor20000703.zip |
ソースファイル | BTinyEditor.cpp |
BTinyEditor.h | |
BFindWindow.cpp | |
BFindWindow.h | |
BMemoView.cpp | |
BMemoView.h | |
cccheck.cpp | |
cccheck.h | |
main.cpp | |
MainWindow.cpp | |
MainWindow.h |