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 * 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 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 bool IsDocumentEntryRef(const entry_ref *ref); 48 49 private: 50 void InitWindow(uint32 encoding = 0); 51 bool Search(BString searchfor, bool casesens, bool wrap, bool backsearch); 52 void FindSelection(); 53 bool Replace(BString findthis, BString replacewith, bool casesens, 54 bool wrap, bool backsearch); 55 void ReplaceAll(BString find, BString replace, bool casesens); 56 void SetFontSize(float fontSize); 57 void SetFontColor(const rgb_color *color); 58 void SetFontStyle(const char *fontFamily, const char *fontStyle); 59 status_t _LoadFile(entry_ref* ref); 60 void RevertToSaved(); 61 void _UpdateCleanUndoRedoSaveRevert(); 62 int32 _ShowAlert(const BString& text, const BString& label, 63 const BString& label2, const BString& label3, 64 alert_type type) const; 65 66 BMenuBar *fMenuBar; 67 BMessage *fPrintSettings; 68 BMessage *fSaveMessage; 69 BMenu *fRecentMenu; 70 71 BMenu *fFontMenu; 72 BMenu *fFontSizeMenu; 73 BMenu *fFontColorMenu; 74 BMenuItem *fCurrentFontItem; 75 BMenuItem *fCurrentStyleItem; 76 77 BMenuItem *fSaveItem; 78 BMenuItem *fRevertItem; 79 80 BMenuItem *fUndoItem; 81 BMenuItem *fCutItem; 82 BMenuItem *fCopyItem; 83 BMenuItem *fClearItem; 84 85 BMenuItem *fFindAgainItem; 86 BMenuItem *fReplaceSameItem; 87 88 BMenuItem *fBlackItem; 89 BMenuItem *fRedItem; 90 BMenuItem *fGreenItem; 91 BMenuItem *fBlueItem; 92 BMenuItem *fCyanItem; 93 BMenuItem *fMagentaItem; 94 BMenuItem *fYellowItem; 95 96 BMenuItem *fWrapItem; 97 BMenuItem *fAlignLeft; 98 BMenuItem *fAlignCenter; 99 BMenuItem *fAlignRight; 100 101 BString fStringToFind; 102 BString fReplaceString; 103 104 // undo modes 105 bool fUndoFlag; // we just did an undo action 106 bool fCanUndo; // we can do an undo action next 107 bool fRedoFlag; // we just did a redo action 108 bool fCanRedo; // we can do a redo action next 109 110 // clean modes 111 bool fUndoCleans; // an undo action will put us in a clean state 112 bool fRedoCleans; // a redo action will put us in a clean state 113 bool fClean; // we are in a clean state 114 115 bool fCaseSens; 116 bool fWrapAround; 117 bool fBackSearch; 118 119 StyledEditView *fTextView; 120 BScrollView *fScrollView; 121 122 BFilePanel *fSavePanel; 123 BMenu *fSavePanelEncodingMenu; 124 }; 125 126 #endif // STYLED_EDIT_WINDOW_H 127 128