xref: /haiku/src/apps/stylededit/StyledEditWindow.h (revision adb0d19d561947362090081e81d90dde59142026)
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 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 		virtual			~StyledEditWindow();
34 
35 		virtual void	Quit();
36 		virtual bool	QuitRequested();
37 		virtual void	MessageReceived(BMessage *message);
38 		virtual 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 		int32			_ShowAlert(const BString& text, const BString& label,
61 							const BString& label2, const BString& label3,
62 							alert_type type) const;
63 
64 		BMenuBar		*fMenuBar;
65 		BMessage		*fPrintSettings;
66 		BMessage		*fSaveMessage;
67 		BMenu			*fRecentMenu;
68 
69 		BMenu			*fFontMenu;
70 		BMenu			*fFontSizeMenu;
71 		BMenu			*fFontColorMenu;
72 		BMenuItem		*fCurrentFontItem;
73 
74 		BMenuItem		*fSaveItem;
75 		BMenuItem		*fRevertItem;
76 
77 		BMenuItem		*fUndoItem;
78 		BMenuItem		*fCutItem;
79 		BMenuItem		*fCopyItem;
80 		BMenuItem		*fClearItem;
81 
82 		BMenuItem		*fFindAgainItem;
83 		BMenuItem		*fReplaceSameItem;
84 
85 		BMenuItem		*fBlackItem;
86 		BMenuItem		*fRedItem;
87 		BMenuItem		*fGreenItem;
88 		BMenuItem		*fBlueItem;
89 		BMenuItem		*fCyanItem;
90 		BMenuItem		*fMagentaItem;
91 		BMenuItem		*fYellowItem;
92 
93 		BMenuItem		*fWrapItem;
94 		BMenuItem		*fAlignLeft;
95 		BMenuItem		*fAlignCenter;
96 		BMenuItem		*fAlignRight;
97 
98 		BString			fStringToFind;
99 		BString			fReplaceString;
100 
101 		// undo modes
102 		bool 			fUndoFlag;   // we just did an undo action
103 		bool			fCanUndo;    // we can do an undo action next
104 		bool 			fRedoFlag;   // we just did a redo action
105 		bool			fCanRedo;    // we can do a redo action next
106 
107 		// clean modes
108 		bool			fUndoCleans; // an undo action will put us in a clean state
109 		bool			fRedoCleans; // a redo action will put us in a clean state
110 		bool			fClean;      // we are in a clean state
111 
112 		bool			fCaseSens;
113 		bool			fWrapAround;
114 		bool			fBackSearch;
115 
116 		StyledEditView	*fTextView;
117 		BScrollView		*fScrollView;
118 
119 		BFilePanel		*fSavePanel;
120 		BMenu			*fSavePanelEncodingMenu;
121 };
122 
123 #endif	// STYLED_EDIT_WINDOW_H
124 
125