libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / apps / stylededit / StyledEditWindow.h
bloba5547e6f9d59a82a0fae6d1003b94e7049249778
1 /*
2 * Copyright 2002-2012, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Mattias Sundblad
7 * Andrew Bachmann
8 * Jonas Sundström
9 */
10 #ifndef STYLED_EDIT_WINDOW_H
11 #define STYLED_EDIT_WINDOW_H
14 #include <Alert.h>
15 #include <Node.h>
16 #include <Window.h>
18 struct entry_ref;
20 class BFilePanel;
21 class BMenu;
22 class BMenuBar;
23 class BMenuItem;
24 class BMessage;
25 class BScrollView;
26 class StatusView;
27 class StyledEditView;
28 class ColorMenuItem;
31 class StyledEditWindow : public BWindow {
32 public:
33 StyledEditWindow(BRect frame, int32 id,
34 uint32 encoding = 0);
35 StyledEditWindow(BRect frame, entry_ref* ref,
36 uint32 encoding = 0);
37 virtual ~StyledEditWindow();
39 virtual void Quit();
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,
50 bool caseSensitive);
51 bool IsDocumentEntryRef(const entry_ref* ref);
53 private:
54 void _InitWindow(uint32 encoding = 0);
55 void _BuildFontColorMenu(BMenu* menu);
56 void _LoadAttrs();
57 void _SaveAttrs();
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,
68 bool backSearch);
69 void _ReplaceAll(BString find, BString replace,
70 bool caseSensitive);
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;
88 public:
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,
102 bool removed);
103 void _SwitchNodeMonitor(bool on,
104 entry_ref* ref = NULL);
106 private:
107 BMenuBar* fMenuBar;
108 BMessage* fPrintSettings;
109 BMessage* fSaveMessage;
111 BMenu* fFontMenu;
112 BMenu* fFontSizeMenu;
113 BMenu* fFontColorMenu;
114 BMenuItem* fCurrentFontItem;
115 BMenuItem* fCurrentStyleItem;
117 BMenuItem* fSaveItem;
118 BMenuItem* fReloadItem;
120 BMenuItem* fUndoItem;
121 BMenuItem* fCutItem;
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;
143 // undo modes
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
149 // clean modes
150 bool fUndoCleans;
151 // an undo action will put us in a clean state
152 bool fRedoCleans;
153 // a redo action will put us in a clean state
154 bool fClean; // we are in a clean state
156 bool fCaseSensitive;
157 bool fWrapAround;
158 bool fBackSearch;
160 StyledEditView* fTextView;
161 BScrollView* fScrollView;
162 StatusView* fStatusView;
164 BFilePanel* fSavePanel;
165 BMenu* fSavePanelEncodingMenu;
166 // node monitoring
167 node_ref fNodeRef;
168 node_ref fFolderNodeRef;
169 bool fNagOnNodeChange;
171 BWindow* fFindWindow;
172 BWindow* fReplaceWindow;
176 #endif // STYLED_EDIT_WINDOW_H