2 * Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
10 #ifndef STYLED_EDIT_WINDOW_H
11 #define STYLED_EDIT_WINDOW_H
31 class StyledEditWindow
: public BWindow
{
33 StyledEditWindow(BRect frame
, int32 id
,
35 StyledEditWindow(BRect frame
, entry_ref
* ref
,
37 virtual ~StyledEditWindow();
40 virtual bool QuitRequested();
41 virtual void MessageReceived(BMessage
* message
);
42 virtual void MenusBeginning();
44 status_t
Save(BMessage
* message
= NULL
);
45 status_t
SaveAs(BMessage
* message
= NULL
);
46 void OpenFile(entry_ref
* ref
);
47 status_t
PageSetup(const char* documentName
);
48 void Print(const char* documentName
);
49 void SearchAllWindows(BString find
, BString replace
,
51 bool IsDocumentEntryRef(const entry_ref
* ref
);
54 void _InitWindow(uint32 encoding
= 0);
55 void _BuildFontColorMenu(BMenu
* menu
);
58 status_t
_LoadFile(entry_ref
* ref
,
59 const char* forceEncoding
= NULL
);
60 void _ReloadDocument(BMessage
*message
);
61 status_t
_UnlockFile();
62 bool _Search(BString searchFor
, bool caseSensitive
,
63 bool wrap
, bool backSearch
,
64 bool scrollToOccurence
= true);
65 void _FindSelection();
66 bool _Replace(BString findThis
, BString replaceWith
,
67 bool caseSensitive
, bool wrap
,
69 void _ReplaceAll(BString find
, BString replace
,
71 void _SetFontSize(float fontSize
);
72 void _SetFontColor(const rgb_color
* color
);
73 void _SetFontStyle(const char* fontFamily
,
74 const char* fontStyle
);
75 int32
_ShowStatistics();
76 void _SetReadOnly(bool editable
);
77 void _UpdateCleanUndoRedoSaveRevert();
78 int32
_ShowAlert(const BString
& text
,
79 const BString
& label
, const BString
& label2
,
80 const BString
& label3
,
81 alert_type type
) const;
82 BMenu
* _PopulateEncodingMenu(BMenu
* menu
,
83 const char* encoding
);
85 // node monitoring helper
86 class _NodeMonitorSuspender
{
87 StyledEditWindow
*fWindow
;
89 _NodeMonitorSuspender(StyledEditWindow
*w
) : fWindow(w
) {
90 fWindow
->_SwitchNodeMonitor(false);
93 ~_NodeMonitorSuspender() {
94 fWindow
->_SwitchNodeMonitor(true);
98 friend class _NodeMonitorSuspender
;
100 void _HandleNodeMonitorEvent(BMessage
*message
);
101 void _ShowNodeChangeAlert(const char* name
,
103 void _SwitchNodeMonitor(bool on
,
104 entry_ref
* ref
= NULL
);
108 BMessage
* fPrintSettings
;
109 BMessage
* fSaveMessage
;
112 BMenu
* fFontSizeMenu
;
113 BMenu
* fFontColorMenu
;
114 BMenuItem
* fCurrentFontItem
;
115 BMenuItem
* fCurrentStyleItem
;
117 BMenuItem
* fSaveItem
;
118 BMenuItem
* fReloadItem
;
120 BMenuItem
* fUndoItem
;
122 BMenuItem
* fCopyItem
;
124 BMenuItem
* fFindAgainItem
;
125 BMenuItem
* fReplaceItem
;
126 BMenuItem
* fReplaceSameItem
;
128 BMenuItem
* fBoldItem
;
129 BMenuItem
* fItalicItem
;
131 BMenuItem
* fWrapItem
;
132 BMenuItem
* fAlignLeft
;
133 BMenuItem
* fAlignCenter
;
134 BMenuItem
* fAlignRight
;
135 BMenuItem
* fEncodingItem
;
136 BMenuItem
* fRecentMenuItem
;
138 BString fStringToFind
;
139 BString fReplaceString
;
141 ColorMenuItem
* fDefaultFontColorItem
;
144 bool fUndoFlag
; // we just did an undo action
145 bool fCanUndo
; // we can do an undo action next
146 bool fRedoFlag
; // we just did a redo action
147 bool fCanRedo
; // we can do a redo action next
151 // an undo action will put us in a clean state
153 // a redo action will put us in a clean state
154 bool fClean
; // we are in a clean state
160 StyledEditView
* fTextView
;
161 BScrollView
* fScrollView
;
162 StatusView
* fStatusView
;
164 BFilePanel
* fSavePanel
;
165 BMenu
* fSavePanelEncodingMenu
;
168 node_ref fFolderNodeRef
;
169 bool fNagOnNodeChange
;
171 BWindow
* fFindWindow
;
172 BWindow
* fReplaceWindow
;
176 #endif // STYLED_EDIT_WINDOW_H