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