style cleanup ; undo, revert, redo, save, quit functions fixed up ; no more extra windows ; quit when all windows are closed ; fix grey lines when scrolling
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1848 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,13 +2,8 @@
|
|||||||
#ifndef CONSTANTS_H
|
#ifndef CONSTANTS_H
|
||||||
#define CONSTANTS_H
|
#define CONSTANTS_H
|
||||||
|
|
||||||
#ifndef _GRAPHICS_DEFS_H
|
|
||||||
#include <GraphicsDefs.h>
|
#include <GraphicsDefs.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _SUPPORT_DEFS_H
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
//See if this takes care of some problems with closing the application
|
//See if this takes care of some problems with closing the application
|
||||||
//by clicking the windowtab
|
//by clicking the windowtab
|
||||||
@@ -17,7 +12,6 @@
|
|||||||
//seems to work, 021021
|
//seems to work, 021021
|
||||||
#define APP_SIGNATURE "application/x-vnd.obos.styled-edit"
|
#define APP_SIGNATURE "application/x-vnd.obos.styled-edit"
|
||||||
|
|
||||||
const float MENU_BAR_HEIGHT= 19.0;
|
|
||||||
const float TEXT_INSET= 3.0;
|
const float TEXT_INSET= 3.0;
|
||||||
|
|
||||||
/*Messages for window registry with application*/
|
/*Messages for window registry with application*/
|
||||||
@@ -73,8 +67,4 @@ const uint32 DISABLE_ITEMS ='DIit';
|
|||||||
const uint32 CHANGE_WINDOW ='CHwi';
|
const uint32 CHANGE_WINDOW ='CHwi';
|
||||||
const uint32 TEXT_CHANGED ='TEch';
|
const uint32 TEXT_CHANGED ='TEch';
|
||||||
|
|
||||||
|
#endif // CONSTANTS_H
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,88 +1,102 @@
|
|||||||
|
|
||||||
#ifndef CONSTANTS_H
|
#include <Autolock.h>
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef STYLED_EDIT_APP
|
|
||||||
#include "StyledEditApp.h"
|
#include "StyledEditApp.h"
|
||||||
#endif
|
#include "StyledEditWindow.h"
|
||||||
|
|
||||||
|
BRect windowRect(7,25,599,399);
|
||||||
|
|
||||||
BRect windowRect(50,50,599,399);
|
StyledEditApp * styled_edit_app;
|
||||||
|
|
||||||
StyledEditApp::StyledEditApp()
|
StyledEditApp::StyledEditApp()
|
||||||
: BApplication(APP_SIGNATURE)
|
: BApplication(APP_SIGNATURE)
|
||||||
{
|
{
|
||||||
|
|
||||||
new StyledEditWindow(windowRect);
|
|
||||||
fOpenPanel= new BFilePanel;
|
fOpenPanel= new BFilePanel;
|
||||||
|
|
||||||
fWindowCount= 0;
|
fWindowCount= 0;
|
||||||
fNext_Untitled_Window= 1;
|
fNext_Untitled_Window= 1;
|
||||||
} /***StyledEditApp::StyledEditApp()***/
|
styled_edit_app = this;
|
||||||
|
} /***StyledEditApp::StyledEditApp()***/
|
||||||
|
|
||||||
|
|
||||||
void StyledEditApp::MessageReceived(BMessage *message){
|
void
|
||||||
switch(message->what){
|
StyledEditApp::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
switch(message->what) {
|
||||||
|
case MENU_NEW:
|
||||||
|
OpenDocument();
|
||||||
|
break;
|
||||||
case MENU_OPEN:
|
case MENU_OPEN:
|
||||||
fOpenPanel->Show(); //
|
fOpenPanel->Show(); //
|
||||||
break;
|
break;
|
||||||
case WINDOW_REGISTRY_ADD:
|
|
||||||
{
|
|
||||||
bool need_id= false;
|
|
||||||
BMessage reply(WINDOW_REGISTRY_ADDED);
|
|
||||||
|
|
||||||
if(message->FindBool("need_id", &need_id)== B_OK)
|
|
||||||
{
|
|
||||||
if(need_id)
|
|
||||||
{
|
|
||||||
reply.AddInt32("new_window_number", fNext_Untitled_Window);
|
|
||||||
fNext_Untitled_Window++;
|
|
||||||
}
|
|
||||||
fWindowCount++;
|
|
||||||
}
|
|
||||||
reply.AddRect("rect",windowRect);
|
|
||||||
windowRect.OffsetBy(20,20);
|
|
||||||
message->SendReply(&reply);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case WINDOW_REGISTRY_SUB:
|
|
||||||
fWindowCount--;
|
|
||||||
if (!fWindowCount)
|
|
||||||
{
|
|
||||||
Quit();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
BApplication::MessageReceived(message);
|
BApplication::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledEditApp::RefsReceived(BMessage *message){
|
void
|
||||||
|
StyledEditApp::OpenDocument()
|
||||||
|
{
|
||||||
|
new StyledEditWindow(windowRect,fNext_Untitled_Window++);
|
||||||
|
windowRect.OffsetBy(20,20); // todo: wrap around screen
|
||||||
|
fWindowCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StyledEditApp::OpenDocument(entry_ref * ref)
|
||||||
|
{
|
||||||
|
new StyledEditWindow(windowRect,ref);
|
||||||
|
windowRect.OffsetBy(20,20); // todo: wrap around screen
|
||||||
|
fWindowCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StyledEditApp::CloseDocument()
|
||||||
|
{
|
||||||
|
fWindowCount--;
|
||||||
|
if (fWindowCount == 0) {
|
||||||
|
BAutolock lock(this);
|
||||||
|
Quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StyledEditApp::RefsReceived(BMessage *message)
|
||||||
|
{
|
||||||
int32 refNum;
|
int32 refNum;
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
refNum=0;
|
refNum=0;
|
||||||
do{
|
do {
|
||||||
if((err= message->FindRef("refs", refNum, &ref)) != B_OK)
|
if((err= message->FindRef("refs", refNum, &ref)) != B_OK)
|
||||||
return;
|
return;
|
||||||
new StyledEditWindow(windowRect, &ref);
|
OpenDocument(&ref);
|
||||||
refNum++;
|
refNum++;
|
||||||
} while(1);
|
} while(1);
|
||||||
} /***StyledEditApp::RefsReceived();***/
|
} /***StyledEditApp::RefsReceived();***/
|
||||||
|
|
||||||
int32 StyledEditApp::NumberOfWindows(){
|
void
|
||||||
|
StyledEditApp::ReadyToRun()
|
||||||
|
{
|
||||||
|
if (fWindowCount == 0) {
|
||||||
|
OpenDocument();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int32
|
||||||
|
StyledEditApp::NumberOfWindows()
|
||||||
|
{
|
||||||
|
|
||||||
return fWindowCount;
|
return fWindowCount;
|
||||||
|
|
||||||
}/***StyledEditApp::NumberOfWindows()***/
|
}/***StyledEditApp::NumberOfWindows()***/
|
||||||
|
|
||||||
int main(){
|
int
|
||||||
StyledEditApp StyledEdit;
|
main()
|
||||||
StyledEdit.Run();
|
{
|
||||||
|
StyledEditApp styledEdit;
|
||||||
|
styledEdit.Run();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,31 +2,33 @@
|
|||||||
#ifndef STYLED_EDIT_APP
|
#ifndef STYLED_EDIT_APP
|
||||||
#define STYLED_EDIT_APP
|
#define STYLED_EDIT_APP
|
||||||
|
|
||||||
#ifndef _APPLICATION_H
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#endif
|
#include <Message.h>
|
||||||
|
#include <FilePanel.h>
|
||||||
|
|
||||||
#ifndef STYLED_EDIT_WINDOW_H
|
class StyledEditWindow;
|
||||||
#include "StyledEditWindow.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class StyledEditApp: public BApplication{
|
class StyledEditApp
|
||||||
public:
|
: public BApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
StyledEditApp();
|
StyledEditApp();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void RefsReceived(BMessage *message);
|
virtual void RefsReceived(BMessage *message);
|
||||||
|
virtual void ReadyToRun();
|
||||||
|
|
||||||
int32 NumberOfWindows();
|
int32 NumberOfWindows();
|
||||||
|
void OpenDocument();
|
||||||
|
void OpenDocument(entry_ref * ref);
|
||||||
|
void CloseDocument();
|
||||||
|
|
||||||
|
private:
|
||||||
private:
|
|
||||||
BFilePanel *fOpenPanel;
|
BFilePanel *fOpenPanel;
|
||||||
int32 fWindowCount;
|
int32 fWindowCount;
|
||||||
int32 fNext_Untitled_Window;
|
int32 fNext_Untitled_Window;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern StyledEditApp * styled_edit_app;
|
||||||
|
|
||||||
|
#endif // STYLED_EDIT_APP
|
||||||
|
|||||||
@@ -1,36 +1,27 @@
|
|||||||
#ifndef STYLED_EDIT_VIEW_H
|
|
||||||
#include "StyledEditView.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MESSAGE_H
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONSTANTS_H
|
|
||||||
#include "Constants.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MESSENGER_H
|
|
||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _RECT_H
|
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#endif
|
#include <TranslationUtils.h>
|
||||||
|
|
||||||
|
#include "StyledEditView.h"
|
||||||
|
#include "Constants.h"
|
||||||
|
|
||||||
|
StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, BHandler *handler)
|
||||||
StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, BHandler *handler) : BTextView(viewFrame, "textview",
|
: BTextView(viewFrame, "textview", textBounds,
|
||||||
textBounds, B_FOLLOW_ALL, B_FRAME_EVENTS|B_WILL_DRAW){
|
B_FOLLOW_ALL, B_FRAME_EVENTS|B_WILL_DRAW)
|
||||||
|
{
|
||||||
fHandler= handler;
|
fHandler= handler;
|
||||||
fMessenger= new BMessenger(handler);
|
fMessenger= new BMessenger(handler);
|
||||||
}/***StyledEditView()***/
|
fSuppressChanges = false;
|
||||||
|
}/***StyledEditView()***/
|
||||||
|
|
||||||
StyledEditView::~StyledEditView(){
|
StyledEditView::~StyledEditView(){
|
||||||
|
|
||||||
}/***~StyledEditView***/
|
}/***~StyledEditView***/
|
||||||
|
|
||||||
void StyledEditView::FrameResized(float width, float height){
|
void
|
||||||
|
StyledEditView::FrameResized(float width, float height)
|
||||||
|
{
|
||||||
BTextView::FrameResized(width, height);
|
BTextView::FrameResized(width, height);
|
||||||
|
|
||||||
if(DoesWordWrap()){
|
if(DoesWordWrap()){
|
||||||
@@ -42,8 +33,27 @@ void StyledEditView::FrameResized(float width, float height){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledEditView::Select(int32 start, int32 finish){
|
status_t
|
||||||
|
StyledEditView::GetStyledText(BPositionIO * stream)
|
||||||
|
{
|
||||||
|
status_t result = B_OK;
|
||||||
|
fSuppressChanges = true;
|
||||||
|
result = BTranslationUtils::GetStyledText(stream, this, NULL);
|
||||||
|
fSuppressChanges = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StyledEditView::Reset()
|
||||||
|
{
|
||||||
|
fSuppressChanges = true;
|
||||||
|
SetText("");
|
||||||
|
fSuppressChanges = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StyledEditView::Select(int32 start, int32 finish)
|
||||||
|
{
|
||||||
if(start==finish)
|
if(start==finish)
|
||||||
fChangeMessage= new BMessage(DISABLE_ITEMS);
|
fChangeMessage= new BMessage(DISABLE_ITEMS);
|
||||||
else
|
else
|
||||||
@@ -54,40 +64,20 @@ void StyledEditView::Select(int32 start, int32 finish){
|
|||||||
BTextView::Select(start, finish);
|
BTextView::Select(start, finish);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StyledEditView::InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs){
|
void StyledEditView::InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs)
|
||||||
|
{
|
||||||
|
if (!fSuppressChanges)
|
||||||
fMessenger-> SendMessage(new BMessage(TEXT_CHANGED));
|
fMessenger-> SendMessage(new BMessage(TEXT_CHANGED));
|
||||||
|
|
||||||
BTextView::InsertText(text, length, offset, runs);
|
BTextView::InsertText(text, length, offset, runs);
|
||||||
|
|
||||||
}/****StyledEditView::InsertText()***/
|
}/****StyledEditView::InsertText()***/
|
||||||
|
|
||||||
void StyledEditView::DeleteText(int32 start, int32 finish){
|
void StyledEditView::DeleteText(int32 start, int32 finish)
|
||||||
|
{
|
||||||
|
if (!fSuppressChanges)
|
||||||
fMessenger-> SendMessage(new BMessage(TEXT_CHANGED));
|
fMessenger-> SendMessage(new BMessage(TEXT_CHANGED));
|
||||||
|
|
||||||
BTextView::DeleteText(start, finish);
|
BTextView::DeleteText(start, finish);
|
||||||
|
|
||||||
}/***StyledEditView::DeleteText***/
|
}/***StyledEditView::DeleteText***/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,34 +1,28 @@
|
|||||||
#ifndef STYLED_EDIT_VIEW_H
|
#ifndef STYLED_EDIT_VIEW_H
|
||||||
#define STYLED_EDIT_VIEW_H
|
#define STYLED_EDIT_VIEW_H
|
||||||
|
|
||||||
#ifndef _TEXTVIEW_H
|
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
#endif
|
#include <DataIO.h>
|
||||||
|
|
||||||
class StyledEditView : public BTextView {
|
class StyledEditView : public BTextView {
|
||||||
public:
|
public:
|
||||||
StyledEditView(BRect viewframe, BRect textframe, BHandler *handler);
|
StyledEditView(BRect viewframe, BRect textframe, BHandler *handler);
|
||||||
~StyledEditView();
|
~StyledEditView();
|
||||||
|
|
||||||
virtual void Select(int32 start, int32 finish);
|
virtual void Select(int32 start, int32 finish);
|
||||||
virtual void FrameResized(float width, float height);
|
virtual void FrameResized(float width, float height);
|
||||||
protected:
|
|
||||||
|
virtual void Reset();
|
||||||
|
virtual status_t GetStyledText(BPositionIO * stream);
|
||||||
|
protected:
|
||||||
virtual void InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs);
|
virtual void InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs);
|
||||||
virtual void DeleteText(int32 start, int32 finish);
|
virtual void DeleteText(int32 start, int32 finish);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BHandler *fHandler;
|
BHandler *fHandler;
|
||||||
BMessage *fChangeMessage;
|
BMessage *fChangeMessage;
|
||||||
BMessenger *fMessenger;
|
BMessenger *fMessenger;
|
||||||
|
bool fSuppressChanges;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif // STYLED_EDIT_VIEW_H
|
||||||
|
|||||||
@@ -1,111 +1,74 @@
|
|||||||
// Be-defined headers
|
// Be-defined headers
|
||||||
|
|
||||||
#ifndef _ALERT_H
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#endif
|
#include <Autolock.h>
|
||||||
|
#include <Debug.h>
|
||||||
#ifndef _CLIPBOARD_H
|
|
||||||
#include <Clipboard.h>
|
#include <Clipboard.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _FILE_H
|
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MENU_H
|
|
||||||
#include <Menu.h>
|
#include <Menu.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MENU_ITEM_H
|
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _PRINTSESSION_H
|
|
||||||
#include <PrintJob.h>
|
#include <PrintJob.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _SCROLL_VIEW_H
|
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _STDLIB_H
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _STRING_H
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _TRANSLATION_UTILS_H
|
|
||||||
#include <TranslationUtils.h>
|
#include <TranslationUtils.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _WINDOW_H
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
//****** Application defined header files************/.
|
//****** Application defined header files************/.
|
||||||
#ifndef CONSTANTS_H
|
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef COLOR_MENU_ITEM_H
|
|
||||||
#include "ColorMenuItem.h"
|
#include "ColorMenuItem.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FIND_WINDOW_H
|
|
||||||
#include "FindWindow.h"
|
#include "FindWindow.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef REPLACE_WINDOW_H
|
|
||||||
#include "ReplaceWindow.h"
|
#include "ReplaceWindow.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef STYLED_EDIT_APP
|
|
||||||
#include "StyledEditApp.h"
|
#include "StyledEditApp.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef STYLED_EDIT_VIEW_H
|
|
||||||
#include "StyledEditView.h"
|
#include "StyledEditView.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef STYLED_EDIT_WINDOW_H
|
|
||||||
#include "StyledEditWindow.h"
|
#include "StyledEditWindow.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
StyledEditWindow::StyledEditWindow(BRect frame)
|
StyledEditWindow::StyledEditWindow(BRect frame, int32 id)
|
||||||
: BWindow(frame,"untitled",B_DOCUMENT_WINDOW,0){
|
: BWindow(frame,"untitled",B_DOCUMENT_WINDOW,0)
|
||||||
|
{
|
||||||
InitWindow();
|
InitWindow();
|
||||||
|
BString unTitled;
|
||||||
|
unTitled.SetTo("Untitled ");
|
||||||
|
unTitled << id;
|
||||||
|
SetTitle(unTitled.String());
|
||||||
|
fSaveItem->SetEnabled(true); // allow saving empty files
|
||||||
Show();
|
Show();
|
||||||
}/***StyledEditWindow()***/
|
} /***StyledEditWindow()***/
|
||||||
|
|
||||||
StyledEditWindow::StyledEditWindow(BRect frame, entry_ref *ref)
|
StyledEditWindow::StyledEditWindow(BRect frame, entry_ref *ref)
|
||||||
: BWindow(frame,"untitled",B_DOCUMENT_WINDOW,0)
|
: BWindow(frame,"untitled",B_DOCUMENT_WINDOW,0)
|
||||||
{
|
{
|
||||||
InitWindow();
|
InitWindow();
|
||||||
OpenFile(ref);
|
OpenFile(ref);
|
||||||
Show();
|
Show();
|
||||||
} /***StyledEditWindow()***/
|
} /***StyledEditWindow()***/
|
||||||
|
|
||||||
StyledEditWindow::~StyledEditWindow(){
|
StyledEditWindow::~StyledEditWindow()
|
||||||
Unregister();
|
{
|
||||||
|
if (fSaveMessage)
|
||||||
if(fSaveMessage)
|
|
||||||
delete fSaveMessage;
|
delete fSaveMessage;
|
||||||
if(fPrintSettings)
|
if (fPrintSettings)
|
||||||
delete fPrintSettings;
|
delete fPrintSettings;
|
||||||
|
|
||||||
delete fSavePanel;
|
delete fSavePanel;
|
||||||
}/***~StyledEditWindow()***/
|
} /***~StyledEditWindow()***/
|
||||||
|
|
||||||
void StyledEditWindow::InitWindow(){
|
|
||||||
|
|
||||||
|
void
|
||||||
|
StyledEditWindow::InitWindow()
|
||||||
|
{
|
||||||
fPrintSettings= NULL;
|
fPrintSettings= NULL;
|
||||||
fSaveMessage= NULL;
|
fSaveMessage= NULL;
|
||||||
fEnableItems= false;
|
|
||||||
fFirstEdit= true;
|
// undo modes
|
||||||
fUnDoneFlag= false;
|
fUndoFlag = false;
|
||||||
fTextSaved= true; //initial state, no text changed.
|
fCanUndo = false;
|
||||||
|
fRedoFlag = false;
|
||||||
|
fCanRedo = false;
|
||||||
|
|
||||||
|
// clean modes
|
||||||
|
fUndoCleans = false;
|
||||||
|
fRedoCleans = false;
|
||||||
|
fClean = true;
|
||||||
|
|
||||||
//search- state
|
//search- state
|
||||||
fReplaceString= "";
|
fReplaceString= "";
|
||||||
@@ -115,10 +78,7 @@ void StyledEditWindow::InitWindow(){
|
|||||||
fBackSearch= false;
|
fBackSearch= false;
|
||||||
|
|
||||||
//add menubar
|
//add menubar
|
||||||
BRect menuBarRect;
|
fMenuBar = new BMenuBar(BRect(0,0,0,0),"menubar");
|
||||||
|
|
||||||
menuBarRect= Bounds();
|
|
||||||
fMenuBar= new BMenuBar(menuBarRect,"menubar");
|
|
||||||
|
|
||||||
AddChild(fMenuBar);
|
AddChild(fMenuBar);
|
||||||
|
|
||||||
@@ -128,7 +88,7 @@ void StyledEditWindow::InitWindow(){
|
|||||||
|
|
||||||
viewFrame= Bounds();
|
viewFrame= Bounds();
|
||||||
|
|
||||||
viewFrame.top = MENU_BAR_HEIGHT; //021021
|
viewFrame.top = fMenuBar->Bounds().Height()+1; //021021
|
||||||
viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
|
viewFrame.right -= B_V_SCROLL_BAR_WIDTH;
|
||||||
viewFrame.left = B_V_SCROLL_BAR_WIDTH-15; //021021
|
viewFrame.left = B_V_SCROLL_BAR_WIDTH-15; //021021
|
||||||
viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
viewFrame.bottom -= B_H_SCROLL_BAR_HEIGHT;
|
||||||
@@ -140,13 +100,13 @@ void StyledEditWindow::InitWindow(){
|
|||||||
|
|
||||||
|
|
||||||
fTextView= new StyledEditView(viewFrame, textBounds, this);
|
fTextView= new StyledEditView(viewFrame, textBounds, this);
|
||||||
fTextView-> SetDoesUndo(true);
|
fTextView->SetDoesUndo(true);
|
||||||
fTextView-> SetStylable(true);
|
fTextView->SetStylable(true);
|
||||||
|
|
||||||
|
|
||||||
fScrollView= new BScrollView("scrollview", fTextView, B_FOLLOW_ALL, 0, true, true, B_NO_BORDER);
|
fScrollView= new BScrollView("scrollview", fTextView, B_FOLLOW_ALL, 0, true, true, B_PLAIN_BORDER);
|
||||||
AddChild(fScrollView);
|
AddChild(fScrollView);
|
||||||
fTextView-> MakeFocus(true);
|
fTextView->MakeFocus(true);
|
||||||
|
|
||||||
|
|
||||||
//Add "File"-menu:
|
//Add "File"-menu:
|
||||||
@@ -155,120 +115,121 @@ void StyledEditWindow::InitWindow(){
|
|||||||
BMenuItem *menuItem;
|
BMenuItem *menuItem;
|
||||||
|
|
||||||
menu= new BMenu("File");
|
menu= new BMenu("File");
|
||||||
fMenuBar-> AddItem(menu);
|
fMenuBar->AddItem(menu);
|
||||||
|
|
||||||
menu-> AddItem(menuItem= new BMenuItem("New", new BMessage(MENU_NEW), 'N'));
|
menu->AddItem(menuItem= new BMenuItem("New", new BMessage(MENU_NEW), 'N'));
|
||||||
menu-> AddItem(menuItem= new BMenuItem(new BMenu("Open..."), new BMessage(MENU_OPEN)));
|
menuItem->SetTarget(be_app);
|
||||||
|
|
||||||
|
menu->AddItem(menuItem= new BMenuItem(new BMenu("Open..."), new BMessage(MENU_OPEN)));
|
||||||
menuItem->SetShortcut('O',0);
|
menuItem->SetShortcut('O',0);
|
||||||
menuItem->SetTarget(be_app);
|
menuItem->SetTarget(be_app);
|
||||||
menu-> AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
menu-> AddItem(fSaveItem= new BMenuItem("Save", new BMessage(MENU_SAVE), 'S'));
|
menu->AddItem(fSaveItem= new BMenuItem("Save", new BMessage(MENU_SAVE), 'S'));
|
||||||
fSaveItem-> SetEnabled(false);
|
fSaveItem->SetEnabled(false);
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Save As...", new BMessage(MENU_SAVEAS)));
|
menu->AddItem(menuItem= new BMenuItem("Save As...", new BMessage(MENU_SAVEAS)));
|
||||||
menuItem-> SetEnabled(true);
|
menuItem->SetEnabled(true);
|
||||||
|
|
||||||
menu-> AddItem(fRevertItem= new BMenuItem("Revert to Saved", new BMessage(MENU_REVERT)));
|
menu->AddItem(fRevertItem= new BMenuItem("Revert to Saved", new BMessage(MENU_REVERT)));
|
||||||
fRevertItem-> SetEnabled(false);
|
fRevertItem->SetEnabled(false);
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Close", new BMessage(MENU_CLOSE), 'W'));
|
menu->AddItem(menuItem= new BMenuItem("Close", new BMessage(MENU_CLOSE), 'W'));
|
||||||
|
|
||||||
menu-> AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Page Setup" B_UTF8_ELLIPSIS, new BMessage(MENU_PAGESETUP)));
|
menu->AddItem(menuItem= new BMenuItem("Page Setup" B_UTF8_ELLIPSIS, new BMessage(MENU_PAGESETUP)));
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Print" B_UTF8_ELLIPSIS, new BMessage(MENU_PRINT), 'P'));
|
menu->AddItem(menuItem= new BMenuItem("Print" B_UTF8_ELLIPSIS, new BMessage(MENU_PRINT), 'P'));
|
||||||
|
|
||||||
menu-> AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Quit", new BMessage(MENU_QUIT), 'Q'));
|
menu->AddItem(menuItem= new BMenuItem("Quit", new BMessage(MENU_QUIT), 'Q'));
|
||||||
|
|
||||||
//Add the "Edit"-menu:
|
//Add the "Edit"-menu:
|
||||||
menu= new BMenu("Edit");
|
menu= new BMenu("Edit");
|
||||||
fMenuBar-> AddItem(menu);
|
fMenuBar->AddItem(menu);
|
||||||
|
|
||||||
menu-> AddItem(fUndoItem= new BMenuItem("Can't Undo", new BMessage(B_UNDO), 'Z'));
|
menu->AddItem(fUndoItem= new BMenuItem("Can't Undo", new BMessage(B_UNDO), 'Z'));
|
||||||
fUndoItem-> SetEnabled(false);
|
fUndoItem->SetEnabled(false);
|
||||||
fUndoItem-> SetTarget(fTextView);
|
|
||||||
|
|
||||||
menu-> AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu-> AddItem(fCutItem= new BMenuItem("Cut", new BMessage(B_CUT), 'X'));
|
menu->AddItem(fCutItem= new BMenuItem("Cut", new BMessage(B_CUT), 'X'));
|
||||||
fCutItem->SetEnabled(false);
|
fCutItem->SetEnabled(false);
|
||||||
fCutItem-> SetTarget(fTextView);
|
fCutItem->SetTarget(fTextView);
|
||||||
|
|
||||||
menu-> AddItem(fCopyItem= new BMenuItem("Copy", new BMessage(B_COPY), 'C'));
|
menu->AddItem(fCopyItem= new BMenuItem("Copy", new BMessage(B_COPY), 'C'));
|
||||||
fCopyItem-> SetEnabled(false);
|
fCopyItem->SetEnabled(false);
|
||||||
fCopyItem-> SetTarget(fTextView);
|
fCopyItem->SetTarget(fTextView);
|
||||||
|
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Paste", new BMessage(B_PASTE), 'V'));
|
menu->AddItem(menuItem= new BMenuItem("Paste", new BMessage(B_PASTE), 'V'));
|
||||||
menuItem-> SetTarget(fTextView);
|
menuItem->SetTarget(fTextView);
|
||||||
menu-> AddItem(fClearItem= new BMenuItem("Clear", new BMessage(MENU_CLEAR)));
|
menu->AddItem(fClearItem= new BMenuItem("Clear", new BMessage(MENU_CLEAR)));
|
||||||
fClearItem-> SetEnabled(false);
|
fClearItem->SetEnabled(false);
|
||||||
fClearItem-> SetTarget(fTextView);
|
fClearItem->SetTarget(fTextView);
|
||||||
|
|
||||||
|
|
||||||
menu-> AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu-> AddItem(menuItem=new BMenuItem("Select All", new BMessage(B_SELECT_ALL), 'A'));
|
menu->AddItem(menuItem=new BMenuItem("Select All", new BMessage(B_SELECT_ALL), 'A'));
|
||||||
menuItem-> SetTarget(fTextView);
|
menuItem->SetTarget(fTextView);
|
||||||
|
|
||||||
menu-> AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Find...", new BMessage(MENU_FIND),'F'));
|
menu->AddItem(menuItem= new BMenuItem("Find...", new BMessage(MENU_FIND),'F'));
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Find Again",new BMessage(MENU_FIND_AGAIN),'G'));
|
menu->AddItem(menuItem= new BMenuItem("Find Again",new BMessage(MENU_FIND_AGAIN),'G'));
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Find Selection", new BMessage(MENU_FIND_SELECTION),'H'));
|
menu->AddItem(menuItem= new BMenuItem("Find Selection", new BMessage(MENU_FIND_SELECTION),'H'));
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Replace...", new BMessage(MENU_REPLACE),'R'));
|
menu->AddItem(menuItem= new BMenuItem("Replace...", new BMessage(MENU_REPLACE),'R'));
|
||||||
menu-> AddItem(menuItem= new BMenuItem("Replace Same", new BMessage(MENU_REPLACE_SAME),'T'));
|
menu->AddItem(menuItem= new BMenuItem("Replace Same", new BMessage(MENU_REPLACE_SAME),'T'));
|
||||||
|
|
||||||
//Add the "Font"-menu:
|
//Add the "Font"-menu:
|
||||||
BMessage *fontMessage;
|
BMessage *fontMessage;
|
||||||
menu= new BMenu("Font");
|
menu= new BMenu("Font");
|
||||||
fMenuBar-> AddItem(menu);
|
fMenuBar->AddItem(menu);
|
||||||
|
|
||||||
//"Size"-subMenu
|
//"Size"-subMenu
|
||||||
subMenu=new BMenu("Size");
|
subMenu=new BMenu("Size");
|
||||||
subMenu-> SetRadioMode(true);
|
subMenu->SetRadioMode(true);
|
||||||
menu-> AddItem(subMenu);
|
menu->AddItem(subMenu);
|
||||||
|
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("9", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("9", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size", 9.0);
|
fontMessage->AddFloat("size", 9.0);
|
||||||
|
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("10", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("10", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size",10.0);
|
fontMessage->AddFloat("size",10.0);
|
||||||
menuItem-> SetMarked(true);
|
menuItem->SetMarked(true);
|
||||||
|
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("12", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("12", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size",12.0);
|
fontMessage->AddFloat("size",12.0);
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("14", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("14", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size",14.0);
|
fontMessage->AddFloat("size",14.0);
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("18", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("18", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size",18.0);
|
fontMessage->AddFloat("size",18.0);
|
||||||
|
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("24", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("24", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size",24.0);
|
fontMessage->AddFloat("size",24.0);
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("36", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("36", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size",36.0);
|
fontMessage->AddFloat("size",36.0);
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("48", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("48", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size",48.0);
|
fontMessage->AddFloat("size",48.0);
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("72", fontMessage= new BMessage(FONT_SIZE)));
|
subMenu->AddItem(menuItem= new BMenuItem("72", fontMessage= new BMessage(FONT_SIZE)));
|
||||||
fontMessage-> AddFloat("size",72.0);
|
fontMessage->AddFloat("size",72.0);
|
||||||
|
|
||||||
//"Color"-subMenu
|
//"Color"-subMenu
|
||||||
subMenu= new BMenu("Color");
|
subMenu= new BMenu("Color");
|
||||||
subMenu->SetRadioMode(true);
|
subMenu->SetRadioMode(true);
|
||||||
menu-> AddItem(subMenu);
|
menu->AddItem(subMenu);
|
||||||
|
|
||||||
ColorMenuItem *ColorItem;
|
ColorMenuItem *ColorItem;
|
||||||
|
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("Black", fontMessage= new BMessage(FONT_COLOR)));
|
subMenu->AddItem(menuItem= new BMenuItem("Black", fontMessage= new BMessage(FONT_COLOR)));
|
||||||
fontMessage-> AddPointer("colour",&BLACK);
|
fontMessage->AddPointer("colour",&BLACK);
|
||||||
menuItem-> SetMarked(true);
|
menuItem->SetMarked(true);
|
||||||
subMenu-> AddItem(ColorItem= new ColorMenuItem("Red", RED, fontMessage= new BMessage(FONT_COLOR)));
|
subMenu->AddItem(ColorItem= new ColorMenuItem("Red", RED, fontMessage= new BMessage(FONT_COLOR)));
|
||||||
fontMessage-> AddPointer("colour", &RED);
|
fontMessage->AddPointer("colour", &RED);
|
||||||
subMenu-> AddItem(ColorItem= new ColorMenuItem("Green", GREEN, fontMessage= new BMessage(FONT_COLOR)));
|
subMenu->AddItem(ColorItem= new ColorMenuItem("Green", GREEN, fontMessage= new BMessage(FONT_COLOR)));
|
||||||
fontMessage-> AddPointer("colour", &GREEN);
|
fontMessage->AddPointer("colour", &GREEN);
|
||||||
subMenu-> AddItem(ColorItem= new ColorMenuItem("Blue", BLUE, fontMessage= new BMessage(FONT_COLOR)));
|
subMenu->AddItem(ColorItem= new ColorMenuItem("Blue", BLUE, fontMessage= new BMessage(FONT_COLOR)));
|
||||||
fontMessage-> AddPointer("colour", &BLUE);
|
fontMessage->AddPointer("colour", &BLUE);
|
||||||
subMenu-> AddItem(ColorItem= new ColorMenuItem("Cyan", CYAN, fontMessage= new BMessage(FONT_COLOR)));
|
subMenu->AddItem(ColorItem= new ColorMenuItem("Cyan", CYAN, fontMessage= new BMessage(FONT_COLOR)));
|
||||||
fontMessage-> AddPointer("colour",&CYAN);
|
fontMessage->AddPointer("colour",&CYAN);
|
||||||
subMenu-> AddItem(ColorItem= new ColorMenuItem("Magenta", MAGENTA, fontMessage= new BMessage(FONT_COLOR)));
|
subMenu->AddItem(ColorItem= new ColorMenuItem("Magenta", MAGENTA, fontMessage= new BMessage(FONT_COLOR)));
|
||||||
fontMessage-> AddPointer("colour", &MAGENTA);
|
fontMessage->AddPointer("colour", &MAGENTA);
|
||||||
subMenu-> AddItem(ColorItem= new ColorMenuItem("Yellow", YELLOW, fontMessage= new BMessage(FONT_COLOR)));
|
subMenu->AddItem(ColorItem= new ColorMenuItem("Yellow", YELLOW, fontMessage= new BMessage(FONT_COLOR)));
|
||||||
fontMessage-> AddPointer("colour", &YELLOW);
|
fontMessage->AddPointer("colour", &YELLOW);
|
||||||
menu->AddSeparatorItem();
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
//Available fonts
|
//Available fonts
|
||||||
@@ -278,7 +239,7 @@ void StyledEditWindow::InitWindow(){
|
|||||||
font_family localfamily;
|
font_family localfamily;
|
||||||
if ( get_font_family ( i, &localfamily ) == B_OK ) {
|
if ( get_font_family ( i, &localfamily ) == B_OK ) {
|
||||||
subMenu=new BMenu(localfamily);
|
subMenu=new BMenu(localfamily);
|
||||||
subMenu-> SetRadioMode(true);
|
subMenu->SetRadioMode(true);
|
||||||
menu->AddItem(subMenu);
|
menu->AddItem(subMenu);
|
||||||
menu->SetRadioMode(true);
|
menu->SetRadioMode(true);
|
||||||
int32 numStyles=count_font_styles(localfamily);
|
int32 numStyles=count_font_styles(localfamily);
|
||||||
@@ -286,9 +247,9 @@ void StyledEditWindow::InitWindow(){
|
|||||||
font_style style;
|
font_style style;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
if( get_font_style(localfamily,j,&style,&flags)==B_OK){
|
if( get_font_style(localfamily,j,&style,&flags)==B_OK){
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem(style, fontMessage= new BMessage(FONT_STYLE)));
|
subMenu->AddItem(menuItem= new BMenuItem(style, fontMessage= new BMessage(FONT_STYLE)));
|
||||||
fontMessage-> AddString("FontFamily", localfamily);
|
fontMessage->AddString("FontFamily", localfamily);
|
||||||
fontMessage-> AddString("FontStyle", style);
|
fontMessage->AddString("FontStyle", style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -296,60 +257,30 @@ void StyledEditWindow::InitWindow(){
|
|||||||
|
|
||||||
//Add the "Document"-menu:
|
//Add the "Document"-menu:
|
||||||
menu= new BMenu("Document");
|
menu= new BMenu("Document");
|
||||||
fMenuBar-> AddItem(menu);
|
fMenuBar->AddItem(menu);
|
||||||
|
|
||||||
//"Align"-subMenu:
|
//"Align"-subMenu:
|
||||||
subMenu= new BMenu("Align");
|
subMenu= new BMenu("Align");
|
||||||
subMenu-> SetRadioMode(true);
|
subMenu->SetRadioMode(true);
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("Left", new BMessage(ALIGN_LEFT)));
|
subMenu->AddItem(menuItem= new BMenuItem("Left", new BMessage(ALIGN_LEFT)));
|
||||||
menuItem-> SetMarked(true);
|
menuItem->SetMarked(true);
|
||||||
|
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("Center", new BMessage(ALIGN_CENTER)));
|
subMenu->AddItem(menuItem= new BMenuItem("Center", new BMessage(ALIGN_CENTER)));
|
||||||
subMenu-> AddItem(menuItem= new BMenuItem("Right", new BMessage(ALIGN_RIGHT)));
|
subMenu->AddItem(menuItem= new BMenuItem("Right", new BMessage(ALIGN_RIGHT)));
|
||||||
menu-> AddItem(subMenu);
|
menu->AddItem(subMenu);
|
||||||
menu-> AddItem(fWrapItem= new BMenuItem("Wrap Lines", new BMessage(WRAP_LINES)));
|
menu->AddItem(fWrapItem= new BMenuItem("Wrap Lines", new BMessage(WRAP_LINES)));
|
||||||
fWrapItem-> SetMarked(true);
|
fWrapItem->SetMarked(true);
|
||||||
/***************************MENUS ADDED***********************/
|
/***************************MENUS ADDED***********************/
|
||||||
|
|
||||||
|
|
||||||
fSavePanel= new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false);
|
fSavePanel= new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, B_FILE_NODE, false);
|
||||||
Register(true);
|
|
||||||
|
|
||||||
} /***StyledEditWindow::Initwindow()***/
|
} /***StyledEditWindow::Initwindow()***/
|
||||||
|
|
||||||
void StyledEditWindow::MessageReceived(BMessage *message){
|
void
|
||||||
|
StyledEditWindow::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
switch(message->what){
|
switch(message->what){
|
||||||
case WINDOW_REGISTRY_ADDED:
|
|
||||||
{
|
|
||||||
|
|
||||||
BRect rect;
|
|
||||||
if (message->FindInt32("new_window_number", &fWindow_Id) == B_OK)
|
|
||||||
{
|
|
||||||
if (!fSaveMessage)
|
|
||||||
{
|
|
||||||
BString unTitled;
|
|
||||||
unTitled.SetTo("Untitled ");
|
|
||||||
unTitled << fWindow_Id;
|
|
||||||
const char *title= unTitled.String();
|
|
||||||
SetTitle(title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (message->FindRect("rect", &rect) == B_OK)
|
|
||||||
{
|
|
||||||
MoveTo(rect.LeftTop());
|
|
||||||
ResizeTo(rect.Width(), rect.Height());
|
|
||||||
}
|
|
||||||
Minimize(false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/************file menu:***************/
|
/************file menu:***************/
|
||||||
case MENU_NEW:
|
|
||||||
{
|
|
||||||
BRect newViewFrame;
|
|
||||||
newViewFrame= Frame();
|
|
||||||
new StyledEditWindow(newViewFrame);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MENU_SAVE:
|
case MENU_SAVE:
|
||||||
{
|
{
|
||||||
if(!fSaveMessage)
|
if(!fSaveMessage)
|
||||||
@@ -368,9 +299,11 @@ void StyledEditWindow::InitWindow(){
|
|||||||
RevertToSaved();
|
RevertToSaved();
|
||||||
break;
|
break;
|
||||||
case MENU_CLOSE:{
|
case MENU_CLOSE:{
|
||||||
if(this->QuitRequested())
|
if(this->QuitRequested()) {
|
||||||
|
BAutolock lock(this);
|
||||||
Quit();
|
Quit();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_PAGESETUP:
|
case MENU_PAGESETUP:
|
||||||
PageSetup(fTextView->Window()->Title());
|
PageSetup(fTextView->Window()->Title());
|
||||||
@@ -383,6 +316,14 @@ void StyledEditWindow::InitWindow(){
|
|||||||
break;
|
break;
|
||||||
/*********commands from the "Edit"-menu:**************/
|
/*********commands from the "Edit"-menu:**************/
|
||||||
case B_UNDO:
|
case B_UNDO:
|
||||||
|
ASSERT(fCanUndo || fCanRedo);
|
||||||
|
ASSERT(!(fCanUndo && fCanRedo));
|
||||||
|
if (fCanUndo) {
|
||||||
|
fUndoFlag = true;
|
||||||
|
}
|
||||||
|
if (fCanRedo) {
|
||||||
|
fRedoFlag = true;
|
||||||
|
}
|
||||||
fTextView->Undo(be_clipboard);
|
fTextView->Undo(be_clipboard);
|
||||||
break;
|
break;
|
||||||
case B_CUT:
|
case B_CUT:
|
||||||
@@ -474,7 +415,7 @@ void StyledEditWindow::InitWindow(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*********"Font"-menu*****************/
|
/*********"Font"-menu*****************/
|
||||||
case FONT_SIZE:
|
case FONT_SIZE:
|
||||||
{
|
{
|
||||||
float fontSize;
|
float fontSize;
|
||||||
@@ -485,8 +426,8 @@ void StyledEditWindow::InitWindow(){
|
|||||||
case FONT_STYLE:
|
case FONT_STYLE:
|
||||||
{
|
{
|
||||||
const char *fontFamily,*fontStyle;
|
const char *fontFamily,*fontStyle;
|
||||||
message-> FindString("FontFamily",&fontFamily);
|
message->FindString("FontFamily",&fontFamily);
|
||||||
message-> FindString("FontStyle",&fontStyle);
|
message->FindString("FontStyle",&fontStyle);
|
||||||
SetFontStyle(fontFamily, fontStyle);
|
SetFontStyle(fontFamily, fontStyle);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -495,12 +436,12 @@ void StyledEditWindow::InitWindow(){
|
|||||||
void *v;
|
void *v;
|
||||||
rgb_color *color;
|
rgb_color *color;
|
||||||
|
|
||||||
message-> FindPointer("colour",&v);
|
message->FindPointer("colour",&v);
|
||||||
color= (rgb_color *) v;
|
color= (rgb_color *) v;
|
||||||
SetFontColor(color);
|
SetFontColor(color);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/*********"Document"-menu*************/
|
/*********"Document"-menu*************/
|
||||||
case ALIGN_LEFT:
|
case ALIGN_LEFT:
|
||||||
fTextView->SetAlignment(B_ALIGN_LEFT);
|
fTextView->SetAlignment(B_ALIGN_LEFT);
|
||||||
break;
|
break;
|
||||||
@@ -536,52 +477,75 @@ void StyledEditWindow::InitWindow(){
|
|||||||
break;
|
break;
|
||||||
case TEXT_CHANGED:
|
case TEXT_CHANGED:
|
||||||
{
|
{
|
||||||
fSaveItem-> SetEnabled(true);
|
if (fUndoFlag) {
|
||||||
fTextSaved= false;
|
if (fUndoCleans) {
|
||||||
|
// we cleaned!
|
||||||
if(fFirstEdit){
|
fClean = true;
|
||||||
fUndoItem-> SetLabel("Undo Typing");
|
fUndoCleans = false;
|
||||||
fUndoItem-> SetEnabled(true);
|
} else if (fClean) {
|
||||||
|
// if we were clean
|
||||||
|
// then a redo will make us clean again
|
||||||
|
fRedoCleans = true;
|
||||||
|
fClean = false;
|
||||||
}
|
}
|
||||||
|
// set mode
|
||||||
if (fUnDoneFlag){
|
fCanUndo = false;
|
||||||
|
fCanRedo = true;
|
||||||
fUndoItem->SetLabel("Redo Typing");
|
fUndoItem->SetLabel("Redo Typing");
|
||||||
fUnDoneFlag= false;
|
fUndoItem->SetEnabled(true);
|
||||||
|
fUndoFlag = false;
|
||||||
|
} else {
|
||||||
|
if (fRedoFlag && fRedoCleans) {
|
||||||
|
// we cleaned!
|
||||||
|
fClean = true;
|
||||||
|
fRedoCleans = false;
|
||||||
|
} else if (fClean) {
|
||||||
|
// if we were clean
|
||||||
|
// then an undo will make us clean again
|
||||||
|
fUndoCleans = true;
|
||||||
|
fClean = false;
|
||||||
|
} else {
|
||||||
|
// no more cleaning from undo now...
|
||||||
|
fUndoCleans = false;
|
||||||
}
|
}
|
||||||
else{
|
// set mode
|
||||||
|
fCanUndo = true;
|
||||||
|
fCanRedo = false;
|
||||||
fUndoItem->SetLabel("Undo Typing");
|
fUndoItem->SetLabel("Undo Typing");
|
||||||
fUnDoneFlag= true;
|
fUndoItem->SetEnabled(true);
|
||||||
|
fRedoFlag = false;
|
||||||
}
|
}
|
||||||
|
if (fClean) {
|
||||||
|
fRevertItem->SetEnabled(false);
|
||||||
|
fSaveItem->SetEnabled(fSaveMessage == NULL);
|
||||||
|
} else {
|
||||||
|
fRevertItem->SetEnabled(fSaveMessage != NULL);
|
||||||
|
fSaveItem->SetEnabled(true);
|
||||||
|
}
|
||||||
|
// clear flags
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}/***StyledEditWindow::MessageReceived() ***/
|
}/***StyledEditWindow::MessageReceived() ***/
|
||||||
|
|
||||||
|
|
||||||
void StyledEditWindow::Register(bool need_id) {
|
void
|
||||||
BMessenger messenger(APP_SIGNATURE);
|
StyledEditWindow::Quit()
|
||||||
BMessage message(WINDOW_REGISTRY_ADD);
|
{
|
||||||
|
styled_edit_app->CloseDocument();
|
||||||
message.AddBool("need_id", need_id);
|
BWindow::Quit();
|
||||||
messenger.SendMessage(&message, this);
|
}
|
||||||
}/***Register()***/
|
|
||||||
|
|
||||||
|
|
||||||
void StyledEditWindow::Unregister(void){
|
|
||||||
BMessenger messenger(APP_SIGNATURE);
|
|
||||||
messenger.SendMessage(new BMessage(WINDOW_REGISTRY_SUB));
|
|
||||||
}/***Unregister()***/
|
|
||||||
|
|
||||||
|
|
||||||
bool StyledEditWindow::QuitRequested(){
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
StyledEditWindow::QuitRequested()
|
||||||
|
{
|
||||||
int32 buttonIndex= 0;
|
int32 buttonIndex= 0;
|
||||||
|
|
||||||
if(!fTextSaved){
|
if (fClean) return true;
|
||||||
|
|
||||||
BAlert *saveAlert;
|
BAlert *saveAlert;
|
||||||
BString alertText;
|
BString alertText;
|
||||||
alertText.SetTo("Save changes to the document ");
|
alertText.SetTo("Save changes to the document ");
|
||||||
@@ -589,29 +553,26 @@ bool StyledEditWindow::QuitRequested(){
|
|||||||
alertText<<"? ";
|
alertText<<"? ";
|
||||||
saveAlert= new BAlert("savealert",alertText.String(), "Cancel", "Don't save","Save",
|
saveAlert= new BAlert("savealert",alertText.String(), "Cancel", "Don't save","Save",
|
||||||
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
|
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
|
||||||
saveAlert-> SetShortcut(0, B_ESCAPE);
|
saveAlert->SetShortcut(0, B_ESCAPE);
|
||||||
buttonIndex= saveAlert-> Go();
|
buttonIndex= saveAlert->Go();
|
||||||
|
|
||||||
|
if (buttonIndex==0) { //"cancel": dont save, dont close the window
|
||||||
if(buttonIndex==0) //"cancel": dont save, dont close the window
|
|
||||||
return false;
|
return false;
|
||||||
else if(buttonIndex==1) // "don't save": just close the window
|
} else if(buttonIndex==1) { // "don't save": just close the window
|
||||||
return true;
|
return true;
|
||||||
else if(!fSaveMessage){ //save as
|
} else if(!fSaveMessage) { //save as
|
||||||
DispatchMessage(new BMessage(MENU_SAVEAS), this);
|
DispatchMessage(new BMessage(MENU_SAVEAS), this);
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
DispatchMessage(new BMessage(B_SAVE_REQUESTED), this);
|
DispatchMessage(new BMessage(B_SAVE_REQUESTED), this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}/***QuitRequested()***/
|
}/***QuitRequested()***/
|
||||||
|
|
||||||
status_t StyledEditWindow::Save(BMessage *message){
|
status_t
|
||||||
|
StyledEditWindow::Save(BMessage *message)
|
||||||
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
const char *name;
|
const char *name;
|
||||||
status_t err;
|
status_t err;
|
||||||
@@ -654,14 +615,18 @@ status_t StyledEditWindow::Save(BMessage *message){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fSaveItem-> SetEnabled(false);
|
// clear clean modes
|
||||||
fTextSaved= true;
|
fSaveItem->SetEnabled(false);
|
||||||
fRevertItem-> SetEnabled(true);
|
fRevertItem->SetEnabled(false);
|
||||||
|
fUndoCleans = false;
|
||||||
|
fRedoCleans = false;
|
||||||
|
fClean = true;
|
||||||
return err;
|
return err;
|
||||||
} /***Save()***/
|
} /***Save()***/
|
||||||
|
|
||||||
void StyledEditWindow::OpenFile(entry_ref *ref){
|
void
|
||||||
|
StyledEditWindow::OpenFile(entry_ref *ref)
|
||||||
|
{
|
||||||
BFile file;
|
BFile file;
|
||||||
status_t fileinit;
|
status_t fileinit;
|
||||||
|
|
||||||
@@ -669,7 +634,7 @@ void StyledEditWindow::OpenFile(entry_ref *ref){
|
|||||||
|
|
||||||
if(fileinit== B_OK){
|
if(fileinit== B_OK){
|
||||||
status_t result;
|
status_t result;
|
||||||
result= BTranslationUtils::GetStyledText(&file, fTextView, NULL); //he he he :)
|
result = fTextView->GetStyledText(&file); //he he he :)
|
||||||
|
|
||||||
if(result==B_OK){
|
if(result==B_OK){
|
||||||
fSaveMessage= new BMessage(B_SAVE_REQUESTED);
|
fSaveMessage= new BMessage(B_SAVE_REQUESTED);
|
||||||
@@ -685,14 +650,14 @@ void StyledEditWindow::OpenFile(entry_ref *ref){
|
|||||||
fSaveMessage->AddRef("directory",&parentRef);
|
fSaveMessage->AddRef("directory",&parentRef);
|
||||||
fSaveMessage->AddString("name", name);
|
fSaveMessage->AddString("name", name);
|
||||||
SetTitle(name);
|
SetTitle(name);
|
||||||
fRevertItem-> SetEnabled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}/*** StyledEditWindow::OpenFile() ***/
|
}/*** StyledEditWindow::OpenFile() ***/
|
||||||
|
|
||||||
void StyledEditWindow::RevertToSaved(){
|
void
|
||||||
//translationutils here as well
|
StyledEditWindow::RevertToSaved()
|
||||||
|
{ //translationutils here as well
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
@@ -702,12 +667,27 @@ void StyledEditWindow::RevertToSaved(){
|
|||||||
BDirectory dir(&ref);
|
BDirectory dir(&ref);
|
||||||
|
|
||||||
BFile file(&dir, name, B_READ_ONLY | B_CREATE_FILE);
|
BFile file(&dir, name, B_READ_ONLY | B_CREATE_FILE);
|
||||||
fTextView->SetText(""); //clear the textview...
|
fTextView->Reset(); //clear the textview...
|
||||||
BTranslationUtils::GetStyledText(&file, fTextView, NULL); //and fill it from the file
|
fTextView->GetStyledText(&file); //and fill it from the file
|
||||||
|
|
||||||
|
// clear undo modes
|
||||||
|
fUndoItem->SetLabel("Can't Undo");
|
||||||
|
fUndoItem->SetEnabled(false);
|
||||||
|
fUndoFlag = false;
|
||||||
|
fCanUndo = false;
|
||||||
|
fRedoFlag = false;
|
||||||
|
fCanRedo = false;
|
||||||
|
// clear clean modes
|
||||||
|
fSaveItem->SetEnabled(false);
|
||||||
|
fRevertItem->SetEnabled(false);
|
||||||
|
fUndoCleans = false;
|
||||||
|
fRedoCleans = false;
|
||||||
|
fClean = true;
|
||||||
}/***StyledEditWindow::RevertToSaved()***/
|
}/***StyledEditWindow::RevertToSaved()***/
|
||||||
|
|
||||||
status_t StyledEditWindow::PageSetup(const char *documentname){
|
status_t
|
||||||
|
StyledEditWindow::PageSetup(const char *documentname)
|
||||||
|
{
|
||||||
status_t result= B_ERROR;
|
status_t result= B_ERROR;
|
||||||
|
|
||||||
BPrintJob printJob(documentname);
|
BPrintJob printJob(documentname);
|
||||||
@@ -727,8 +707,9 @@ status_t StyledEditWindow::PageSetup(const char *documentname){
|
|||||||
return result;
|
return result;
|
||||||
}/***StyledEditWindow::PageSetup()***/
|
}/***StyledEditWindow::PageSetup()***/
|
||||||
|
|
||||||
void StyledEditWindow::Print(const char *documentname){
|
void
|
||||||
|
StyledEditWindow::Print(const char *documentname)
|
||||||
|
{
|
||||||
BPrintJob printJob(documentname);
|
BPrintJob printJob(documentname);
|
||||||
|
|
||||||
if (fPrintSettings== NULL){
|
if (fPrintSettings== NULL){
|
||||||
@@ -775,8 +756,9 @@ void StyledEditWindow::Print(const char *documentname){
|
|||||||
}
|
}
|
||||||
}/***StyledEditWindow::Print()***/
|
}/***StyledEditWindow::Print()***/
|
||||||
|
|
||||||
bool StyledEditWindow::Search(BString string, bool casesens, bool wrap, bool backsearch){
|
bool
|
||||||
|
StyledEditWindow::Search(BString string, bool casesens, bool wrap, bool backsearch)
|
||||||
|
{
|
||||||
int32 start;
|
int32 start;
|
||||||
int32 finish;
|
int32 finish;
|
||||||
int32 strlen;
|
int32 strlen;
|
||||||
@@ -801,19 +783,19 @@ bool StyledEditWindow::Search(BString string, bool casesens, bool wrap, bool bac
|
|||||||
else
|
else
|
||||||
start= viewText.IFindFirst(string, textFinish); //i.e this one...
|
start= viewText.IFindFirst(string, textFinish); //i.e this one...
|
||||||
|
|
||||||
|
if(start!= B_ERROR) {
|
||||||
if(start!= B_ERROR){
|
|
||||||
finish= start+ strlen;
|
finish= start+ strlen;
|
||||||
fTextView->Select(start, finish);
|
fTextView->Select(start, finish);
|
||||||
fTextView->ScrollToSelection();
|
fTextView->ScrollToSelection();
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}/***StyledEditWindow::Search***/
|
}/***StyledEditWindow::Search***/
|
||||||
|
|
||||||
void StyledEditWindow::FindSelection(){
|
void
|
||||||
|
StyledEditWindow::FindSelection()
|
||||||
|
{
|
||||||
int32 selectionStart, selectionFinish;
|
int32 selectionStart, selectionFinish;
|
||||||
fTextView->GetSelection(&selectionStart,&selectionFinish);
|
fTextView->GetSelection(&selectionStart,&selectionFinish);
|
||||||
|
|
||||||
@@ -828,8 +810,9 @@ void StyledEditWindow::FindSelection(){
|
|||||||
|
|
||||||
}/***StyledEditWindow::FindSelection()***/
|
}/***StyledEditWindow::FindSelection()***/
|
||||||
|
|
||||||
void StyledEditWindow::Replace(BString findthis, BString replaceWith, bool casesens, bool wrap, bool backsearch){
|
void
|
||||||
|
StyledEditWindow::Replace(BString findthis, BString replaceWith, bool casesens, bool wrap, bool backsearch)
|
||||||
|
{
|
||||||
int32 start;
|
int32 start;
|
||||||
int32 replaceLength;
|
int32 replaceLength;
|
||||||
int32 findLength;
|
int32 findLength;
|
||||||
@@ -862,15 +845,17 @@ void StyledEditWindow::Replace(BString findthis, BString replaceWith, bool case
|
|||||||
|
|
||||||
}/***StyledEditWindow::Replace()***/
|
}/***StyledEditWindow::Replace()***/
|
||||||
|
|
||||||
void StyledEditWindow::ReplaceAll(BString findIt, BString replaceWith, bool caseSens){
|
void
|
||||||
|
StyledEditWindow::ReplaceAll(BString findIt, BString replaceWith, bool caseSens)
|
||||||
|
{
|
||||||
while(Search(findIt, caseSens, true, false))
|
while(Search(findIt, caseSens, true, false))
|
||||||
Replace(findIt, replaceWith, caseSens, true, false);
|
Replace(findIt, replaceWith, caseSens, true, false);
|
||||||
|
|
||||||
}/***StyledEditWindow::ReplaceAll()***/
|
}/***StyledEditWindow::ReplaceAll()***/
|
||||||
|
|
||||||
void StyledEditWindow::SearchAllWindows(BString find, BString replace, bool casesens){
|
void
|
||||||
|
StyledEditWindow::SearchAllWindows(BString find, BString replace, bool casesens)
|
||||||
|
{
|
||||||
int32 numWindows;
|
int32 numWindows;
|
||||||
numWindows= be_app->CountWindows();
|
numWindows= be_app->CountWindows();
|
||||||
|
|
||||||
@@ -893,8 +878,9 @@ void StyledEditWindow::SearchAllWindows(BString find, BString replace, bool case
|
|||||||
}/***StyledEditWindow::SearchAllWindows***/
|
}/***StyledEditWindow::SearchAllWindows***/
|
||||||
|
|
||||||
|
|
||||||
void StyledEditWindow::SetFontSize(float fontSize){
|
void
|
||||||
|
StyledEditWindow::SetFontSize(float fontSize)
|
||||||
|
{
|
||||||
uint32 sameProperties;
|
uint32 sameProperties;
|
||||||
BFont font;
|
BFont font;
|
||||||
|
|
||||||
@@ -903,16 +889,20 @@ void StyledEditWindow::SetFontSize(float fontSize){
|
|||||||
fTextView->SetFontAndColor(&font,B_FONT_SIZE);
|
fTextView->SetFontAndColor(&font,B_FONT_SIZE);
|
||||||
}/***StyledEditWindow::SetFontSize()***/
|
}/***StyledEditWindow::SetFontSize()***/
|
||||||
|
|
||||||
void StyledEditWindow::SetFontColor(rgb_color *color){
|
void
|
||||||
|
StyledEditWindow::SetFontColor(rgb_color *color)
|
||||||
|
{
|
||||||
uint32 sameProperties;
|
uint32 sameProperties;
|
||||||
BFont font;
|
BFont font;
|
||||||
|
|
||||||
fTextView-> GetFontAndColor(&font,&sameProperties,NULL,NULL);
|
fTextView->GetFontAndColor(&font,&sameProperties,NULL,NULL);
|
||||||
fTextView-> SetFontAndColor(&font, B_FONT_ALL,color);
|
fTextView->SetFontAndColor(&font, B_FONT_ALL,color);
|
||||||
|
|
||||||
}/***StyledEditWindow::SetFontColor()***/
|
}/***StyledEditWindow::SetFontColor()***/
|
||||||
|
|
||||||
void StyledEditWindow::SetFontStyle(const char *fontFamily, const char *fontStyle){
|
void
|
||||||
|
StyledEditWindow::SetFontStyle(const char *fontFamily, const char *fontStyle)
|
||||||
|
{
|
||||||
BFont font;
|
BFont font;
|
||||||
uint32 sameProperties;
|
uint32 sameProperties;
|
||||||
|
|
||||||
@@ -922,7 +912,6 @@ void StyledEditWindow::SetFontStyle(const char *fontFamily, const char *fontStyl
|
|||||||
|
|
||||||
BMenuItem *superItem;
|
BMenuItem *superItem;
|
||||||
superItem= fMenuBar->FindItem(fontFamily);
|
superItem= fMenuBar->FindItem(fontFamily);
|
||||||
superItem-> SetMarked(true);
|
superItem->SetMarked(true);
|
||||||
|
|
||||||
}/***StyledEditWindow::SetFontStyle()***/
|
}/***StyledEditWindow::SetFontStyle()***/
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +1,25 @@
|
|||||||
|
|
||||||
#ifndef STYLED_EDIT_WINDOW_H
|
#ifndef STYLED_EDIT_WINDOW_H
|
||||||
#define STYLED_EDIT_WINDOW_H
|
#define STYLED_EDIT_WINDOW_H
|
||||||
|
|
||||||
#ifndef _FILE_PANEL_H
|
|
||||||
#include <FilePanel.h>
|
#include <FilePanel.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MENUBAR_H
|
|
||||||
#include <MenuBar.h>
|
#include <MenuBar.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MESSAGE_H
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _RECT_H
|
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _STRING_H
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _TEXTVIEW_H
|
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _WINDOW_H
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef STYLED_EDIT_VIEW_H
|
class StyledEditView;
|
||||||
#include "StyledEditView.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
class StyledEditWindow
|
||||||
class StyledEditWindow: public BWindow{
|
: public BWindow
|
||||||
public:
|
{
|
||||||
StyledEditWindow(BRect frame);
|
public:
|
||||||
|
StyledEditWindow(BRect frame, int32 id);
|
||||||
StyledEditWindow(BRect frame, entry_ref *ref);
|
StyledEditWindow(BRect frame, entry_ref *ref);
|
||||||
~StyledEditWindow();
|
~StyledEditWindow();
|
||||||
|
|
||||||
|
virtual void Quit();
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
|
|
||||||
@@ -51,10 +29,8 @@ class StyledEditWindow: public BWindow{
|
|||||||
void Print(const char *documentname);
|
void Print(const char *documentname);
|
||||||
void SearchAllWindows(BString find, BString replace, bool casesens);
|
void SearchAllWindows(BString find, BString replace, bool casesens);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitWindow();
|
void InitWindow();
|
||||||
void Register(bool need_id);
|
|
||||||
void Unregister(void);
|
|
||||||
bool Search(BString searchfor, bool casesens, bool wrap, bool backsearch);
|
bool Search(BString searchfor, bool casesens, bool wrap, bool backsearch);
|
||||||
void FindSelection();
|
void FindSelection();
|
||||||
void Replace(BString findthis, BString replacewith, bool casesens, bool wrap, bool backsearch);
|
void Replace(BString findthis, BString replacewith, bool casesens, bool wrap, bool backsearch);
|
||||||
@@ -64,7 +40,6 @@ class StyledEditWindow: public BWindow{
|
|||||||
void SetFontStyle(const char *fontFamily, const char *fontStyle);
|
void SetFontStyle(const char *fontFamily, const char *fontStyle);
|
||||||
void RevertToSaved();
|
void RevertToSaved();
|
||||||
|
|
||||||
|
|
||||||
BMenuBar *fMenuBar;
|
BMenuBar *fMenuBar;
|
||||||
BMessage *fPrintSettings;
|
BMessage *fPrintSettings;
|
||||||
BMessage *fSaveMessage;
|
BMessage *fSaveMessage;
|
||||||
@@ -77,18 +52,26 @@ class StyledEditWindow: public BWindow{
|
|||||||
BMenuItem *fWrapItem;
|
BMenuItem *fWrapItem;
|
||||||
BString fStringToFind;
|
BString fStringToFind;
|
||||||
BString fReplaceString;
|
BString fReplaceString;
|
||||||
bool fEnableItems;
|
|
||||||
bool fFirstEdit;
|
// undo modes
|
||||||
bool fTextSaved;
|
bool fUndoFlag; // we just did an undo action
|
||||||
bool fUnDoneFlag;
|
bool fCanUndo; // we can do an undo action next
|
||||||
|
bool fRedoFlag; // we just did a redo action
|
||||||
|
bool fCanRedo; // we can do a redo action next
|
||||||
|
|
||||||
|
// clean modes
|
||||||
|
bool fUndoCleans; // an undo action will put us in a clean state
|
||||||
|
bool fRedoCleans; // a redo action will put us in a clean state
|
||||||
|
bool fClean; // we are in a clean state
|
||||||
|
|
||||||
bool fCaseSens;
|
bool fCaseSens;
|
||||||
bool fWrapAround;
|
bool fWrapAround;
|
||||||
bool fBackSearch;
|
bool fBackSearch;
|
||||||
|
|
||||||
StyledEditView *fTextView;
|
StyledEditView *fTextView;
|
||||||
BScrollView *fScrollView;
|
BScrollView *fScrollView;
|
||||||
BFilePanel *fSavePanel;
|
BFilePanel *fSavePanel;
|
||||||
int32 fWindow_Id;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif // STYLED_EDIT_WINDOW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user