2002-09-23 23:01:55 +00:00
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
#include <Autolock.h>
|
2002-09-23 23:01:55 +00:00
|
|
|
#include "Constants.h"
|
|
|
|
|
#include "StyledEditApp.h"
|
2002-11-05 09:24:25 +00:00
|
|
|
#include "StyledEditWindow.h"
|
2002-09-23 23:01:55 +00:00
|
|
|
|
2002-11-05 18:28:19 +00:00
|
|
|
BRect windowRect(7,26,507,426);
|
2002-09-23 23:01:55 +00:00
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
StyledEditApp * styled_edit_app;
|
2002-09-23 23:01:55 +00:00
|
|
|
|
|
|
|
|
StyledEditApp::StyledEditApp()
|
|
|
|
|
: BApplication(APP_SIGNATURE)
|
2002-11-05 09:24:25 +00:00
|
|
|
{
|
2002-11-06 23:03:34 +00:00
|
|
|
fOpenPanel= new BFilePanel();
|
|
|
|
|
BMenuBar * menuBar =
|
|
|
|
|
dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
|
|
|
|
|
|
|
|
|
|
fOpenPanelEncodingMenu= new BMenu("Encoding");
|
|
|
|
|
menuBar->AddItem(fOpenPanelEncodingMenu);
|
|
|
|
|
|
|
|
|
|
// TODO: add encodings
|
|
|
|
|
|
2002-09-23 23:01:55 +00:00
|
|
|
fWindowCount= 0;
|
|
|
|
|
fNext_Untitled_Window= 1;
|
2002-11-05 09:24:25 +00:00
|
|
|
styled_edit_app = this;
|
|
|
|
|
} /***StyledEditApp::StyledEditApp()***/
|
2002-09-23 23:01:55 +00:00
|
|
|
|
|
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
void
|
|
|
|
|
StyledEditApp::MessageReceived(BMessage *message)
|
|
|
|
|
{
|
|
|
|
|
switch(message->what) {
|
|
|
|
|
case MENU_NEW:
|
|
|
|
|
OpenDocument();
|
|
|
|
|
break;
|
2002-09-23 23:01:55 +00:00
|
|
|
case MENU_OPEN:
|
|
|
|
|
fOpenPanel->Show(); //
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
BApplication::MessageReceived(message);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
void
|
|
|
|
|
StyledEditApp::OpenDocument()
|
|
|
|
|
{
|
|
|
|
|
new StyledEditWindow(windowRect,fNext_Untitled_Window++);
|
2002-11-06 23:03:34 +00:00
|
|
|
windowRect.OffsetBy(15,15); // TODO: wrap around screen
|
2002-11-05 09:24:25 +00:00
|
|
|
fWindowCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
StyledEditApp::OpenDocument(entry_ref * ref)
|
|
|
|
|
{
|
|
|
|
|
new StyledEditWindow(windowRect,ref);
|
2002-11-06 23:03:34 +00:00
|
|
|
windowRect.OffsetBy(15,15); // TODO: wrap around screen
|
2002-11-05 09:24:25 +00:00
|
|
|
fWindowCount++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
StyledEditApp::CloseDocument()
|
|
|
|
|
{
|
|
|
|
|
fWindowCount--;
|
|
|
|
|
if (fWindowCount == 0) {
|
|
|
|
|
BAutolock lock(this);
|
|
|
|
|
Quit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
StyledEditApp::RefsReceived(BMessage *message)
|
|
|
|
|
{
|
2002-09-23 23:01:55 +00:00
|
|
|
int32 refNum;
|
|
|
|
|
entry_ref ref;
|
|
|
|
|
status_t err;
|
|
|
|
|
|
|
|
|
|
refNum=0;
|
2002-11-05 09:24:25 +00:00
|
|
|
do {
|
2002-09-23 23:01:55 +00:00
|
|
|
if((err= message->FindRef("refs", refNum, &ref)) != B_OK)
|
|
|
|
|
return;
|
2002-11-05 09:24:25 +00:00
|
|
|
OpenDocument(&ref);
|
2002-09-23 23:01:55 +00:00
|
|
|
refNum++;
|
|
|
|
|
} while(1);
|
|
|
|
|
} /***StyledEditApp::RefsReceived();***/
|
|
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
void
|
|
|
|
|
StyledEditApp::ReadyToRun()
|
|
|
|
|
{
|
|
|
|
|
if (fWindowCount == 0) {
|
|
|
|
|
OpenDocument();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32
|
|
|
|
|
StyledEditApp::NumberOfWindows()
|
|
|
|
|
{
|
2002-09-23 23:01:55 +00:00
|
|
|
|
|
|
|
|
return fWindowCount;
|
|
|
|
|
|
|
|
|
|
}/***StyledEditApp::NumberOfWindows()***/
|
|
|
|
|
|
2002-11-05 09:24:25 +00:00
|
|
|
int
|
|
|
|
|
main()
|
|
|
|
|
{
|
|
|
|
|
StyledEditApp styledEdit;
|
|
|
|
|
styledEdit.Run();
|
2002-09-23 23:01:55 +00:00
|
|
|
return 0;
|
2002-11-05 09:24:25 +00:00
|
|
|
}
|
2002-09-27 04:47:23 +00:00
|
|
|
|