Applied patch from "HOST", with a few small style fixes myself.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22163 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,14 +7,14 @@
|
|||||||
* Andrew Bachmann
|
* Andrew Bachmann
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ColorMenuItem.h"
|
#include "ColorMenuItem.h"
|
||||||
|
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
ColorMenuItem::ColorMenuItem(const char *label, rgb_color color, BMessage *message)
|
ColorMenuItem::ColorMenuItem(const char *label, rgb_color color, BMessage *message)
|
||||||
: BMenuItem(label, message, 0, 0)
|
: BMenuItem(label, message, 0, 0)
|
||||||
|
, fItemColor(color)
|
||||||
{
|
{
|
||||||
fItemColor = color;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -22,9 +22,11 @@ void
|
|||||||
ColorMenuItem::DrawContent()
|
ColorMenuItem::DrawContent()
|
||||||
{
|
{
|
||||||
BMenu *menu = Menu();
|
BMenu *menu = Menu();
|
||||||
rgb_color menuColor = menu->HighColor();
|
if (menu) {
|
||||||
|
rgb_color menuColor = menu->HighColor();
|
||||||
|
|
||||||
menu->SetHighColor(fItemColor);
|
menu->SetHighColor(fItemColor);
|
||||||
BMenuItem::DrawContent();
|
BMenuItem::DrawContent();
|
||||||
menu->SetHighColor(menuColor);
|
menu->SetHighColor(menuColor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,15 +13,16 @@
|
|||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BMessage;
|
||||||
|
|
||||||
|
|
||||||
class ColorMenuItem: public BMenuItem {
|
class ColorMenuItem: public BMenuItem {
|
||||||
public:
|
public:
|
||||||
ColorMenuItem(const char *label, rgb_color color, BMessage *message);
|
ColorMenuItem(const char *label, rgb_color color, BMessage *message);
|
||||||
|
void DrawContent();
|
||||||
protected:
|
|
||||||
virtual void DrawContent();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rgb_color fItemColor;
|
rgb_color fItemColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COLOR_MENU_ITEM_H
|
#endif // COLOR_MENU_ITEM_H
|
||||||
|
|||||||
@@ -76,3 +76,4 @@ const uint32 SAVE_AS_ENCODING = 'FPse';
|
|||||||
const uint32 SAVE_THEN_QUIT = 'FPsq';
|
const uint32 SAVE_THEN_QUIT = 'FPsq';
|
||||||
|
|
||||||
#endif // CONSTANTS_H
|
#endif // CONSTANTS_H
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,11 @@
|
|||||||
|
|
||||||
|
|
||||||
FindWindow::FindWindow(BRect frame, BHandler *_handler, BString *searchString,
|
FindWindow::FindWindow(BRect frame, BHandler *_handler, BString *searchString,
|
||||||
bool *caseState, bool *wrapState, bool *backState)
|
bool caseState, bool wrapState, bool backState)
|
||||||
: BWindow(frame, "FindWindow", B_MODAL_WINDOW,
|
: BWindow(frame, "FindWindow", B_MODAL_WINDOW,
|
||||||
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS,
|
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE)
|
||||||
B_CURRENT_WORKSPACE)
|
|
||||||
{
|
{
|
||||||
AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
|
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||||
|
|
||||||
fFindView = new BView(Bounds(), "FindView", B_FOLLOW_ALL, B_WILL_DRAW);
|
fFindView = new BView(Bounds(), "FindView", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
fFindView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fFindView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -31,7 +30,7 @@ FindWindow::FindWindow(BRect frame, BHandler *_handler, BString *searchString,
|
|||||||
|
|
||||||
font_height height;
|
font_height height;
|
||||||
fFindView->GetFontHeight(&height);
|
fFindView->GetFontHeight(&height);
|
||||||
float lineHeight = height.ascent+height.descent + height.leading;
|
float lineHeight = height.ascent + height.descent + height.leading;
|
||||||
|
|
||||||
float findWidth = fFindView->StringWidth("Find:") + 6;
|
float findWidth = fFindView->StringWidth("Find:") + 6;
|
||||||
|
|
||||||
@@ -65,12 +64,12 @@ FindWindow::FindWindow(BRect frame, BHandler *_handler, BString *searchString,
|
|||||||
|
|
||||||
const char *text = searchString->String();
|
const char *text = searchString->String();
|
||||||
|
|
||||||
fSearchString->SetText(text);
|
fSearchString->SetText(text);
|
||||||
fSearchString->MakeFocus(true);
|
fSearchString->MakeFocus(true);
|
||||||
|
|
||||||
fCaseSensBox->SetValue(*caseState ? B_CONTROL_ON : B_CONTROL_OFF);
|
fCaseSensBox->SetValue(caseState ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
fWrapBox->SetValue(*wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
|
fWrapBox->SetValue(wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
fBackSearchBox->SetValue(*backState ? B_CONTROL_ON : B_CONTROL_OFF);
|
fBackSearchBox->SetValue(backState ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
|
||||||
class BButton;
|
class BButton;
|
||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
@@ -20,14 +21,14 @@ class BView;
|
|||||||
|
|
||||||
class FindWindow : public BWindow {
|
class FindWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
FindWindow(BRect frame, BHandler* handler, BString *searchString,
|
FindWindow(BRect frame, BHandler* handler, BString *searchString,
|
||||||
bool *caseState, bool *wrapState, bool *backState);
|
bool caseState, bool wrapState, bool backState);
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
void MessageReceived(BMessage* message);
|
||||||
virtual void DispatchMessage(BMessage* message, BHandler* handler);
|
void DispatchMessage(BMessage* message, BHandler* handler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _SendMessage();
|
void _SendMessage();
|
||||||
|
|
||||||
BView *fFindView;
|
BView *fFindView;
|
||||||
BTextControl *fSearchString;
|
BTextControl *fSearchString;
|
||||||
@@ -42,8 +43,3 @@ class FindWindow : public BWindow {
|
|||||||
|
|
||||||
#endif // FIND_WINDOW_H
|
#endif // FIND_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,21 +11,23 @@
|
|||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "ReplaceWindow.h"
|
#include "ReplaceWindow.h"
|
||||||
|
|
||||||
#include <Messenger.h>
|
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
#include <CheckBox.h>
|
#include <CheckBox.h>
|
||||||
|
#include <Handler.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <Rect.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
#include <Window.h>
|
#include <View.h>
|
||||||
|
|
||||||
|
|
||||||
ReplaceWindow::ReplaceWindow(BRect frame, BHandler *_handler, BString *searchString,
|
ReplaceWindow::ReplaceWindow(BRect frame, BHandler *_handler, BString *searchString,
|
||||||
BString *replaceString, bool *caseState, bool *wrapState, bool *backState)
|
BString *replaceString, bool caseState, bool wrapState, bool backState)
|
||||||
: BWindow(frame, "ReplaceWindow", B_MODAL_WINDOW,
|
: BWindow(frame, "ReplaceWindow", B_MODAL_WINDOW,
|
||||||
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS,
|
B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_CURRENT_WORKSPACE)
|
||||||
B_CURRENT_WORKSPACE)
|
|
||||||
{
|
{
|
||||||
AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
|
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
|
||||||
|
|
||||||
fReplaceView = new BView(Bounds(), "ReplaceView", B_FOLLOW_ALL, B_WILL_DRAW);
|
fReplaceView = new BView(Bounds(), "ReplaceView", B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
fReplaceView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
fReplaceView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
@@ -41,7 +43,7 @@ ReplaceWindow::ReplaceWindow(BRect frame, BHandler *_handler, BString *searchStr
|
|||||||
fReplaceView->AddChild(fReplaceString = new BTextControl(BRect(5, 35, 290, 50), "",
|
fReplaceView->AddChild(fReplaceString = new BTextControl(BRect(5, 35, 290, 50), "",
|
||||||
replaceWithLabel, NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
replaceWithLabel, NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW | B_NAVIGABLE));
|
B_WILL_DRAW | B_NAVIGABLE));
|
||||||
float maxWidth = (replaceWithWidth > findWidth ? replaceWithWidth : findWidth) + 1;
|
float maxWidth = (replaceWithWidth > findWidth ? replaceWithWidth : findWidth) + TEXT_INSET;
|
||||||
fSearchString->SetDivider(maxWidth);
|
fSearchString->SetDivider(maxWidth);
|
||||||
fReplaceString->SetDivider(maxWidth);
|
fReplaceString->SetDivider(maxWidth);
|
||||||
|
|
||||||
@@ -78,16 +80,16 @@ ReplaceWindow::ReplaceWindow(BRect frame, BHandler *_handler, BString *searchStr
|
|||||||
fReplaceString->SetText(replacetext);
|
fReplaceString->SetText(replacetext);
|
||||||
fSearchString->MakeFocus(true);
|
fSearchString->MakeFocus(true);
|
||||||
|
|
||||||
fCaseSensBox->SetValue(*caseState ? B_CONTROL_ON : B_CONTROL_OFF);
|
fCaseSensBox->SetValue(caseState ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
fWrapBox->SetValue(*wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
|
fWrapBox->SetValue(wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
fBackSearchBox->SetValue(*backState ? B_CONTROL_ON : B_CONTROL_OFF);
|
fBackSearchBox->SetValue(backState ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplaceWindow::MessageReceived(BMessage *msg)
|
ReplaceWindow::MessageReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
switch (msg->what){
|
switch (msg->what) {
|
||||||
case MSG_REPLACE:
|
case MSG_REPLACE:
|
||||||
_SendMessage(MSG_REPLACE);
|
_SendMessage(MSG_REPLACE);
|
||||||
break;
|
break;
|
||||||
@@ -108,22 +110,16 @@ ReplaceWindow::MessageReceived(BMessage *msg)
|
|||||||
void
|
void
|
||||||
ReplaceWindow::_ChangeUI()
|
ReplaceWindow::_ChangeUI()
|
||||||
{
|
{
|
||||||
if (!fUIchange) {
|
fWrapBox->SetEnabled(fUIchange);
|
||||||
fReplaceAllButton->MakeDefault(true);
|
fWrapBox->SetValue(fUIchange ? B_CONTROL_OFF : B_CONTROL_ON);
|
||||||
fReplaceButton->SetEnabled(false);
|
|
||||||
fWrapBox->SetValue(B_CONTROL_ON);
|
fBackSearchBox->SetEnabled(fUIchange);
|
||||||
fWrapBox->SetEnabled(false);
|
|
||||||
fBackSearchBox->SetEnabled(false);
|
fReplaceButton->SetEnabled(fUIchange);
|
||||||
fUIchange = true;
|
fUIchange ? fReplaceButton->MakeDefault(true)
|
||||||
} else {
|
: fReplaceAllButton->MakeDefault(true);
|
||||||
fReplaceButton->MakeDefault(true);
|
|
||||||
fReplaceButton->SetEnabled(true);
|
fUIchange = !fUIchange;
|
||||||
fReplaceAllButton->SetEnabled(true);
|
|
||||||
fWrapBox->SetValue(B_CONTROL_OFF);
|
|
||||||
fWrapBox->SetEnabled(true);
|
|
||||||
fBackSearchBox->SetEnabled(true);
|
|
||||||
fUIchange = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,27 +11,29 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
#include <Rect.h>
|
|
||||||
#include <Handler.h>
|
|
||||||
#include <String.h>
|
class BView;
|
||||||
#include <Message.h>
|
class BString;
|
||||||
#include <View.h>
|
class BButton;
|
||||||
#include <TextControl.h>
|
class BHandler;
|
||||||
#include <CheckBox.h>
|
class BMessage;
|
||||||
#include <Button.h>
|
class BCheckBox;
|
||||||
|
class BTextControl;
|
||||||
|
|
||||||
|
|
||||||
class ReplaceWindow : public BWindow {
|
class ReplaceWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
ReplaceWindow(BRect frame, BHandler *_handler,BString *searchString,
|
ReplaceWindow(BRect frame, BHandler *_handler,
|
||||||
BString *replaceString, bool *caseState, bool *wrapState, bool *backState);
|
BString *searchString, BString *replaceString,
|
||||||
|
bool caseState, bool wrapState, bool backState);
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
void MessageReceived(BMessage* message);
|
||||||
virtual void DispatchMessage(BMessage* message, BHandler *handler);
|
void DispatchMessage(BMessage* message, BHandler *handler);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _SendMessage(uint32 what);
|
void _SendMessage(uint32 what);
|
||||||
void _ChangeUI();
|
void _ChangeUI();
|
||||||
|
|
||||||
BView *fReplaceView;
|
BView *fReplaceView;
|
||||||
BTextControl *fSearchString;
|
BTextControl *fSearchString;
|
||||||
@@ -48,3 +50,4 @@ class ReplaceWindow : public BWindow {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // REPLACE_WINDOW_H
|
#endif // REPLACE_WINDOW_H
|
||||||
|
|
||||||
|
|||||||
@@ -8,61 +8,70 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Alert.h>
|
|
||||||
#include <Autolock.h>
|
|
||||||
#include <Path.h>
|
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <CharacterSet.h>
|
|
||||||
#include <CharacterSetRoster.h>
|
|
||||||
#include <Screen.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "StyledEditApp.h"
|
#include "StyledEditApp.h"
|
||||||
#include "StyledEditWindow.h"
|
#include "StyledEditWindow.h"
|
||||||
|
|
||||||
|
#include <Alert.h>
|
||||||
|
#include <Autolock.h>
|
||||||
|
#include <MenuBar.h>
|
||||||
|
#include <CharacterSet.h>
|
||||||
|
#include <CharacterSetRoster.h>
|
||||||
|
#include <FilePanel.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
StyledEditApp * styled_edit_app;
|
StyledEditApp * styled_edit_app;
|
||||||
BRect gWindowRect(7-15, 26-15, 507, 426);
|
BRect gWindowRect(7-15, 26-15, 507, 426);
|
||||||
|
|
||||||
|
|
||||||
void
|
namespace
|
||||||
cascade()
|
|
||||||
{
|
{
|
||||||
BScreen screen(NULL);
|
void
|
||||||
BRect screenBorder = screen.Frame();
|
cascade()
|
||||||
float left = gWindowRect.left + 15;
|
{
|
||||||
if (left + gWindowRect.Width() > screenBorder.right)
|
BScreen screen(NULL);
|
||||||
left = 7;
|
BRect screenBorder = screen.Frame();
|
||||||
|
float left = gWindowRect.left + 15;
|
||||||
|
if (left + gWindowRect.Width() > screenBorder.right)
|
||||||
|
left = 7;
|
||||||
|
|
||||||
float top = gWindowRect.top + 15;
|
float top = gWindowRect.top + 15;
|
||||||
if (top + gWindowRect.Height() > screenBorder.bottom)
|
if (top + gWindowRect.Height() > screenBorder.bottom)
|
||||||
top = 26;
|
top = 26;
|
||||||
|
|
||||||
gWindowRect.OffsetTo(BPoint(left,top));
|
gWindowRect.OffsetTo(BPoint(left,top));
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
uncascade()
|
|
||||||
{
|
|
||||||
BScreen screen(NULL);
|
|
||||||
BRect screenBorder = screen.Frame();
|
|
||||||
|
|
||||||
float left = gWindowRect.left - 15;
|
|
||||||
if (left < 7) {
|
|
||||||
left = screenBorder.right - gWindowRect.Width() - 7;
|
|
||||||
left = left - ((int)left % 15) + 7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float top = gWindowRect.top - 15;
|
|
||||||
if (top < 26) {
|
|
||||||
top = screenBorder.bottom - gWindowRect.Height() - 26;
|
|
||||||
top = top - ((int)left % 15) + 26;
|
|
||||||
}
|
|
||||||
|
|
||||||
gWindowRect.OffsetTo(BPoint(left,top));
|
void
|
||||||
|
uncascade()
|
||||||
|
{
|
||||||
|
BScreen screen(NULL);
|
||||||
|
BRect screenBorder = screen.Frame();
|
||||||
|
|
||||||
|
float left = gWindowRect.left - 15;
|
||||||
|
if (left < 7) {
|
||||||
|
left = screenBorder.right - gWindowRect.Width() - 7;
|
||||||
|
left = left - ((int)left % 15) + 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
float top = gWindowRect.top - 15;
|
||||||
|
if (top < 26) {
|
||||||
|
top = screenBorder.bottom - gWindowRect.Height() - 26;
|
||||||
|
top = top - ((int)left % 15) + 26;
|
||||||
|
}
|
||||||
|
|
||||||
|
gWindowRect.OffsetTo(BPoint(left,top));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,9 +80,10 @@ uncascade()
|
|||||||
|
|
||||||
StyledEditApp::StyledEditApp()
|
StyledEditApp::StyledEditApp()
|
||||||
: BApplication(APP_SIGNATURE)
|
: BApplication(APP_SIGNATURE)
|
||||||
|
, fOpenPanel(NULL)
|
||||||
{
|
{
|
||||||
fOpenPanel= new BFilePanel();
|
fOpenPanel = new BFilePanel();
|
||||||
BMenuBar * menuBar =
|
BMenuBar *menuBar =
|
||||||
dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
|
dynamic_cast<BMenuBar*>(fOpenPanel->Window()->FindView("MenuBar"));
|
||||||
|
|
||||||
fOpenAsEncoding = 0;
|
fOpenAsEncoding = 0;
|
||||||
@@ -110,6 +120,12 @@ StyledEditApp::StyledEditApp()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StyledEditApp::~StyledEditApp()
|
||||||
|
{
|
||||||
|
delete fOpenPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StyledEditApp::DispatchMessage(BMessage *msg, BHandler *handler)
|
StyledEditApp::DispatchMessage(BMessage *msg, BHandler *handler)
|
||||||
{
|
{
|
||||||
@@ -128,7 +144,7 @@ StyledEditApp::DispatchMessage(BMessage *msg, BHandler *handler)
|
|||||||
if (msg->FindString("cwd", &cwd) != B_OK)
|
if (msg->FindString("cwd", &cwd) != B_OK)
|
||||||
cwd = "";
|
cwd = "";
|
||||||
|
|
||||||
ArgvReceived(argc, argv, cwd);
|
ArgvReceivedEx(argc, argv, cwd);
|
||||||
} else
|
} else
|
||||||
BApplication::DispatchMessage(msg, handler);
|
BApplication::DispatchMessage(msg, handler);
|
||||||
}
|
}
|
||||||
@@ -205,7 +221,7 @@ StyledEditApp::RefsReceived(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StyledEditApp::ArgvReceived(int32 argc, const char* argv[], const char* cwd)
|
StyledEditApp::ArgvReceivedEx(int32 argc, const char* argv[], const char* cwd)
|
||||||
{
|
{
|
||||||
for (int i = 1 ; (i < argc) ; i++) {
|
for (int i = 1 ; (i < argc) ; i++) {
|
||||||
BPath path;
|
BPath path;
|
||||||
|
|||||||
@@ -11,36 +11,46 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Message.h>
|
|
||||||
#include <FilePanel.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
struct entry_ref;
|
||||||
|
|
||||||
|
class BMenu;
|
||||||
|
class BHandler;
|
||||||
|
class BMessage;
|
||||||
|
class BFilePanel;
|
||||||
class StyledEditWindow;
|
class StyledEditWindow;
|
||||||
|
|
||||||
|
|
||||||
class StyledEditApp : public BApplication {
|
class StyledEditApp : public BApplication {
|
||||||
public:
|
public:
|
||||||
StyledEditApp();
|
StyledEditApp();
|
||||||
virtual void MessageReceived(BMessage *message);
|
~StyledEditApp();
|
||||||
void ArgvReceived(int32 argc, const char *argv[], const char * cwd);
|
|
||||||
virtual void RefsReceived(BMessage *message);
|
|
||||||
virtual void ReadyToRun();
|
|
||||||
|
|
||||||
virtual void DispatchMessage(BMessage *an_event, BHandler *handler);
|
void MessageReceived(BMessage *message);
|
||||||
|
void RefsReceived(BMessage *message);
|
||||||
|
void ReadyToRun();
|
||||||
|
|
||||||
int32 NumberOfWindows();
|
void DispatchMessage(BMessage *an_event, BHandler *handler);
|
||||||
void OpenDocument();
|
|
||||||
void OpenDocument(entry_ref * ref);
|
int32 NumberOfWindows();
|
||||||
void CloseDocument();
|
void OpenDocument();
|
||||||
|
void OpenDocument(entry_ref * ref);
|
||||||
|
void CloseDocument();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BFilePanel* fOpenPanel;
|
void ArgvReceivedEx(int32 argc, const char *argv[], const char * cwd);
|
||||||
BMenu* fOpenPanelEncodingMenu;
|
|
||||||
uint32 fOpenAsEncoding;
|
private:
|
||||||
int32 fWindowCount;
|
BFilePanel *fOpenPanel;
|
||||||
int32 fNextUntitledWindow;
|
BMenu *fOpenPanelEncodingMenu;
|
||||||
|
uint32 fOpenAsEncoding;
|
||||||
|
int32 fWindowCount;
|
||||||
|
int32 fNextUntitledWindow;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern StyledEditApp* styled_edit_app;
|
extern StyledEditApp* styled_edit_app;
|
||||||
|
|
||||||
#endif // STYLED_EDIT_APP
|
#endif // STYLED_EDIT_APP
|
||||||
|
|
||||||
|
|||||||
@@ -12,18 +12,20 @@
|
|||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "StyledEditView.h"
|
#include "StyledEditView.h"
|
||||||
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Messenger.h>
|
|
||||||
#include <Rect.h>
|
|
||||||
#include <Region.h>
|
|
||||||
#include <TranslationUtils.h>
|
|
||||||
#include <Node.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <CharacterSet.h>
|
#include <CharacterSet.h>
|
||||||
#include <CharacterSetRoster.h>
|
#include <CharacterSetRoster.h>
|
||||||
|
#include <DataIO.h>
|
||||||
|
#include <File.h>
|
||||||
|
#include <Message.h>
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <Node.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <TranslationUtils.h>
|
||||||
#include <UTF8.h>
|
#include <UTF8.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
@@ -32,7 +34,6 @@ StyledEditView::StyledEditView(BRect viewFrame, BRect textBounds, BHandler *hand
|
|||||||
: BTextView(viewFrame, "textview", textBounds,
|
: BTextView(viewFrame, "textview", textBounds,
|
||||||
B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW)
|
B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW)
|
||||||
{
|
{
|
||||||
fHandler = handler;
|
|
||||||
fMessenger = new BMessenger(handler);
|
fMessenger = new BMessenger(handler);
|
||||||
fSuppressChanges = false;
|
fSuppressChanges = false;
|
||||||
}
|
}
|
||||||
@@ -45,35 +46,22 @@ StyledEditView::~StyledEditView()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StyledEditView::FrameResized(float width, float height)
|
StyledEditView::Select(int32 start, int32 finish)
|
||||||
{
|
{
|
||||||
BTextView::FrameResized(width, height);
|
fMessenger->SendMessage(start == finish ? DISABLE_ITEMS : ENABLE_ITEMS);
|
||||||
|
|
||||||
if (DoesWordWrap()) {
|
BTextView::Select(start, finish);
|
||||||
BRect textRect;
|
}
|
||||||
textRect = Bounds();
|
|
||||||
textRect.OffsetTo(B_ORIGIN);
|
|
||||||
textRect.InsetBy(TEXT_INSET, TEXT_INSET);
|
|
||||||
SetTextRect(textRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* // I tried to do some sort of intelligent resize thing but it just doesn't work
|
|
||||||
// so we revert to the R5 stylededit yucky practice of setting the text rect to
|
|
||||||
// some crazy large number when word wrap is turned off :-(
|
|
||||||
else if (textRect.Width() > TextRect().Width()) {
|
|
||||||
SetTextRect(textRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
BRegion region;
|
void
|
||||||
GetTextRegion(0,TextLength(),®ion);
|
StyledEditView::Reset()
|
||||||
float textWidth = region.Frame().Width();
|
{
|
||||||
if (textWidth < textRect.Width()) {
|
fSuppressChanges = true;
|
||||||
BRect textRect(B_ORIGIN,BPoint(textWidth+TEXT_INSET*2,Bounds().Height()));
|
SetText("");
|
||||||
textRect.InsetBy(TEXT_INSET,TEXT_INSET);
|
fEncoding = "";
|
||||||
SetTextRect(textRect);
|
fSuppressChanges = false;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
@@ -144,39 +132,18 @@ StyledEditView::WriteStyledEditFile(BFile* file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
StyledEditView::Reset()
|
|
||||||
{
|
|
||||||
fSuppressChanges = true;
|
|
||||||
SetText("");
|
|
||||||
fEncoding = "";
|
|
||||||
fSuppressChanges = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
StyledEditView::Select(int32 start, int32 finish)
|
|
||||||
{
|
|
||||||
fChangeMessage = new BMessage(start == finish ? DISABLE_ITEMS : ENABLE_ITEMS);
|
|
||||||
fMessenger->SendMessage(fChangeMessage);
|
|
||||||
|
|
||||||
BTextView::Select(start, finish);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StyledEditView::SetEncoding(uint32 encoding)
|
StyledEditView::SetEncoding(uint32 encoding)
|
||||||
{
|
{
|
||||||
if (encoding == 0) {
|
fEncoding = "";
|
||||||
fEncoding = "";
|
if (encoding == 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
const BCharacterSet* set = BCharacterSetRoster::GetCharacterSetByFontID(encoding);
|
const BCharacterSet* set
|
||||||
|
= BCharacterSetRoster::GetCharacterSetByFontID(encoding);
|
||||||
|
|
||||||
if (set != NULL)
|
if (set != NULL)
|
||||||
fEncoding = set->GetName();
|
fEncoding = set->GetName();
|
||||||
else
|
|
||||||
fEncoding = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -186,31 +153,47 @@ StyledEditView::GetEncoding() const
|
|||||||
if (fEncoding == "")
|
if (fEncoding == "")
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const BCharacterSet* set = BCharacterSetRoster::FindCharacterSetByName(fEncoding.String());
|
const BCharacterSet* set =
|
||||||
if (set != NULL)
|
BCharacterSetRoster::FindCharacterSetByName(fEncoding.String());
|
||||||
|
if(set != NULL)
|
||||||
return set->GetFontID();
|
return set->GetFontID();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
StyledEditView::DeleteText(int32 start, int32 finish)
|
||||||
|
{
|
||||||
|
if (!fSuppressChanges)
|
||||||
|
fMessenger-> SendMessage(TEXT_CHANGED);
|
||||||
|
|
||||||
|
BTextView::DeleteText(start, finish);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StyledEditView::InsertText(const char *text, int32 length, int32 offset,
|
StyledEditView::InsertText(const char *text, int32 length, int32 offset,
|
||||||
const text_run_array *runs)
|
const text_run_array *runs)
|
||||||
{
|
{
|
||||||
if (!fSuppressChanges)
|
if (!fSuppressChanges)
|
||||||
fMessenger->SendMessage(new BMessage(TEXT_CHANGED));
|
fMessenger->SendMessage(TEXT_CHANGED);
|
||||||
|
|
||||||
BTextView::InsertText(text, length, offset, runs);
|
BTextView::InsertText(text, length, offset, runs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
StyledEditView::DeleteText(int32 start, int32 finish)
|
StyledEditView::FrameResized(float width, float height)
|
||||||
{
|
{
|
||||||
if (!fSuppressChanges)
|
BTextView::FrameResized(width, height);
|
||||||
fMessenger-> SendMessage(new BMessage(TEXT_CHANGED));
|
|
||||||
|
|
||||||
BTextView::DeleteText(start, finish);
|
if (DoesWordWrap()) {
|
||||||
}
|
BRect textRect;
|
||||||
|
textRect = Bounds();
|
||||||
|
textRect.OffsetTo(B_ORIGIN);
|
||||||
|
textRect.InsetBy(TEXT_INSET, TEXT_INSET);
|
||||||
|
SetTextRect(textRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,37 +11,40 @@
|
|||||||
#define STYLED_EDIT_VIEW_H
|
#define STYLED_EDIT_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
#include <File.h>
|
|
||||||
#include <DataIO.h>
|
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BFile;
|
||||||
|
class BHandler;
|
||||||
|
class BMessanger;
|
||||||
|
|
||||||
|
|
||||||
class StyledEditView : public BTextView {
|
class StyledEditView : public BTextView {
|
||||||
public:
|
public:
|
||||||
StyledEditView(BRect viewframe, BRect textframe, BHandler *handler);
|
StyledEditView(BRect viewframe, BRect textframe,
|
||||||
virtual ~StyledEditView();
|
BHandler *handler);
|
||||||
|
~StyledEditView();
|
||||||
|
|
||||||
virtual void Select(int32 start, int32 finish);
|
void Select(int32 start, int32 finish);
|
||||||
virtual void FrameResized(float width, float height);
|
|
||||||
|
|
||||||
virtual void Reset();
|
void Reset();
|
||||||
virtual status_t GetStyledText(BPositionIO * stream);
|
status_t GetStyledText(BPositionIO * stream);
|
||||||
virtual status_t WriteStyledEditFile(BFile * file);
|
status_t WriteStyledEditFile(BFile * file);
|
||||||
|
|
||||||
virtual void SetEncoding(uint32 encoding);
|
void SetEncoding(uint32 encoding);
|
||||||
virtual uint32 GetEncoding() const;
|
uint32 GetEncoding() const;
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void InsertText(const char *text, int32 length, int32 offset, const text_run_array *runs = NULL);
|
|
||||||
virtual void DeleteText(int32 start, int32 finish);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BHandler *fHandler;
|
void DeleteText(int32 start, int32 finish);
|
||||||
BMessage *fChangeMessage;
|
void FrameResized(float width, float height);
|
||||||
|
void InsertText(const char *text, int32 length, int32 offset,
|
||||||
|
const text_run_array *runs = NULL);
|
||||||
|
|
||||||
BMessenger *fMessenger;
|
BMessenger *fMessenger;
|
||||||
bool fSuppressChanges;
|
bool fSuppressChanges;
|
||||||
BString fEncoding;
|
BString fEncoding;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STYLED_EDIT_VIEW_H
|
#endif // STYLED_EDIT_VIEW_H
|
||||||
|
|
||||||
|
|||||||
@@ -18,24 +18,26 @@
|
|||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <Debug.h>
|
|
||||||
#include <Clipboard.h>
|
|
||||||
#include <File.h>
|
|
||||||
#include <Menu.h>
|
|
||||||
#include <MenuItem.h>
|
|
||||||
#include <PrintJob.h>
|
|
||||||
#include <Roster.h>
|
|
||||||
#include <ScrollView.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <TextControl.h>
|
|
||||||
#include <TranslationUtils.h>
|
|
||||||
#include <Window.h>
|
|
||||||
|
|
||||||
#include <CharacterSet.h>
|
#include <CharacterSet.h>
|
||||||
#include <CharacterSetRoster.h>
|
#include <CharacterSetRoster.h>
|
||||||
|
#include <Clipboard.h>
|
||||||
|
#include <Debug.h>
|
||||||
|
#include <File.h>
|
||||||
|
#include <FilePanel.h>
|
||||||
|
#include <Menu.h>
|
||||||
|
#include <MenuBar.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
|
#include <PrintJob.h>
|
||||||
|
#include <Rect.h>
|
||||||
|
#include <ScrollView.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
#include <TranslationUtils.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
using namespace BPrivate;
|
using namespace BPrivate;
|
||||||
|
|
||||||
|
|
||||||
@@ -43,8 +45,7 @@ StyledEditWindow::StyledEditWindow(BRect frame, int32 id, uint32 encoding)
|
|||||||
: BWindow(frame, "untitled", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
: BWindow(frame, "untitled", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
||||||
{
|
{
|
||||||
InitWindow(encoding);
|
InitWindow(encoding);
|
||||||
BString unTitled;
|
BString unTitled("Untitled ");
|
||||||
unTitled.SetTo("Untitled ");
|
|
||||||
unTitled << id;
|
unTitled << id;
|
||||||
SetTitle(unTitled.String());
|
SetTitle(unTitled.String());
|
||||||
fSaveItem->SetEnabled(true);
|
fSaveItem->SetEnabled(true);
|
||||||
@@ -365,7 +366,7 @@ StyledEditWindow::MessageReceived(BMessage *message)
|
|||||||
{
|
{
|
||||||
BRect findWindowFrame(100, 100, 400, 235);
|
BRect findWindowFrame(100, 100, 400, 235);
|
||||||
BWindow* window = new FindWindow(findWindowFrame, this,
|
BWindow* window = new FindWindow(findWindowFrame, this,
|
||||||
&fStringToFind, &fCaseSens, &fWrapAround, &fBackSearch);
|
&fStringToFind, fCaseSens, fWrapAround, fBackSearch);
|
||||||
window->Show();
|
window->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -388,58 +389,45 @@ StyledEditWindow::MessageReceived(BMessage *message)
|
|||||||
{
|
{
|
||||||
BRect replaceWindowFrame(100, 100, 400, 284);
|
BRect replaceWindowFrame(100, 100, 400, 284);
|
||||||
BWindow* window = new ReplaceWindow(replaceWindowFrame, this,
|
BWindow* window = new ReplaceWindow(replaceWindowFrame, this,
|
||||||
&fStringToFind, &fReplaceString, &fCaseSens, &fWrapAround, &fBackSearch);
|
&fStringToFind, &fReplaceString, fCaseSens, fWrapAround, fBackSearch);
|
||||||
window->Show();
|
window->Show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_REPLACE:
|
case MSG_REPLACE:
|
||||||
{
|
{
|
||||||
BString findIt;
|
message->FindBool("casesens", &fCaseSens);
|
||||||
BString replaceWith;
|
message->FindBool("wrap", &fWrapAround);
|
||||||
bool caseSens, wrap, backSearch;
|
message->FindBool("backsearch", &fBackSearch);
|
||||||
|
|
||||||
message->FindBool("casesens", &caseSens);
|
message->FindString("FindText", &fStringToFind);
|
||||||
message->FindBool("wrap", &wrap);
|
message->FindString("ReplaceText", &fReplaceString);
|
||||||
message->FindBool("backsearch", &backSearch);
|
|
||||||
|
|
||||||
message->FindString("FindText", &findIt);
|
|
||||||
message->FindString("ReplaceText", &replaceWith);
|
|
||||||
fStringToFind = findIt;
|
|
||||||
fFindAgainItem->SetEnabled(true);
|
fFindAgainItem->SetEnabled(true);
|
||||||
fReplaceString = replaceWith;
|
|
||||||
fReplaceSameItem->SetEnabled(true);
|
fReplaceSameItem->SetEnabled(true);
|
||||||
fCaseSens = caseSens;
|
|
||||||
fWrapAround = wrap;
|
|
||||||
fBackSearch = backSearch;
|
|
||||||
|
|
||||||
Replace(findIt, replaceWith, caseSens, wrap, backSearch);
|
Replace(fStringToFind, fReplaceString, fCaseSens, fWrapAround, fBackSearch);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MENU_REPLACE_SAME:
|
case MENU_REPLACE_SAME:
|
||||||
Replace(fStringToFind,fReplaceString,fCaseSens,fWrapAround,fBackSearch);
|
Replace(fStringToFind, fReplaceString, fCaseSens, fWrapAround, fBackSearch);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSG_REPLACE_ALL:
|
case MSG_REPLACE_ALL:
|
||||||
{
|
{
|
||||||
BString findIt;
|
message->FindBool("casesens", &fCaseSens);
|
||||||
BString replaceWith;
|
message->FindString("FindText",&fStringToFind);
|
||||||
bool caseSens, allWindows;
|
message->FindString("ReplaceText",&fReplaceString);
|
||||||
|
|
||||||
message->FindBool("casesens", &caseSens);
|
bool allWindows;
|
||||||
message->FindString("FindText",&findIt);
|
|
||||||
message->FindString("ReplaceText",&replaceWith);
|
|
||||||
message->FindBool("allwindows", &allWindows);
|
message->FindBool("allwindows", &allWindows);
|
||||||
|
|
||||||
fStringToFind = findIt;
|
|
||||||
fFindAgainItem->SetEnabled(true);
|
fFindAgainItem->SetEnabled(true);
|
||||||
fReplaceString = replaceWith;
|
|
||||||
fReplaceSameItem->SetEnabled(true);
|
fReplaceSameItem->SetEnabled(true);
|
||||||
fCaseSens = caseSens;
|
|
||||||
|
|
||||||
if (allWindows)
|
if (allWindows)
|
||||||
SearchAllWindows(findIt, replaceWith, caseSens);
|
SearchAllWindows(fStringToFind, fReplaceString, fCaseSens);
|
||||||
else
|
else
|
||||||
ReplaceAll(findIt, replaceWith,caseSens);
|
ReplaceAll(fStringToFind, fReplaceString, fCaseSens);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,70 +496,35 @@ StyledEditWindow::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
case ALIGN_LEFT:
|
case ALIGN_LEFT:
|
||||||
fTextView->SetAlignment(B_ALIGN_LEFT);
|
fTextView->SetAlignment(B_ALIGN_LEFT);
|
||||||
fClean = false;
|
_UpdateCleanUndoRedoSaveRevert();
|
||||||
fUndoCleans = false;
|
|
||||||
fRedoCleans = false;
|
|
||||||
fRevertItem->SetEnabled(fSaveMessage != NULL);
|
|
||||||
fSaveItem->SetEnabled(true);
|
|
||||||
fUndoItem->SetLabel("Can't Undo");
|
|
||||||
fUndoItem->SetEnabled(false);
|
|
||||||
fCanUndo = false;
|
|
||||||
fCanRedo = false;
|
|
||||||
break;
|
break;
|
||||||
case ALIGN_CENTER:
|
case ALIGN_CENTER:
|
||||||
fTextView->SetAlignment(B_ALIGN_CENTER);
|
fTextView->SetAlignment(B_ALIGN_CENTER);
|
||||||
fClean = false;
|
_UpdateCleanUndoRedoSaveRevert();
|
||||||
fUndoCleans = false;
|
|
||||||
fRedoCleans = false;
|
|
||||||
fRevertItem->SetEnabled(fSaveMessage != NULL);
|
|
||||||
fSaveItem->SetEnabled(true);
|
|
||||||
fUndoItem->SetLabel("Can't Undo");
|
|
||||||
fUndoItem->SetEnabled(false);
|
|
||||||
fCanUndo = false;
|
|
||||||
fCanRedo = false;
|
|
||||||
break;
|
break;
|
||||||
case ALIGN_RIGHT:
|
case ALIGN_RIGHT:
|
||||||
fTextView->SetAlignment(B_ALIGN_RIGHT);
|
fTextView->SetAlignment(B_ALIGN_RIGHT);
|
||||||
fClean = false;
|
_UpdateCleanUndoRedoSaveRevert();
|
||||||
fUndoCleans = false;
|
|
||||||
fRedoCleans = false;
|
|
||||||
fRevertItem->SetEnabled(fSaveMessage != NULL);
|
|
||||||
fSaveItem->SetEnabled(true);
|
|
||||||
fUndoItem->SetLabel("Can't Undo");
|
|
||||||
fUndoItem->SetEnabled(false);
|
|
||||||
fCanUndo = false;
|
|
||||||
fCanRedo = false;
|
|
||||||
break;
|
break;
|
||||||
case WRAP_LINES:
|
case WRAP_LINES:
|
||||||
|
{
|
||||||
|
BRect textRect(fTextView->Bounds());
|
||||||
|
textRect.OffsetTo(B_ORIGIN);
|
||||||
|
textRect.InsetBy(TEXT_INSET,TEXT_INSET);
|
||||||
if (fTextView->DoesWordWrap()) {
|
if (fTextView->DoesWordWrap()) {
|
||||||
fTextView->SetWordWrap(false);
|
fTextView->SetWordWrap(false);
|
||||||
fWrapItem->SetMarked(false);
|
fWrapItem->SetMarked(false);
|
||||||
BRect textRect;
|
|
||||||
textRect = fTextView->Bounds();
|
|
||||||
textRect.OffsetTo(B_ORIGIN);
|
|
||||||
textRect.InsetBy(TEXT_INSET,TEXT_INSET);
|
|
||||||
// the width comes from stylededit R5. TODO: find a better way
|
// the width comes from stylededit R5. TODO: find a better way
|
||||||
textRect.SetRightBottom(BPoint(1500.0,textRect.RightBottom().y));
|
textRect.SetRightBottom(BPoint(1500.0, textRect.RightBottom().y));
|
||||||
fTextView->SetTextRect(textRect);
|
|
||||||
} else {
|
} else {
|
||||||
fTextView->SetWordWrap(true);
|
fTextView->SetWordWrap(true);
|
||||||
fWrapItem->SetMarked(true);
|
fWrapItem->SetMarked(true);
|
||||||
BRect textRect;
|
}
|
||||||
textRect = fTextView->Bounds();
|
fTextView->SetTextRect(textRect);
|
||||||
textRect.OffsetTo(B_ORIGIN);
|
|
||||||
textRect.InsetBy(TEXT_INSET,TEXT_INSET);
|
_UpdateCleanUndoRedoSaveRevert();
|
||||||
fTextView->SetTextRect(textRect);
|
|
||||||
}
|
|
||||||
fClean = false;
|
|
||||||
fUndoCleans = false;
|
|
||||||
fRedoCleans = false;
|
|
||||||
fRevertItem->SetEnabled(fSaveMessage != NULL);
|
|
||||||
fSaveItem->SetEnabled(true);
|
|
||||||
fUndoItem->SetLabel("Can't Undo");
|
|
||||||
fUndoItem->SetEnabled(false);
|
|
||||||
fCanUndo = false;
|
|
||||||
fCanRedo = false;
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case ENABLE_ITEMS:
|
case ENABLE_ITEMS:
|
||||||
fCutItem->SetEnabled(true);
|
fCutItem->SetEnabled(true);
|
||||||
fCopyItem->SetEnabled(true);
|
fCopyItem->SetEnabled(true);
|
||||||
@@ -1303,15 +1256,7 @@ StyledEditWindow::ReplaceAll(BString findIt, BString replaceWith, bool caseSensi
|
|||||||
fTextView->Select(textStart,textFinish);
|
fTextView->Select(textStart,textFinish);
|
||||||
fTextView->ScrollToSelection();
|
fTextView->ScrollToSelection();
|
||||||
|
|
||||||
fClean = false;
|
_UpdateCleanUndoRedoSaveRevert();
|
||||||
fUndoCleans = false;
|
|
||||||
fRedoCleans = false;
|
|
||||||
fRevertItem->SetEnabled(fSaveMessage != NULL);
|
|
||||||
fSaveItem->SetEnabled(true);
|
|
||||||
fUndoItem->SetLabel("Can't Undo");
|
|
||||||
fUndoItem->SetEnabled(false);
|
|
||||||
fCanUndo = false;
|
|
||||||
fCanRedo = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1348,15 +1293,8 @@ StyledEditWindow::SetFontSize(float fontSize)
|
|||||||
fTextView->GetFontAndColor(&font, &sameProperties);
|
fTextView->GetFontAndColor(&font, &sameProperties);
|
||||||
font.SetSize(fontSize);
|
font.SetSize(fontSize);
|
||||||
fTextView->SetFontAndColor(&font, B_FONT_SIZE);
|
fTextView->SetFontAndColor(&font, B_FONT_SIZE);
|
||||||
fClean = false;
|
|
||||||
fUndoCleans = false;
|
_UpdateCleanUndoRedoSaveRevert();
|
||||||
fRedoCleans = false;
|
|
||||||
fRevertItem->SetEnabled(fSaveMessage != NULL);
|
|
||||||
fSaveItem->SetEnabled(true);
|
|
||||||
fUndoItem->SetLabel("Can't Undo");
|
|
||||||
fUndoItem->SetEnabled(false);
|
|
||||||
fCanUndo = false;
|
|
||||||
fCanRedo = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1368,15 +1306,8 @@ StyledEditWindow::SetFontColor(const rgb_color *color)
|
|||||||
|
|
||||||
fTextView->GetFontAndColor(&font, &sameProperties, NULL, NULL);
|
fTextView->GetFontAndColor(&font, &sameProperties, NULL, NULL);
|
||||||
fTextView->SetFontAndColor(&font, 0, color);
|
fTextView->SetFontAndColor(&font, 0, color);
|
||||||
fClean = false;
|
|
||||||
fUndoCleans = false;
|
_UpdateCleanUndoRedoSaveRevert();
|
||||||
fRedoCleans = false;
|
|
||||||
fRevertItem->SetEnabled(fSaveMessage != NULL);
|
|
||||||
fSaveItem->SetEnabled(true);
|
|
||||||
fUndoItem->SetLabel("Can't Undo");
|
|
||||||
fUndoItem->SetEnabled(false);
|
|
||||||
fCanUndo = false;
|
|
||||||
fCanRedo = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1407,6 +1338,12 @@ StyledEditWindow::SetFontStyle(const char *fontFamily, const char *fontStyle)
|
|||||||
if (superItem != NULL)
|
if (superItem != NULL)
|
||||||
superItem->SetMarked(true);
|
superItem->SetMarked(true);
|
||||||
|
|
||||||
|
_UpdateCleanUndoRedoSaveRevert();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
StyledEditWindow::_UpdateCleanUndoRedoSaveRevert()
|
||||||
|
{
|
||||||
fClean = false;
|
fClean = false;
|
||||||
fUndoCleans = false;
|
fUndoCleans = false;
|
||||||
fRedoCleans = false;
|
fRedoCleans = false;
|
||||||
@@ -1417,3 +1354,4 @@ StyledEditWindow::SetFontStyle(const char *fontFamily, const char *fontStyle)
|
|||||||
fCanUndo = false;
|
fCanUndo = false;
|
||||||
fCanRedo = false;
|
fCanRedo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,29 +10,34 @@
|
|||||||
#define STYLED_EDIT_WINDOW_H
|
#define STYLED_EDIT_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
#include <FilePanel.h>
|
|
||||||
#include <MenuBar.h>
|
|
||||||
#include <Message.h>
|
|
||||||
#include <Rect.h>
|
|
||||||
#include <String.h>
|
|
||||||
#include <TextView.h>
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct entry_ref;
|
||||||
|
|
||||||
|
class BMenu;
|
||||||
|
class BMessage;
|
||||||
|
class BMenuBar;
|
||||||
|
class BMenuItem;
|
||||||
|
class BFilePanel;
|
||||||
|
class BScrollView;
|
||||||
class StyledEditView;
|
class StyledEditView;
|
||||||
|
|
||||||
|
|
||||||
class StyledEditWindow : public BWindow {
|
class StyledEditWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
StyledEditWindow(BRect frame, int32 id, uint32 encoding = 0);
|
StyledEditWindow(BRect frame, int32 id, uint32 encoding = 0);
|
||||||
StyledEditWindow(BRect frame, entry_ref *ref, uint32 encoding = 0);
|
StyledEditWindow(BRect frame, entry_ref *ref, uint32 encoding = 0);
|
||||||
virtual ~StyledEditWindow();
|
~StyledEditWindow();
|
||||||
|
|
||||||
virtual void Quit();
|
void Quit();
|
||||||
virtual bool QuitRequested();
|
bool QuitRequested();
|
||||||
virtual void MessageReceived(BMessage *message);
|
void MessageReceived(BMessage *message);
|
||||||
virtual void MenusBeginning();
|
void MenusBeginning();
|
||||||
|
|
||||||
status_t Save(BMessage *message = 0);
|
status_t Save(BMessage *message = 0);
|
||||||
status_t SaveAs(BMessage *message = 0);
|
status_t SaveAs(BMessage *message = 0);
|
||||||
void OpenFile(entry_ref *ref);
|
void OpenFile(entry_ref *ref);
|
||||||
status_t PageSetup(const char *documentname);
|
status_t PageSetup(const char *documentname);
|
||||||
@@ -43,13 +48,15 @@ class StyledEditWindow : public BWindow {
|
|||||||
void InitWindow(uint32 encoding = 0);
|
void InitWindow(uint32 encoding = 0);
|
||||||
bool Search(BString searchfor, bool casesens, bool wrap, bool backsearch);
|
bool Search(BString searchfor, bool casesens, bool wrap, bool backsearch);
|
||||||
void FindSelection();
|
void FindSelection();
|
||||||
bool Replace(BString findthis, BString replacewith, bool casesens, bool wrap, bool backsearch);
|
bool Replace(BString findthis, BString replacewith, bool casesens,
|
||||||
|
bool wrap, bool backsearch);
|
||||||
void ReplaceAll(BString find, BString replace, bool casesens);
|
void ReplaceAll(BString find, BString replace, bool casesens);
|
||||||
void SetFontSize(float fontSize);
|
void SetFontSize(float fontSize);
|
||||||
void SetFontColor(const rgb_color *color);
|
void SetFontColor(const rgb_color *color);
|
||||||
void SetFontStyle(const char *fontFamily, const char *fontStyle);
|
void SetFontStyle(const char *fontFamily, const char *fontStyle);
|
||||||
status_t _LoadFile(entry_ref* ref);
|
status_t _LoadFile(entry_ref* ref);
|
||||||
void RevertToSaved();
|
void RevertToSaved();
|
||||||
|
void _UpdateCleanUndoRedoSaveRevert();
|
||||||
|
|
||||||
BMenuBar *fMenuBar;
|
BMenuBar *fMenuBar;
|
||||||
BMessage *fPrintSettings;
|
BMessage *fPrintSettings;
|
||||||
@@ -85,7 +92,7 @@ class StyledEditWindow : public BWindow {
|
|||||||
BMenuItem *fAlignCenter;
|
BMenuItem *fAlignCenter;
|
||||||
BMenuItem *fAlignRight;
|
BMenuItem *fAlignRight;
|
||||||
|
|
||||||
BString fStringToFind;
|
BString fStringToFind;
|
||||||
BString fReplaceString;
|
BString fReplaceString;
|
||||||
|
|
||||||
// undo modes
|
// undo modes
|
||||||
@@ -103,7 +110,7 @@ class StyledEditWindow : public BWindow {
|
|||||||
bool fWrapAround;
|
bool fWrapAround;
|
||||||
bool fBackSearch;
|
bool fBackSearch;
|
||||||
|
|
||||||
StyledEditView *fTextView;
|
StyledEditView *fTextView;
|
||||||
BScrollView *fScrollView;
|
BScrollView *fScrollView;
|
||||||
|
|
||||||
BFilePanel *fSavePanel;
|
BFilePanel *fSavePanel;
|
||||||
@@ -111,3 +118,4 @@ class StyledEditWindow : public BWindow {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // STYLED_EDIT_WINDOW_H
|
#endif // STYLED_EDIT_WINDOW_H
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user