xref: /haiku/src/apps/stylededit/StyledEditWindow.h (revision 079c69cbfd7cd3c97baae91332251c8388a8bb02)
1 /*
2  * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Mattias Sundblad
7  *		Andrew Bachmann
8  */
9 #ifndef STYLED_EDIT_WINDOW_H
10 #define STYLED_EDIT_WINDOW_H
11 
12 
13 #include <Window.h>
14 #include <String.h>
15 #include <Message.h>
16 
17 
18 struct entry_ref;
19 
20 class BMenu;
21 class BMessage;
22 class BMenuBar;
23 class BMenuItem;
24 class BFilePanel;
25 class BScrollView;
26 class StyledEditView;
27 
28 
29 class StyledEditWindow : public BWindow {
30 	public:
31 						StyledEditWindow(BRect frame, int32 id, uint32 encoding = 0);
32 						StyledEditWindow(BRect frame, entry_ref *ref, uint32 encoding = 0);
33 						~StyledEditWindow();
34 
35 		void			Quit();
36 		bool			QuitRequested();
37 		void			MessageReceived(BMessage *message);
38 		void			MenusBeginning();
39 
40 		status_t		Save(BMessage *message = 0);
41 		status_t		SaveAs(BMessage *message = 0);
42 		void			OpenFile(entry_ref *ref);
43 		status_t		PageSetup(const char *documentname);
44 		void			Print(const char *documentname);
45 		void			SearchAllWindows(BString find, BString replace, bool casesens);
46 
47 	private:
48 		void			InitWindow(uint32 encoding = 0);
49 		bool			Search(BString searchfor, bool casesens, bool wrap, bool backsearch);
50 		void			FindSelection();
51 		bool			Replace(BString findthis, BString replacewith, bool casesens,
52 							bool wrap, bool backsearch);
53 		void			ReplaceAll(BString find, BString replace, bool casesens);
54 		void			SetFontSize(float fontSize);
55 		void			SetFontColor(const rgb_color *color);
56 		void			SetFontStyle(const char *fontFamily, const char *fontStyle);
57 		status_t		_LoadFile(entry_ref* ref);
58 		void			RevertToSaved();
59 		void			_UpdateCleanUndoRedoSaveRevert();
60 
61 		BMenuBar		*fMenuBar;
62 		BMessage		*fPrintSettings;
63 		BMessage		*fSaveMessage;
64 		BMenu			*fRecentMenu;
65 
66 		BMenu			*fFontMenu;
67 		BMenu			*fFontSizeMenu;
68 		BMenu			*fFontColorMenu;
69 		BMenuItem		*fCurrentFontItem;
70 
71 		BMenuItem		*fSaveItem;
72 		BMenuItem		*fRevertItem;
73 
74 		BMenuItem		*fUndoItem;
75 		BMenuItem		*fCutItem;
76 		BMenuItem		*fCopyItem;
77 		BMenuItem		*fClearItem;
78 
79 		BMenuItem		*fFindAgainItem;
80 		BMenuItem		*fReplaceSameItem;
81 
82 		BMenuItem		*fBlackItem;
83 		BMenuItem		*fRedItem;
84 		BMenuItem		*fGreenItem;
85 		BMenuItem		*fBlueItem;
86 		BMenuItem		*fCyanItem;
87 		BMenuItem		*fMagentaItem;
88 		BMenuItem		*fYellowItem;
89 
90 		BMenuItem		*fWrapItem;
91 		BMenuItem		*fAlignLeft;
92 		BMenuItem		*fAlignCenter;
93 		BMenuItem		*fAlignRight;
94 
95 		BString			fStringToFind;
96 		BString			fReplaceString;
97 
98 		// undo modes
99 		bool 			fUndoFlag;   // we just did an undo action
100 		bool			fCanUndo;    // we can do an undo action next
101 		bool 			fRedoFlag;   // we just did a redo action
102 		bool			fCanRedo;    // we can do a redo action next
103 
104 		// clean modes
105 		bool			fUndoCleans; // an undo action will put us in a clean state
106 		bool			fRedoCleans; // a redo action will put us in a clean state
107 		bool			fClean;      // we are in a clean state
108 
109 		bool			fCaseSens;
110 		bool			fWrapAround;
111 		bool			fBackSearch;
112 
113 		StyledEditView	*fTextView;
114 		BScrollView		*fScrollView;
115 
116 		BFilePanel		*fSavePanel;
117 		BMenu			*fSavePanelEncodingMenu;
118 };
119 
120 #endif	// STYLED_EDIT_WINDOW_H
121 
122