1 /* 2 * Copyright 2002-2010, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 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 12 13 14 #include <Alert.h> 15 #include <Window.h> 16 #include <String.h> 17 #include <Message.h> 18 19 20 struct entry_ref; 21 22 class BMenu; 23 class BMessage; 24 class BMenuBar; 25 class BMenuItem; 26 class BFilePanel; 27 class BScrollView; 28 class StyledEditView; 29 30 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(); 38 39 virtual void Quit(); 40 virtual bool QuitRequested(); 41 virtual void MessageReceived(BMessage* message); 42 virtual void MenusBeginning(); 43 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); 52 53 private: 54 void _InitWindow(uint32 encoding = 0); 55 void _LoadAttrs(); 56 void _SaveAttrs(); 57 status_t _LoadFile(entry_ref* ref); 58 void _RevertToSaved(); 59 bool _Search(BString searchFor, bool caseSensitive, 60 bool wrap, bool backSearch); 61 void _FindSelection(); 62 bool _Replace(BString findThis, BString replaceWith, 63 bool caseSensitive, bool wrap, 64 bool backSearch); 65 void _ReplaceAll(BString find, BString replace, 66 bool caseSensitive); 67 void _SetFontSize(float fontSize); 68 void _SetFontColor(const rgb_color* color); 69 void _SetFontStyle(const char* fontFamily, 70 const char* fontStyle); 71 int32 _ShowStatistics(); 72 void _UpdateCleanUndoRedoSaveRevert(); 73 int32 _ShowAlert(const BString& text, 74 const BString& label, const BString& label2, 75 const BString& label3, 76 alert_type type) const; 77 78 private: 79 BMenuBar* fMenuBar; 80 BMessage* fPrintSettings; 81 BMessage* fSaveMessage; 82 BMenu* fRecentMenu; 83 84 BMenu* fFontMenu; 85 BMenu* fFontSizeMenu; 86 BMenu* fFontColorMenu; 87 BMenuItem* fCurrentFontItem; 88 BMenuItem* fCurrentStyleItem; 89 90 BMenuItem* fSaveItem; 91 BMenuItem* fRevertItem; 92 93 BMenuItem* fUndoItem; 94 BMenuItem* fCutItem; 95 BMenuItem* fCopyItem; 96 97 BMenuItem* fFindAgainItem; 98 BMenuItem* fReplaceSameItem; 99 100 BMenuItem* fBlackItem; 101 BMenuItem* fRedItem; 102 BMenuItem* fGreenItem; 103 BMenuItem* fBlueItem; 104 BMenuItem* fCyanItem; 105 BMenuItem* fMagentaItem; 106 BMenuItem* fYellowItem; 107 108 BMenuItem* fBoldItem; 109 BMenuItem* fItalicItem; 110 111 BMenuItem* fWrapItem; 112 BMenuItem* fAlignLeft; 113 BMenuItem* fAlignCenter; 114 BMenuItem* fAlignRight; 115 116 BString fStringToFind; 117 BString fReplaceString; 118 119 // undo modes 120 bool fUndoFlag; // we just did an undo action 121 bool fCanUndo; // we can do an undo action next 122 bool fRedoFlag; // we just did a redo action 123 bool fCanRedo; // we can do a redo action next 124 125 // clean modes 126 bool fUndoCleans; 127 // an undo action will put us in a clean state 128 bool fRedoCleans; 129 // a redo action will put us in a clean state 130 bool fClean; // we are in a clean state 131 132 bool fCaseSensitive; 133 bool fWrapAround; 134 bool fBackSearch; 135 136 StyledEditView* fTextView; 137 BScrollView* fScrollView; 138 139 BFilePanel* fSavePanel; 140 BMenu* fSavePanelEncodingMenu; 141 }; 142 143 144 #endif // STYLED_EDIT_WINDOW_H 145