├── .gitignore ├── README.md └── Source ├── BinaryData ├── SiteData.zip ├── close.png ├── cut.png ├── icon.jpg ├── logo.png ├── mic.png ├── next.png ├── ok.png ├── play.png ├── prev.png ├── stop.png ├── system-r.png ├── system.png ├── trans-cn.h ├── view.png └── width.png ├── DocTreeViewItem.cpp ├── DocTreeViewItem.h ├── EditAndPreview.cpp ├── EditAndPreview.h ├── FileTreeContainer.cpp ├── FileTreeContainer.h ├── HtmlProcessor.cpp ├── HtmlProcessor.h ├── KeywordsComp.cpp ├── KeywordsComp.h ├── Main.cpp ├── MainComponent.cpp ├── MainComponent.h ├── MarkdownEditor.cpp ├── MarkdownEditor.h ├── README.md ├── RecordComp.cpp ├── RecordComp.h ├── ReplaceComponent.cpp ├── ReplaceComponent.h ├── SetupPanel.cpp ├── SetupPanel.h ├── StatisComp.cpp ├── StatisComp.h ├── SwingLibrary ├── AudioDataPlayer.cpp ├── AudioDataPlayer.h ├── AudioRecorder.cpp ├── AudioRecorder.h ├── MD2Html.cpp ├── MD2Html.h ├── PasswordPropertyComponent.cpp ├── PasswordPropertyComponent.h ├── SwingEditor.cpp ├── SwingEditor.h ├── SwingLookAndFeel.cpp ├── SwingLookAndFeel.h ├── SwingRegex.h ├── SwingUtilities.cpp └── SwingUtilities.h ├── ThemeEditor.cpp ├── ThemeEditor.h ├── TipsBank.cpp ├── TipsBank.h ├── TopToolBar.cpp ├── TopToolBar.h ├── WdtpHeader.h ├── libHackBackup ├── juce_TextEditor.cpp └── juce_TextEditor.h └── version /.gitignore: -------------------------------------------------------------------------------- 1 | # ========================= 2 | # Common dirs 3 | # ========================= 4 | 5 | Application/Debug 6 | Application/Release 7 | Builds/ 8 | JuceLibraryCode/ 9 | 10 | # ========================= 11 | # Operating System Files 12 | # ========================= 13 | 14 | .DS_Store 15 | .AppleDouble 16 | .LSOverride 17 | Desktop.ini 18 | $RECYCLE.BIN/ 19 | *.lnk 20 | *.supported 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Walden Trip (山·湖·路) 2 | 3 | ![WDTP](http://underwaysoft.com/works/wdtp/media/wdtp-main.jpg) 4 | 5 | WDTP is GPL (v2) licensed. 6 | 7 | See: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 8 | 9 | WDTP uses JUCE Library, Steinberg ASIO and Highlight.js, which are licensed separately. 10 | 11 | See: https://juce.com https://steinberg.net https://highlightjs.org 12 | 13 | Document: https://github.com/LegendRhine/WDTP/blob/master/Source/README.md 14 | 15 | Contact me: underwaySoft@gmail.com 16 | 17 | For more information, please visit the website: http://underwaysoft.com/works/wdtp/ 18 | -------------------------------------------------------------------------------- /Source/BinaryData/SiteData.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/SiteData.zip -------------------------------------------------------------------------------- /Source/BinaryData/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/close.png -------------------------------------------------------------------------------- /Source/BinaryData/cut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/cut.png -------------------------------------------------------------------------------- /Source/BinaryData/icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/icon.jpg -------------------------------------------------------------------------------- /Source/BinaryData/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/logo.png -------------------------------------------------------------------------------- /Source/BinaryData/mic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/mic.png -------------------------------------------------------------------------------- /Source/BinaryData/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/next.png -------------------------------------------------------------------------------- /Source/BinaryData/ok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/ok.png -------------------------------------------------------------------------------- /Source/BinaryData/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/play.png -------------------------------------------------------------------------------- /Source/BinaryData/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/prev.png -------------------------------------------------------------------------------- /Source/BinaryData/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/stop.png -------------------------------------------------------------------------------- /Source/BinaryData/system-r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/system-r.png -------------------------------------------------------------------------------- /Source/BinaryData/system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/system.png -------------------------------------------------------------------------------- /Source/BinaryData/view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/view.png -------------------------------------------------------------------------------- /Source/BinaryData/width.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LegendRhine/WDTP/46524ccb13f3513fada0d0a99fd14a535d901cb0/Source/BinaryData/width.png -------------------------------------------------------------------------------- /Source/DocTreeViewItem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | DocTreeViewItem.h 5 | Created: 16 Sep 2016 5:20:49am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef DOCTREEVIEWITEM_H_INCLUDED 12 | #define DOCTREEVIEWITEM_H_INCLUDED 13 | 14 | /** Repsent a doc, a dir or the project-root which showed in treeView. */ 15 | class DocTreeViewItem : public TreeViewItem, 16 | private ValueTree::Listener, 17 | private ActionListener 18 | { 19 | public: 20 | DocTreeViewItem (const ValueTree& tree, 21 | FileTreeContainer* container, 22 | ItemSorter* itemSorter); 23 | ~DocTreeViewItem(); 24 | 25 | /** Note 1: when this item is the root (project item of the top), 26 | this method will return this project's 'docs' dir instead of the project file! 27 | 28 | Note 2: this method will return a nonexists file when the arg is invalid. */ 29 | static const File getMdFileOrDir (const ValueTree& tree); 30 | 31 | /** these two methods will return index.html when it's a dir. */ 32 | static const File getHtmlFile (const File& mdFileOrDir); 33 | static const File getHtmlFile (const ValueTree& tree); 34 | 35 | /** get a html-file's all local media files. the result would be stored in arg-2. 36 | return: media-files' number of this html-file included. */ 37 | static const int getHtmlMediaFiles (const File& htmlFile, Array& files); 38 | 39 | /** get a doc-file's all local media files. the result would be stored in arg-2. 40 | return: media-files' number of this doc-file included. */ 41 | static const int getMdMediaFiles (const File& doc, Array& files); 42 | 43 | /** let the arg tree and all its parents set to needCreateHtml. */ 44 | static void needCreate (ValueTree tree); 45 | static void allChildrenNeedCreate (ValueTree tree); 46 | 47 | /** for drag-drop/moving items */ 48 | static void moveItems (const OwnedArray& items, 49 | ValueTree newParent); 50 | 51 | /** callback method whnever the project-tree has some changed */ 52 | void refreshDisplay(); 53 | const ValueTree& getTree() const { return tree; } 54 | 55 | /** override the parent class... */ 56 | virtual bool mightContainSubItems() override; 57 | virtual String getUniqueName() const override; 58 | virtual void itemOpennessChanged (bool isNowOpen) override; 59 | 60 | virtual String getTooltip() override; 61 | virtual void paintItem (Graphics& g, int width, int height) override; 62 | 63 | /** core method, it'll call the edit/preview area's startWork()*/ 64 | virtual void itemSelectionChanged (bool isNowSelected) override; 65 | 66 | /** popup-menu is here */ 67 | virtual void itemClicked (const MouseEvent& e) override; 68 | 69 | /** double click for rename it */ 70 | virtual void itemDoubleClicked (const MouseEvent& e) override; 71 | 72 | /** for move items.. */ 73 | virtual var getDragSourceDescription() override; 74 | virtual bool isInterestedInDragSource (const DragAndDropTarget::SourceDetails& details) override; 75 | virtual void itemDropped (const DragAndDropTarget::SourceDetails& details, 76 | int insertIndex) override; 77 | 78 | /** files drag to import */ 79 | virtual bool isInterestedInFileDrag (const StringArray& files) override; 80 | virtual void filesDropped (const StringArray& files, int insertIndex) override; 81 | 82 | const bool importExternalDocs (const Array& docs, 83 | const bool selectOneByOneAfterImport, 84 | const bool isUTF8Format); 85 | 86 | /** draw lines from within the file-tree panel.. */ 87 | virtual void paintHorizontalConnectingLine (Graphics&, const Line& line) override; 88 | virtual void paintVerticalConnectingLine (Graphics&, const Line& line) override; 89 | virtual void paintOpenCloseButton (Graphics&, const Rectangle&, Colour, bool) override; 90 | 91 | private: 92 | //========================================================================= 93 | 94 | /** for click to search a keyword from keywords-table component.*/ 95 | virtual void actionListenerCallback (const String& message) override; 96 | 97 | /** select all its chilren doc which include the given skyword */ 98 | void selectChildren (DocTreeViewItem* currentItem, const String& keyword); 99 | 100 | /** for exportAsHtml. Note: the arg item must be a dir. 101 | Note: 'hide' doc will be excluded. */ 102 | static const bool getDirDocsAndAllMedias (DocTreeViewItem* item, 103 | const File& mdFile, 104 | Array& medias); 105 | 106 | static DocTreeViewItem* getRootItem (DocTreeViewItem* subItem); 107 | 108 | static void statis (const ValueTree& tree, 109 | int& dirNums, 110 | int& totalWords, 111 | int& innerImgNums, 112 | int& exImgNums); 113 | 114 | static void getWordsAndImgNumsInDoc (const ValueTree& tree, 115 | int& words, 116 | int& innerImgNums, 117 | int& exImgNums); 118 | 119 | //========================================================================= 120 | enum MenuIndex 121 | { 122 | newDir = 1, newDoc, importUTF8Docs, importANSIDocs, 123 | packWholeSite, packHtmls, packMedias, 124 | exportTextDoc, exportDocs, dataStatis, keywordsTable, getItemPath, 125 | copyForAnotherProject, pasteFromAnotherProject, 126 | replaceIn, selectDue, remindSet, 127 | rename, deleteThis, 128 | viewInFinder, openInExEditor, browseInEx 129 | }; 130 | 131 | void menuPerform (const int menuIndex); 132 | 133 | void importExternalDocs (const bool isUTF8Format); 134 | void packSiteData (const bool includeHtmls, const bool includeMedias); 135 | void exportAsTextDoc(); 136 | void exportAsHtml(); 137 | void renameSelectedItem(); 138 | void createNewDocument(); 139 | const File createDoc (const String &docName, 140 | const String& content, 141 | const ValueTree& docProperties, 142 | const bool selectAfterCreated); 143 | 144 | void createNewFolder(); 145 | void deleteSelected(); 146 | void statistics(); 147 | void showKeywordsTable(); 148 | void getPath(); 149 | void replaceContent(); 150 | 151 | void crossProjectCopy(); // only for single doc 152 | void crossProjectPaste(); 153 | 154 | void setRemind() const; 155 | static void setRemind (ValueTree thisTree, const int days); 156 | static void getRemindNumbers (ValueTree treeForCheck, int& remindNums, int& dueNums); 157 | 158 | void selectDueDocs(); 159 | static void selectDueDocs (DocTreeViewItem* thisItem); 160 | 161 | //========================================================================= 162 | void valueTreePropertyChanged (ValueTree&, const Identifier&) override; 163 | void valueTreeChildAdded (ValueTree& parentTree, ValueTree&) override; 164 | void valueTreeChildRemoved (ValueTree& parentTree, ValueTree&, int) override; 165 | void valueTreeChildOrderChanged (ValueTree& parentTree, int, int) override; 166 | void valueTreeParentChanged (ValueTree&) override { } 167 | void treeChildrenChanged (const ValueTree& parentTree); 168 | 169 | //========================================================================= 170 | ValueTree tree; // no need and must NOT be refernce!! 171 | FileTreeContainer* treeContainer; 172 | ItemSorter* sorter; 173 | uint32 selectTime; // for left click to popup outline menu 174 | int remindNumber, dueNumber; 175 | bool allowShowMenu; 176 | 177 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DocTreeViewItem) 178 | 179 | }; 180 | 181 | 182 | #endif // HEADERGUA 183 | -------------------------------------------------------------------------------- /Source/EditAndPreview.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | EditAndPreview.h 5 | Created: 4 Sep 2016 12:28:00am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef EDITANDPREVIEW_H_INCLUDED 12 | #define EDITANDPREVIEW_H_INCLUDED 13 | 14 | class SetupPanel; 15 | class MarkdownEditor; 16 | class WebBrowserComp; 17 | class ThemeEditor; 18 | 19 | //============================================================================== 20 | /** For edit a doc or preview the selected item's html and setup its properties. 21 | */ 22 | class EditAndPreview : public Component, 23 | private TextEditor::Listener, 24 | private Timer 25 | { 26 | public: 27 | EditAndPreview (MainContentComponent* mainComp); 28 | ~EditAndPreview(); 29 | 30 | void workAreaStartWork (ValueTree& newDocTree); 31 | void updateEditorContent(); 32 | void editThemeFile (const File& themeFile, bool needRegenerate); 33 | 34 | /** false for switch to edit mode. but note: 35 | true isn't make sure switch to preview mode 36 | (it depends on the state of toolbar's 'big eye' button) */ 37 | void switchMode (const bool switchToPreview); 38 | void forcePreview(); 39 | 40 | void refreshCurrentPage() { webView->refresh(); } 41 | void restartWebBrowser(); 42 | void setMdEditorReadOnly (const bool onlyForRead); 43 | 44 | /** true for stretch theme editor, false for normal */ 45 | void stretchThemeEditor (const bool stretchIt); 46 | 47 | //================================================================================= 48 | void paint (Graphics&) override {} 49 | void resized() override; 50 | 51 | /** if arg 1 is true and arg 2 'showSetupPanel' is false, it'll show theme editor */ 52 | void displaySetupArea (const bool showSetupArea, 53 | const bool showSetupPanel); 54 | 55 | const bool setupAreaIsShowing() const; 56 | const bool themeEditorIsShowing() const; 57 | const File& getEditingThemeFile() const; 58 | 59 | TextEditor* getMdEditor() const { return mdEditor; } 60 | WebBrowserComponent* getWebBrowser() const { return webView; } 61 | const String& getCurrentUrl() const { return currentUrl; } 62 | 63 | const File& getCurrentDocFile() const { return docOrDirFile; } 64 | const String& getCurrentContent() const { return currentContent; } 65 | 66 | ValueTree& getCurrentTree() { return docOrDirTree; } 67 | SetupPanel* getSetupPanel() const { return setupPanel; } 68 | 69 | /** return true if preview state at the present, flase for edit state. */ 70 | const bool getCureentState() const { return webView->isVisible(); } 71 | 72 | /** see DocTreeViewItem::itemClicked() left-click */ 73 | void outlineGoto (const StringArray& titleStrs, const int itemIndex); 74 | 75 | void projectClosed(); 76 | const bool saveCurrentDocIfChanged(); 77 | void showProperties (const bool saveCurrentValues, const ValueTree& tree); 78 | 79 | /** a transfer method */ 80 | const bool selectItemFromHtmlFile (const File& htmlFile); 81 | 82 | void setSearchKeyword (const String& keyword); 83 | 84 | private: 85 | //========================================================================= 86 | void editCurrentDoc(); 87 | void previewCurrentDoc(); 88 | 89 | virtual void textEditorTextChanged (TextEditor&) override; 90 | virtual void timerCallback() override; 91 | 92 | //========================================================================= 93 | File docOrDirFile; 94 | ValueTree docOrDirTree; 95 | bool docHasChanged; 96 | String currentContent, currentUrl; 97 | 98 | MainContentComponent* mainComp; 99 | 100 | ScopedPointer mdEditor; 101 | ScopedPointer webView; 102 | ScopedPointer setupPanel; 103 | ScopedPointer themeEditor; 104 | 105 | StretchableLayoutManager layoutManager; 106 | ScopedPointer layoutBar; 107 | bool showSetupArea; 108 | 109 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (EditAndPreview) 110 | }; 111 | 112 | //================================================================================================= 113 | /** A WebBrowserComponent, it could load an url which with the tag "target=_blank" 114 | in a new modal window. By default, juce's webBrowser can't do this. 115 | 116 | and it'll intercept the inter-link, get it's matched item and select it in the file-tree panel. 117 | 118 | Usage: same as JUCE's WebBrowserComponent */ 119 | class WebBrowserComp : public WebBrowserComponent 120 | { 121 | public: 122 | WebBrowserComp (EditAndPreview* parent_); 123 | ~WebBrowserComp() { } 124 | 125 | /** new dialog window to display the URL */ 126 | virtual void newWindowAttemptingToLoad (const String& newURL) override; 127 | 128 | void openUrlInNewWindow (const String& newURL); 129 | 130 | /** intercept the inter-link and select the matched item in file tree */ 131 | virtual bool pageAboutToLoad (const String& newURL) override; 132 | 133 | private: 134 | EditAndPreview* parent; 135 | 136 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (WebBrowserComp) 137 | }; 138 | 139 | #endif // EDITANDPREVIEW_H_INCLUDED 140 | -------------------------------------------------------------------------------- /Source/FileTreeContainer.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | FileTreeContainer.h 5 | Created: 7 Sep 2016 7:37:28am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef FILETREECONTAINER_H_INCLUDED 12 | #define FILETREECONTAINER_H_INCLUDED 13 | 14 | class FileTreeContainer; 15 | class DocTreeViewItem; 16 | 17 | //========================================================================= 18 | /** For sort items of class DocTreeViewItem. 19 | Usage: create object, then call setTreeViewItem(). 20 | */ 21 | class ItemSorter : public Value::Listener 22 | { 23 | public: 24 | ItemSorter (ValueTree& tree); 25 | ~ItemSorter(); 26 | 27 | void setTreeViewItem (DocTreeViewItem* item) { rootItem = item; } 28 | 29 | const int compareElements (TreeViewItem* first, 30 | TreeViewItem* second) const; 31 | 32 | //============================================================================ 33 | const int getOrder() const { return var (order); } 34 | const int getShowWhat() const { return var (showWhat); } 35 | const int getTooltipToShow() const { return var (tooltip); } 36 | const int getAscending() const { return var (ascending); } 37 | const int getWhichFirst() const { return var (dirFirst); } 38 | 39 | void setOrder (const int value) { order.setValue (value); } 40 | void setShowWhat (const int value) { showWhat.setValue (value); } 41 | void setTooltipToShow (const int value) { tooltip.setValue (value); } 42 | void setAscending (const int value) { ascending.setValue (value); } 43 | void setWhichFirst (const int value) { dirFirst.setValue (value); } 44 | 45 | /** update the file-tree ui and save the project */ 46 | virtual void valueChanged (Value& value) override; 47 | 48 | private: 49 | //========================================================================= 50 | ValueTree& projectTree; 51 | DocTreeViewItem* rootItem; 52 | 53 | Value order, showWhat, tooltip, ascending, dirFirst; 54 | 55 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ItemSorter) 56 | }; 57 | 58 | //============================================================================== 59 | /** Showed in main interface's left. 60 | */ 61 | class FileTreeContainer : public Component, 62 | public DragAndDropContainer 63 | { 64 | public: 65 | FileTreeContainer (EditAndPreview* editAndPreview); 66 | ~FileTreeContainer(); 67 | 68 | void resized() override; 69 | void paint (Graphics& g) override; 70 | 71 | void openProject (const File& projectFile); 72 | void closeProject(); 73 | 74 | const Array getSelectedItems() const; 75 | const bool saveOpenSateAndSelect (const bool alsoSaveProject); 76 | const bool saveDocAndProject(); 77 | 78 | const bool hasLoadedProject() const { return projectTree.isValid(); } 79 | TreeView& getTreeView() { return fileTree; } 80 | EditAndPreview* getEditAndPreview() const { return editAndPreview; } 81 | 82 | const bool aDocSelectedCurrently() const; 83 | void reloadCurrentDoc(); 84 | 85 | static bool saveProject(); 86 | const bool selectItemFromHtmlFile (const File& html); 87 | 88 | // core static objects. this's a BAD design I totally know that but it's handy :) 89 | static File projectFile; 90 | static ValueTree projectTree; 91 | 92 | private: 93 | //========================================================================= 94 | ScopedPointer docTreeItem; 95 | ScopedPointer sorter; 96 | 97 | TreeView fileTree; 98 | EditAndPreview* editAndPreview; 99 | 100 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileTreeContainer) 101 | 102 | }; 103 | 104 | 105 | #endif // FILETREECONTAINER_H_INCLUDED 106 | -------------------------------------------------------------------------------- /Source/HtmlProcessor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | HtmlProcessor.h 5 | Created: 4 Jan 2017 3:34:15pm 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef HTMLPROCESSOR_H_INCLUDED 12 | #define HTMLPROCESSOR_H_INCLUDED 13 | 14 | struct HtmlProcessor 15 | { 16 | HtmlProcessor (const bool sortByReverse_) : sortByReverse (sortByReverse_) { } 17 | 18 | /** let the arg-1 write to the arg-2, then generate arg-3 */ 19 | static void renderHtmlContent (const ValueTree& docTree, 20 | const File& tplFile, 21 | const File& htmlFile); 22 | 23 | /** [keywords]: extract and display all keywords of the project. 24 | 25 | [allPublish]: extract and display all articles, base on created date. 26 | [allModify]: all articles, base on modified date. 27 | 28 | [latestPublish]: top 5 latest created docs which inside the docTree's parent. 29 | [latestModify]: top 5 latest modified docs which inside the docTree's parent, 30 | not include the lastest top 5 created. 31 | [featuredArticle]: top 5 lastest modified featured doc which inside the docTree's parent. 32 | not include the latest modified docs. 33 | 34 | [randomArticle]: 5 random docs from all articles. 35 | */ 36 | static void parseExMdMark (const ValueTree& docTree, 37 | const String& rootRelativePath, 38 | String &mdStrWithoutAbbrev, 39 | String &tplStr); 40 | 41 | static const File createArticleHtml (ValueTree& docTree, bool saveProjectAfterCreated); 42 | static const File createIndexHtml (ValueTree& dirTree, bool saveProjectAfterCreated); 43 | 44 | static const String extractKeywordsOfDocs (const ValueTree& dirTree); 45 | static const String getKeywordsLinks (const String& rootPath); 46 | 47 | //========================================================================= 48 | /** Use for file/dir list sort. Base on create-date */ 49 | const int compareElements (const ValueTree& ft, const ValueTree& st); 50 | 51 | /** the result will include 'hide' doc(s). */ 52 | static void getDocNumbersOfTheDir (const ValueTree& dirTree, int& num); 53 | 54 | /** process the arg-string if it includes any abbrev */ 55 | static const String processAbbrev (const ValueTree& docTree, 56 | const String& originalStr); 57 | 58 | private: 59 | /** Process tpl-file's tags */ 60 | static void processTplTags (const ValueTree& docOrDirTree, 61 | const File& htmlFile, 62 | String& tplStr); 63 | 64 | /** these 2 non-include 'hide' docs */ 65 | static const StringArray getBlogList (const ValueTree& dirTree); 66 | static const String getBookList (const ValueTree& dirTree); 67 | 68 | enum ExtrcatType { publishDate, ModifiedDate, featuredArticle }; 69 | 70 | /** it'll extract modified date when extract featured articles 71 | this method will extract all articles and pages except 'index' and menu-page. 72 | also, not include the arg-5 doc. */ 73 | static void getAllArticleLinksOfGivenTree (const ValueTree& tree, 74 | const String& rootRelativePath, 75 | const ExtrcatType& extractType, 76 | StringArray& links, 77 | const ValueTree& doesntIncludeThisTree); 78 | 79 | /** generate site menu. 2 level dir/doc. that is: 80 | if an item is tend for a site menu, it must not too deep. */ 81 | static const String getSiteMenu (const ValueTree& tree); 82 | 83 | static const String getSiteNavi (const ValueTree& docTree); 84 | static const String getContentTitle (const ValueTree& tree); 85 | static const String getCreateAndModifyTime (const ValueTree& tree); 86 | static const String getPrevAndNextArticel (const ValueTree& tree); 87 | static const String getRandomArticels (const ValueTree& notIncludeThisTree, const int howMany); 88 | 89 | /** The return result could be showed on the very bottom of every web-page */ 90 | static const String getCopyrightInfo(); 91 | static const String getContactInfo(); 92 | 93 | static void copyDocMediasToSite (const File& mdFile, const File& htmlFile, const String& htmlStr); 94 | 95 | public: 96 | /** the end character in the result is '/' */ 97 | static const String getRelativePathToRoot (const File &htmlFile); 98 | 99 | /** extrct the project's title (up to first occurrence of ' ') */ 100 | static const String getSiteLink(const File &htmlFile); 101 | 102 | private: 103 | static const bool atLeastHasOneMenu (const ValueTree& tree); 104 | 105 | //================================================================================================= 106 | /** get a tree that create time previous/next the arg tree */ 107 | static void getPreviousTree (const ValueTree& oTree, const ValueTree& tree, ValueTree& result); 108 | static void getNextTree (const ValueTree& oTree, const ValueTree& tree, ValueTree& result); 109 | 110 | /** ad text from the project setup. its formmat should be "imgName link" 111 | the img should place in site's add-in folder. */ 112 | static const String getAdStr (const String& text, const File& htmlFile); 113 | 114 | /** return 'howMany' ints, range: 0 ~ getDocNumbersOfTheDir (projectTree). */ 115 | static const Array getRandomInts (const int howMany); 116 | 117 | /** get the arg tree's all child tree's link string. their path base on the arg 2 tree. 118 | Note: not include the baseOnThisTree's link and not include create-date, desc, etc. 119 | This method is for random articel. */ 120 | static void getLinkStrOfAlllDocTrees (const ValueTree& fromThisTree, 121 | const ValueTree& baseOnThisTree, 122 | StringArray& linkStr); 123 | 124 | /** this method is for file-list of index.html. it'll include create date and extra info */ 125 | static void getBlogListHtmlStr (const ValueTree& tree, 126 | const File& baseOnthisFile, 127 | StringArray& linkStr); 128 | 129 | static void getBookListLinks (const ValueTree& tree, 130 | const bool isRootTree, 131 | StringArray& linkStr); 132 | 133 | /** arg 2: the caller's page number. 1: No.1 (index.html), 2: No.2 (index-2.html)...*/ 134 | static const String getPageNavi (const int howManyPages, const int thisIsNoX); 135 | static const String getBackPrevLevel(); 136 | static const String getToTop(); 137 | 138 | static void extractKeywords (const ValueTree& tree, StringArray& arrayToAddTo); 139 | 140 | static void getDocTreeWithKeyword (const ValueTree& tree, 141 | const String& keyword, 142 | Array& result); 143 | 144 | //================================================================================================= 145 | bool sortByReverse; 146 | 147 | }; 148 | 149 | 150 | #endif // HTMLPROCESSOR_H_INCLUDED 151 | -------------------------------------------------------------------------------- /Source/KeywordsComp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | KeywordsComp.cpp 5 | Created: 28 Feb 2017 9:14:57am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #include "WdtpHeader.h" 12 | 13 | //================================================================================================= 14 | struct TextButtonLF : public LookAndFeel_V3 15 | { 16 | virtual Font getTextButtonFont (TextButton&, int /*buttonHeight*/) override 17 | { 18 | return Font (16.f); 19 | } 20 | }; 21 | 22 | //================================================================================================= 23 | class KeywordsButtons : public Component, 24 | public Button::Listener, 25 | public ActionBroadcaster 26 | { 27 | public: 28 | KeywordsButtons (const ValueTree& tree, 29 | const bool showInEditor, 30 | const StringArray& kwToMatch) : 31 | displayInEditor (showInEditor) 32 | { 33 | StringArray keywords; 34 | keywords.addTokens (HtmlProcessor::extractKeywordsOfDocs (tree), ",", String()); 35 | 36 | // add buttons 37 | for (int i = keywords.size(); --i >= 0; ) 38 | { 39 | TextButton* bt = new TextButton (keywords[i].replace ("--", " (") 40 | + (keywords[i].contains ("--") ? ")" : String())); 41 | 42 | if (displayInEditor) 43 | bt->setTooltip (keywords[i].upToFirstOccurrenceOf ("--", false, true)); 44 | 45 | bt->setSize (100, 25); 46 | bt->setColour (TextButton::buttonColourId, Colours::lightgrey.withAlpha (0.15f)); 47 | bt->setColour (TextButton::buttonOnColourId, Colours::lightskyblue); 48 | bt->setLookAndFeel (&tlf); 49 | 50 | setToggleIfMatched (bt, kwToMatch); 51 | 52 | bt->addListener (this); 53 | addAndMakeVisible (bt); 54 | bts.insert (0, bt); 55 | } 56 | 57 | const int btNum = keywords.size(); 58 | setSize (550, (btNum / 5 * 30) + ((btNum % 5 != 0) ? 40 : 15)); 59 | } 60 | 61 | //================================================================================================= 62 | ~KeywordsButtons() { } 63 | 64 | //================================================================================================= 65 | const int getKeywordsNumbers() const { return bts.size(); } 66 | 67 | //================================================================================================= 68 | void resized() override 69 | { 70 | int x, y; 71 | x = y = 0; 72 | 73 | for (int i = 0; i < bts.size(); ++i) 74 | { 75 | if (i % 5 == 0 && i != 0) 76 | { 77 | x = 0; 78 | ++y; 79 | } 80 | 81 | bts[i]->setTopLeftPosition (x * 105 + 10, y * 30 + 5); 82 | ++x; 83 | } 84 | } 85 | 86 | //================================================================================================= 87 | virtual void buttonClicked (Button* bt) override 88 | { 89 | const bool toggled = bt->getToggleState(); 90 | const String& buttonText (bt->getButtonText()); 91 | const String& textWithoutTimes (getTextWithoutTimes (bt)); 92 | 93 | if (displayInEditor) 94 | { 95 | bt->setToggleState (!toggled, dontSendNotification); 96 | sendActionMessage ((toggled ? "--" : "++") + textWithoutTimes); 97 | 98 | // times - 1 99 | if (toggled && buttonText.getLastCharacters (1) == ")") 100 | { 101 | int num = bt->getButtonText().dropLastCharacters (1) 102 | .fromLastOccurrenceOf ("(", false, true).getIntValue(); 103 | 104 | if (2 == num) // no need to display the times when it is the first keyword in table 105 | bt->setButtonText (textWithoutTimes); 106 | else 107 | bt->setButtonText (textWithoutTimes + " (" + String (--num) + ")"); 108 | } 109 | 110 | // times + 1 111 | else if (!toggled && buttonText.getLastCharacters (1) == ")") 112 | { 113 | int num = bt->getButtonText().dropLastCharacters (1) 114 | .fromLastOccurrenceOf ("(", false, true).getIntValue(); 115 | 116 | bt->setButtonText (textWithoutTimes + " (" + String (++num) + ")"); 117 | } 118 | 119 | // times turned to be '2' 120 | else if (!toggled && buttonText.getLastCharacters (1) != ")") 121 | { 122 | bt->setButtonText (textWithoutTimes + " (2)"); 123 | } 124 | } 125 | else 126 | { 127 | sendActionMessage (textWithoutTimes); 128 | } 129 | } 130 | 131 | private: 132 | //================================================================================================= 133 | 134 | void setToggleIfMatched (TextButton* bt, const StringArray& kwToMatch) 135 | { 136 | const String& text (getTextWithoutTimes (bt)); 137 | 138 | for (int i = kwToMatch.size(); --i >= 0; ) 139 | { 140 | if (kwToMatch[i] == text) 141 | { 142 | bt->setToggleState (true, dontSendNotification); 143 | return; 144 | } 145 | } 146 | } 147 | 148 | //================================================================================================= 149 | const String getTextWithoutTimes (Button* bt) 150 | { 151 | return bt->getButtonText().upToFirstOccurrenceOf (" (", false, true).trim(); 152 | } 153 | 154 | //================================================================================================= 155 | const bool displayInEditor; 156 | TextButtonLF tlf; 157 | OwnedArray bts; 158 | 159 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KeywordsButtons) 160 | }; 161 | 162 | //============================================================================== 163 | KeywordsComp::KeywordsComp (const ValueTree& tree, 164 | const bool displayInEditor, 165 | const StringArray& keywordsToMatch) 166 | { 167 | viewport = new Viewport(); 168 | viewport->setScrollBarsShown (true, false); 169 | viewport->setScrollBarThickness (10); 170 | 171 | KeywordsButtons* bts = new KeywordsButtons (tree, displayInEditor, keywordsToMatch); 172 | viewport->setViewedComponent (bts); 173 | addAndMakeVisible (viewport); 174 | 175 | titleLb.setFont (18.f); 176 | titleLb.setJustificationType (Justification::centred); 177 | titleLb.setText ((displayInEditor ? TRANS ("Project ") : tree.getProperty ("title").toString() + TRANS ("\'s ")) 178 | + TRANS ("Keywords Table") + " (" + String (bts->getKeywordsNumbers()) + ")", 179 | dontSendNotification); 180 | 181 | addAndMakeVisible (titleLb); 182 | setSize (550, 340); 183 | } 184 | 185 | //================================================================================================= 186 | KeywordsComp::~KeywordsComp() 187 | { 188 | } 189 | //================================================================================================= 190 | void KeywordsComp::paint (Graphics& g) 191 | { 192 | g.fillAll (Colour (0xffdcdbdb)); 193 | } 194 | 195 | //================================================================================================= 196 | void KeywordsComp::resized() 197 | { 198 | titleLb.setBounds (10, 3, getWidth() - 20, 30); 199 | viewport->setBounds (0, 35, getWidth(), getHeight() - 35); 200 | } 201 | 202 | //================================================================================================= 203 | ActionBroadcaster* KeywordsComp::getKeywordsPicker() 204 | { 205 | return dynamic_cast(viewport->getViewedComponent()); 206 | } 207 | -------------------------------------------------------------------------------- /Source/KeywordsComp.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | KeywordsComp.h 5 | Created: 28 Feb 2017 9:14:57am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef KEYWORDSCOMP_H_INCLUDED 12 | #define KEYWORDSCOMP_H_INCLUDED 13 | 14 | class KeywordsComp : public Component 15 | { 16 | public: 17 | KeywordsComp (const ValueTree& tree, 18 | const bool displayInEditor, 19 | const StringArray& keywordsToMatch); 20 | 21 | ~KeywordsComp(); 22 | 23 | void paint (Graphics&) override; 24 | void resized() override; 25 | 26 | /** the actionBrodcaster is inside the viewport. */ 27 | ActionBroadcaster* getKeywordsPicker(); 28 | 29 | private: 30 | //================================================================================================= 31 | Label titleLb; 32 | ScopedPointer viewport; 33 | 34 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (KeywordsComp) 35 | }; 36 | 37 | 38 | #endif // KEYWORDSCOMP_H_INCLUDED 39 | -------------------------------------------------------------------------------- /Source/Main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | Main.cpp 5 | Created: 4 Sep 2016 11:08:17am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #include "WdtpHeader.h" 12 | 13 | // global objects, managed in mainApplication class 14 | PropertiesFile* systemFile = nullptr; 15 | ApplicationCommandManager* cmdManager = nullptr; 16 | 17 | AudioFormatManager* formatManager = nullptr; 18 | AudioDeviceManager* deviceManager = nullptr; 19 | 20 | //============================================================================== 21 | class WDTPApplication : public JUCEApplication 22 | { 23 | public: 24 | //============================================================================== 25 | WDTPApplication() {} 26 | 27 | const String getApplicationName() override { return ProjectInfo::projectName; } 28 | const String getApplicationVersion() override { return ProjectInfo::versionString; } 29 | bool moreThanOneInstanceAllowed() override { return true; } 30 | void systemRequestedQuit() override { quit(); } 31 | 32 | //============================================================================== 33 | void initialise (const String& commandLine) override 34 | { 35 | // for WebBrowserComponent's web-core on Windows (IE7-IE11) 36 | // otherwise, the embedded browser cannot load any js (e.g. code-hightlight..) 37 | SwingUtilities::fixWindowsRegistry(); 38 | 39 | // initial system properties file 40 | const File& f (File::getSpecialLocation (File::userDocumentsDirectory).getChildFile ("wdtp.sys")); 41 | PropertiesFile::Options options; 42 | options.storageFormat = PropertiesFile::storeAsXML; 43 | systemFile = new PropertiesFile (f, options); 44 | 45 | // when first run this application... 46 | if (!f.existsAsFile()) 47 | { 48 | // 0 for English, 1 for Chinese 49 | systemFile->setValue ("language", (SystemStats::getUserRegion() == "CN") ? 1 : 0); 50 | 51 | systemFile->setValue ("uiBackground", Colour (0xff202020).toString()); 52 | systemFile->setValue ("uiTextColour", Colour (0xffe8e8e8).toString()); 53 | systemFile->setValue ("editorFontColour", Colour (0xff181818).toString()); 54 | systemFile->setValue ("editorBackground", Colour (0xffafcc90).toString()); 55 | systemFile->setValue ("fontSize", SwingUtilities::getFontSize() + 1.f); 56 | 57 | systemFile->save(); 58 | } 59 | 60 | // command manager and audio format 61 | cmdManager = new ApplicationCommandManager(); 62 | formatManager = new AudioFormatManager(); 63 | formatManager->registerBasicFormats(); 64 | 65 | // initial audio device 66 | deviceManager = new AudioDeviceManager(); 67 | ScopedPointer audioState (systemFile->getXmlValue ("audioState")); 68 | deviceManager->initialise (2, 2, audioState, true); 69 | 70 | // initial application's GUI 71 | LookAndFeel::setDefaultLookAndFeel (lnf = new SwingLookAndFeel()); 72 | mainWindow = new MainWindow (getApplicationName()); 73 | 74 | // double click to open a project/packed-project in OS-finder 75 | if (commandLine.isNotEmpty() && 76 | (commandLine.contains (".wdtp") || commandLine.contains (".wpck"))) 77 | { 78 | mainWindow->openProject (File (commandLine.unquoted())); 79 | } 80 | else // open the project when eixts the app the last time 81 | { 82 | RecentlyOpenedFilesList recentFiles; 83 | recentFiles.restoreFromString (systemFile->getValue ("recentFiles")); 84 | const File& projectFile (recentFiles.getFile (0)); 85 | 86 | if (projectFile.existsAsFile()) 87 | mainWindow->openProject (projectFile); 88 | } 89 | } 90 | 91 | //========================================================================= 92 | void shutdown() override 93 | { 94 | // must destroy all guis first since they're using the systemFile object 95 | PopupMenu::dismissAllActiveMenus(); 96 | mainWindow = nullptr; 97 | 98 | systemFile->saveIfNeeded(); 99 | TipsBank::deleteInstance(); 100 | 101 | deleteAndZero (systemFile); 102 | deleteAndZero (cmdManager); 103 | deleteAndZero (formatManager); 104 | deleteAndZero (deviceManager); 105 | 106 | // delete all desktop when one of them is showing while exit the application 107 | for (int i = Component::getNumCurrentlyModalComponents(); --i >= 0; ) 108 | delete (Component::getCurrentlyModalComponent (i)); 109 | } 110 | 111 | //========================================================================= 112 | void anotherInstanceStarted (const String& commandLine) override 113 | { 114 | mainWindow->openProject (File (commandLine)); 115 | } 116 | 117 | private: 118 | ScopedPointer lnf; 119 | ScopedPointer mainWindow; 120 | }; 121 | 122 | //============================================================================== 123 | 124 | START_JUCE_APPLICATION (WDTPApplication) 125 | -------------------------------------------------------------------------------- /Source/MainComponent.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | MainComponent.cpp 5 | Created: 4 Sep 2016 11:08:17am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #include "WdtpHeader.h" 12 | 13 | extern PropertiesFile* systemFile; 14 | extern ApplicationCommandManager* cmdManager; 15 | File lameEncoder; 16 | 17 | //============================================================================== 18 | MainContentComponent::MainContentComponent() : 19 | Thread ("CheckNewVersion"), 20 | showFileTreePanel (true) 21 | { 22 | if (1 == systemFile->getIntValue ("language")) 23 | { 24 | const String& languageStr = MemoryBlock (BinaryData::transcn_h, BinaryData::transcn_hSize).toString(); 25 | LocalisedStrings::setCurrentMappings (new LocalisedStrings (languageStr, true)); 26 | } 27 | 28 | // must be these order... 29 | addAndMakeVisible (editAndPreview = new EditAndPreview (this)); 30 | addAndMakeVisible (fileTree = new FileTreeContainer (editAndPreview)); 31 | addAndMakeVisible (toolBar = new TopToolBar (fileTree, editAndPreview)); 32 | addAndMakeVisible (layoutBar = new StrechableBar (&layoutManager, 1, true)); 33 | 34 | /* here must disable the preview button of the toolbar 35 | to prevent the jassert when the app doesn't load any project 36 | the arg 2 will decide the editor's mode (preview or edit) after 37 | the app running with a project has loaded */ 38 | toolBar->enableEditPreviewBt (false, true); 39 | 40 | // stretched layout. arg: index, min-width, max-width,default x% 41 | layoutManager.setItemLayout (0, 2, -0.3, -0.20); // fileTree 42 | layoutManager.setItemLayout (1, 2, 2, 2); // layoutBar 43 | layoutManager.setItemLayout (2, -0.7, -1.0, -0.80); // editAndPreview 44 | 45 | addAndMakeVisible (webBrowserForStatis = new WebBrowserComponent (true)); 46 | setSize (1000, 740); 47 | 48 | // check new version and download mp3-encoder if it's not there 49 | startTimer (500); 50 | } 51 | 52 | //======================================================================= 53 | MainContentComponent::~MainContentComponent() 54 | { 55 | stopTimer(); 56 | 57 | if (isThreadRunning()) 58 | stopThread (2000); 59 | } 60 | //========================================================================= 61 | void MainContentComponent::paint (Graphics& g) 62 | { 63 | g.fillAll (Colour::fromString (systemFile->getValue ("uiBackground"))); 64 | } 65 | 66 | //========================================================================= 67 | void MainContentComponent::resized() 68 | { 69 | webBrowserForStatis->setBounds (1, getHeight() - 1, getWidth() - 2, 1); 70 | toolBar->setBounds (0, 0, getWidth(), 45); 71 | toolBar->toFront (true); 72 | 73 | if (getWidth() > 740 && showFileTreePanel) // stretched layout 74 | { 75 | fileTree->setVisible (true); 76 | layoutBar->setVisible (true); 77 | 78 | Component* comps[] = { fileTree, layoutBar, editAndPreview }; 79 | layoutManager.layOutComponents (comps, 3, 0, 45, getWidth(), getHeight() - 46, false, true); 80 | } 81 | else // silent-mode (only makes the editor visable) 82 | { 83 | fileTree->setVisible (false); 84 | layoutBar->setVisible (false); 85 | editAndPreview->setBounds (0, 45, getWidth(), getHeight() - 46); 86 | } 87 | } 88 | 89 | //================================================================================================= 90 | void MainContentComponent::setSearchInputVisible (const bool shouldVisible) 91 | { 92 | toolBar->setSearchInputVisible (shouldVisible); 93 | } 94 | 95 | //================================================================================================= 96 | void MainContentComponent::displayFileTree (const bool showFileTree) 97 | { 98 | showFileTreePanel = showFileTree; 99 | resized(); 100 | } 101 | 102 | //================================================================================================= 103 | const bool MainContentComponent::aDocSelectedCurrently() const 104 | { 105 | return fileTree->aDocSelectedCurrently(); 106 | } 107 | 108 | //================================================================================================= 109 | void MainContentComponent::reloadCurrentDoc() 110 | { 111 | fileTree->reloadCurrentDoc(); 112 | } 113 | 114 | //================================================================================================= 115 | const bool MainContentComponent::selectItemFromHtmlFile (const File& html) 116 | { 117 | return fileTree->selectItemFromHtmlFile (html); 118 | } 119 | 120 | //================================================================================================= 121 | void MainContentComponent::timerCallback() 122 | { 123 | stopTimer(); 124 | 125 | showStartTip(); 126 | startThread(); // must using background thread on Android when connect internet 127 | } 128 | 129 | //================================================================================================= 130 | void MainContentComponent::run() 131 | { 132 | // check new version 133 | URL url ("https://raw.githubusercontent.com/LegendRhine/WDTP/master/Source/version"); 134 | const String& urlContent = url.readEntireTextStream().trim(); 135 | 136 | if (urlContent.isEmpty() 137 | || urlContent.length() > 10 138 | || urlContent.length() < 8 // 1.0.0101 ~ 99.99.1231 139 | || urlContent.containsAnyOf ("abcdefghijklmnopqrstuvwxyz" 140 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 141 | "<>/\\+-*!@#$%^&*()_=-`~[]{}")) 142 | { 143 | return; 144 | } 145 | 146 | const String& currentVersion ("1" + String (ProjectInfo::versionString).replace (".", String())); 147 | const String& urlVersion ("1" + urlContent.replace (".", String())); 148 | //DBGX (currentVersion << " - " << urlVersion); 149 | 150 | if (currentVersion.getIntValue() < urlVersion.getIntValue()) 151 | { 152 | const MessageManagerLock mmLock; 153 | toolBar->hasNewVersion(); 154 | } 155 | 156 | // download mp3 encoder if it's not there 157 | #if JUCE_WINDOWS 158 | lameEncoder = File::getSpecialLocation (File::userDocumentsDirectory).getChildFile ("lame.exe"); 159 | url = URL::createWithoutParsing ("https://github.com/LegendRhine/gitBackup/raw/master/applications/lame-win.zip"); 160 | #elif JUCE_MAC 161 | lameEncoder = File::getSpecialLocation (File::userDocumentsDirectory).getChildFile ("lame.app"); 162 | url = URL::createWithoutParsing ("https://github.com/LegendRhine/gitBackup/raw/master/applications/lame-osx.zip"); 163 | #endif 164 | 165 | if (!lameEncoder.existsAsFile()) 166 | { 167 | MemoryBlock mb; 168 | 169 | // put it in userDocumentsDirectory 170 | if (url.readEntireBinaryStream (mb)) 171 | { 172 | MemoryInputStream inputSteam (mb, false); 173 | ZipFile zip (inputSteam); 174 | zip.uncompressEntry (0, File::getSpecialLocation (File::userDocumentsDirectory)); 175 | lameEncoder.setExecutePermission (true); 176 | } 177 | } 178 | 179 | // statis 180 | webBrowserForStatis->goToURL ("https://legendrhine.github.io/WDTP/index.html"); 181 | } 182 | 183 | //================================================================================================= 184 | void MainContentComponent::showStartTip() 185 | { 186 | if (!fileTree->hasLoadedProject()) 187 | { 188 | Label info (String(), TRANS ("Click here and 'New Project...'\n\nStart your journey of WDTP!")); 189 | info.setColour (Label::textColourId, Colours::greenyellow.withAlpha (0.8f)); 190 | info.setFont (SwingUtilities::getFontSize() - 2.f); 191 | info.setJustificationType (Justification::centred); 192 | info.setSize (240, 70); 193 | 194 | CallOutBox callOut (info, toolBar->getScreenBounds(), nullptr); 195 | callOut.runModalLoop(); 196 | } 197 | } 198 | 199 | //================================================================================================= 200 | MainWindow::MainWindow (const String& name) : 201 | DocumentWindow (name, Colours::lightgrey, 202 | DocumentWindow::minimiseButton | DocumentWindow::closeButton) 203 | { 204 | setContentOwned (mainComp = new MainContentComponent(), true); 205 | 206 | // command manager 207 | cmdManager->registerAllCommandsForTarget (mainComp->getToolbar()); 208 | addKeyListener (cmdManager->getKeyMappings()); 209 | cmdManager->setFirstCommandTarget (mainComp->getToolbar()); 210 | 211 | setResizable (true, false); 212 | setResizeLimits (640, 480, 3200, 2400); 213 | setUsingNativeTitleBar (true); 214 | setCentreRelative (0.5f, 0.5f); 215 | 216 | setFullScreen (true); 217 | setVisible (true); 218 | 219 | mainComp->setSearchInputVisible (false); 220 | mainComp->grabKeyboardFocus(); 221 | } 222 | 223 | //================================================================================================= 224 | void MainWindow::closeButtonPressed() 225 | { 226 | // save and exit 227 | if (mainComp->getFileTree()->saveOpenSateAndSelect (true) 228 | && mainComp->getEditAndPreview()->saveCurrentDocIfChanged()) 229 | { 230 | JUCEApplication::getInstance()->systemRequestedQuit(); 231 | } 232 | else 233 | { 234 | if (AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, TRANS ("Message"), 235 | TRANS ("Something wrong during saving this project.") + 236 | newLine + newLine + 237 | TRANS ("Do you really want to quit?"))) 238 | { 239 | JUCEApplication::getInstance()->systemRequestedQuit(); 240 | } 241 | } 242 | } 243 | 244 | //================================================================================================= 245 | void MainWindow::openProject (const File& projectFile) 246 | { 247 | mainComp->getFileTree()->openProject (projectFile); 248 | } 249 | 250 | //================================================================================================= 251 | void MainWindow::activeWindowStatusChanged() 252 | { 253 | if (isActiveWindow()) 254 | mainComp->reloadCurrentDoc(); 255 | } 256 | 257 | -------------------------------------------------------------------------------- /Source/MainComponent.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | MainComponent.cpp 5 | Created: 4 Sep 2016 11:08:17am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef MAINCOMPONENT_H_INCLUDED 12 | #define MAINCOMPONENT_H_INCLUDED 13 | 14 | class TopToolBar; 15 | class FileTreeContainer; 16 | class EditAndPreview; 17 | 18 | //============================================================================== 19 | class MainContentComponent : public Component, 20 | public Thread, 21 | private Timer 22 | { 23 | public: 24 | //============================================================================== 25 | MainContentComponent(); 26 | ~MainContentComponent(); 27 | 28 | void paint (Graphics&) override; 29 | void resized() override; 30 | 31 | /** transfer method */ 32 | void setSearchInputVisible (const bool shouldVisible); 33 | 34 | void displayFileTree (const bool showFileTree); 35 | FileTreeContainer* getFileTree() const { return fileTree; } 36 | TopToolBar* getToolbar() const { return toolBar; } 37 | EditAndPreview* getEditAndPreview() const { return editAndPreview; } 38 | 39 | 40 | /** 3 transfer methods */ 41 | const bool aDocSelectedCurrently() const; 42 | void reloadCurrentDoc(); 43 | const bool selectItemFromHtmlFile (const File& htmlFile); 44 | 45 | /** these 2 for check the new version and download mp3-encoder if it's not there. */ 46 | virtual void timerCallback() override; 47 | virtual void run() override; 48 | 49 | /** show some info after launch the app and no project has been loaded */ 50 | void showStartTip(); 51 | 52 | private: 53 | //========================================================================= 54 | ScopedPointer toolBar; 55 | ScopedPointer fileTree; 56 | ScopedPointer editAndPreview; 57 | 58 | StretchableLayoutManager layoutManager; 59 | ScopedPointer layoutBar; 60 | ScopedPointer webBrowserForStatis; 61 | bool showFileTreePanel; 62 | 63 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent) 64 | }; 65 | 66 | //============================================================================== 67 | 68 | /** Main window on desktop */ 69 | class MainWindow : public DocumentWindow 70 | { 71 | public: 72 | MainWindow (const String& name); 73 | ~MainWindow() { } 74 | 75 | void closeButtonPressed() override; 76 | void openProject (const File& projectFile); 77 | 78 | /** transfer method */ 79 | void setSearchInputVisible (const bool shouldVisible) { mainComp->setSearchInputVisible (shouldVisible); } 80 | 81 | /** reload the current doc which has been edited from external editor */ 82 | virtual void activeWindowStatusChanged() override; 83 | 84 | private: 85 | ScopedPointer mainComp; 86 | TooltipWindow toolTips; 87 | 88 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow) 89 | }; 90 | 91 | 92 | #endif // MAINCOMPONENT_H_INCLUDED 93 | -------------------------------------------------------------------------------- /Source/MarkdownEditor.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | MarkdownEditor.h 5 | Created: 8 Feb 2017 2:46:52am 6 | Author: SwingCoder 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef MARKDOWNEDITOR_H_INCLUDED 12 | #define MARKDOWNEDITOR_H_INCLUDED 13 | 14 | #include "SwingLibrary/SwingEditor.h" 15 | 16 | /** A text editor especially for Markdown input, display and edit. 17 | The powerful functions totally in its right-click popup-menu and 18 | some shortcuts - see its keyPressed(). 19 | */ 20 | class MarkdownEditor : public SwingEditor, 21 | public Slider::Listener, 22 | public ChangeListener, 23 | public FileDragAndDropTarget, 24 | private ActionListener 25 | { 26 | public: 27 | MarkdownEditor (EditAndPreview* parent_); 28 | ~MarkdownEditor() { } 29 | 30 | void paint (Graphics& g) override; 31 | 32 | //================================================================================================= 33 | static void popupOutlineMenu (EditAndPreview* editAndPreview, 34 | const String& editorContent, 35 | bool showMessageWhenNoOutline); 36 | 37 | virtual void addPopupMenuItems (PopupMenu& menuToAddTo, 38 | const MouseEvent* mouseClickEvent) override; 39 | 40 | virtual void performPopupMenuAction (int menuItemID) override; 41 | bool keyPressed (const KeyPress& key) override; 42 | void insertExternalFiles (const Array& mediaFiles); 43 | 44 | /** prevent popup tips menu after drag and drop selected text*/ 45 | virtual void mouseUp (const MouseEvent& e) override; 46 | 47 | /** for set the font-size and color of font and backgroud */ 48 | virtual void sliderValueChanged (Slider* slider) override; 49 | virtual void changeListenerCallback (ChangeBroadcaster* source) override; 50 | 51 | /** drag and drop native files */ 52 | virtual bool isInterestedInFileDrag (const StringArray& files) override; 53 | virtual void filesDropped (const StringArray& files, int x, int y) override; 54 | 55 | /** auto-complete, show tips...*/ 56 | virtual void insertTextAtCaret (const String& textToInsert) override; 57 | void autoComplete (const int index); 58 | 59 | /** show real-time tips */ 60 | virtual void timerCallback() override; 61 | 62 | private: 63 | //============================================================================================= 64 | enum MenuIndex 65 | { 66 | pickTitle = 1, addKeywords, pickFromAllKeywords, pickDesc, 67 | insertMedia, insertHyperlink, insertQuota, timeLine, 68 | insertNormalTable, insertInterlaced, insertNoborderTable, 69 | insertAlignCenter, insertAlignRight, 70 | doubleLinespcing, tripleLinespcing, 71 | insertUnoerderList, insertOrderList, 72 | insertFirstTitle, insertSecondTitle, insertThirdTitle, 73 | insertToc, insertEndnote, insertBackToTop, formatPostil, 74 | insertIdentifier, insertTime, 75 | insertCaption, insertSeparator, insertAuthor, insertInterLink, 76 | formatBold, formatItalic, formatBoldAndItalic, formatHighlight, 77 | codeBlock, hybridLayout, commentBlock, inlineCode, antiIndent, 78 | fontName, textSize, textColor, 79 | forceIndent, audioRecord, 80 | autoSumPara, autoAvPara, autoSumCol, autoAvCol, 81 | latestPublish, latestModify, featuredArticle, 82 | allKeywords, randomArticle, allPublish, allModify, 83 | searchNext, searchPrev, 84 | searchByGoogle, searchByBing, searchByWiki, baiduBaike, 85 | transByGoogle, transByBaidu, showTips, joinTips, 86 | fontSize, fontColor, setBackground, resetDefault, 87 | outlineMenu, setExEditorForMedia, editMediaByExEditor, 88 | convertToJpg, halfWidth, threeQuarterWidth, transparentImg, 89 | rotateImgLeft, rotateImgRight, syntax 90 | }; 91 | 92 | /** pick the selected to 'tile', 'keywords', 'description' of this doc*/ 93 | void pickSelectedToProperties (const int pickType); 94 | 95 | /** for click to select/unselect a keyword from keywords-table component. 96 | see showAllKeywords(). */ 97 | virtual void actionListenerCallback (const String& message) override; 98 | void showAllKeywords(); 99 | 100 | /** if the selected text is a file name without its extension, 101 | it will return its 'full' name (doesn't include its path, 102 | only the file's name with its extension) */ 103 | const String getSelectedFileName() const; 104 | 105 | /** return: 0 for image file, 1 for mp3 file, -1 for unknown type */ 106 | const int getSelectedMediaType() const; 107 | 108 | /** tableStyle: should be the menu index see above */ 109 | void tableInsert (const int tableStyle); 110 | void hyperlinkInsert(); 111 | void insertExternalFiles(); 112 | void insertTimeLine(); 113 | 114 | /** expandIndex: should be the menu index see above */ 115 | void insertExpandMark (const int expandIndex); 116 | void quotaInsert(); 117 | void insertIndent (const bool isIndent); // false for anti-indent 118 | void insertTitle (const int level); 119 | void endnoteInsert(); 120 | void tocInsert(); 121 | void identifierInsert(); 122 | void addSelectedToKeywords (const String& selectedStr); 123 | void subtractFromKeywords (const String& keyword); 124 | 125 | void alignCenterInsert(); 126 | void alignRightInsert(); 127 | void orderListInsert(); 128 | void unorderListInsert(); 129 | void captionInsert(); 130 | void interLinkInsert(); 131 | void authorInsert(); 132 | void dateAndTimeInsert(); 133 | void codeBlockFormat(); 134 | void hybridFormat(); 135 | void commentBlockFormat(); 136 | 137 | void returnKeyInput(); 138 | void pasteForCtrlV(); 139 | void recordAudio(); 140 | 141 | void searchPrevious(); 142 | void searchForNext(); 143 | void externalSearch (const int searchType); 144 | 145 | void setFontSize(); 146 | void setFontColour(); 147 | void setBackgroundColour(); 148 | void resetToDefault(); 149 | 150 | /** formatIndex: should be the menu index see above */ 151 | void inlineFormat (const int formatIndex); 152 | void selectedAddToTipsBank(); 153 | 154 | /** auto sum/average all numbers of the current paragraph. 155 | the separater between each number must be whitespace or ' | ' 156 | 157 | @para isSum true for sum, false for average */ 158 | void calculateNumbersOfCurrentParagraph (const bool isSum); 159 | 160 | /** auto sum/average all numbers of the current column. 161 | the separater between each number must be ' | ' 162 | this method only for table. 163 | 164 | @para isSum true for sum, false for average */ 165 | void calculateNumbersOfCurrentColumn (const bool isSum); 166 | 167 | //============================================================================================= 168 | EditAndPreview* parent; 169 | Slider fontSizeSlider; 170 | ScopedPointer fontColourSelector; 171 | ScopedPointer bgColourSelector; 172 | 173 | StringArray menuItems; // for popup tips 174 | int tipKeyNumber = 2; 175 | bool ctrlGpressed = false; 176 | 177 | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MarkdownEditor) 178 | }; 179 | 180 | 181 | #endif // MARKDOWNEDITOR_H_INCLUDED 182 | -------------------------------------------------------------------------------- /Source/README.md: -------------------------------------------------------------------------------- 1 | # Walden Trip (山·湖·路) 2 | 3 | ![WDTP](http://underwaysoft.com/works/wdtp/media/wdtp-main.jpg) 4 | 5 | ### System Setup 6 | - PropertiesFile (systemFile, the file of system properties) is place in the local 'user-documents/wdtp.sys'. 7 | - recentFiles: 10 items of the recent-opened. 8 | - language: The language of UI text (String, language name). 9 | - uiBackground 10 | - uiTextColour: it has only 2 colors (dark/light) based on the background of UI. 11 | - fontName: (haven't been using yet.) 12 | - fontSize: The font-size of TextEditor. 13 | - editorFontColour 14 | - editorBackground 15 | - imageEditor: default application for edit image file 16 | - audioEditor: default application for edit audiao file 17 | 18 | ### Project File 19 | - '.wdtp' for the normal project file, the packed project is '.wpck', '.wtpl' is the theme when it has been exported. 20 | - It uses ValueTree (data-model), TreeView (UI) and TreeViewItems (controller) to manage/display/operate all the items which recorded in the project file. 21 | - The structure of project is same as the structure of local-disk file system, however it doesn't include any 'media' or other folder/files. 22 | 23 | ### Properties of Project ValueTree 24 | 25 | #### Structure: 26 | 27 | - wdtpProject 28 | - resource 29 | - dir 30 | - doc 31 | 32 | - wdtpProject: root valueTree, also represents the Project Properties. 33 | - name: it should be 'site' always. 34 | - tile 35 | - keywords: keywords of its own (means: keywords of this dir, not all the keywords of this project) 36 | - description 37 | - owner 38 | - contact: matches {{contact}} in a tpl 39 | - copyright: it could be place at the bottom of a page 40 | - order: It'll decide the items' display order. 41 | - 0: file name 42 | - 1: title 43 | - 2: page file name 44 | - 3: file size 45 | - 4: create time 46 | - 5: last modified time 47 | - dirFirst: 0 for dir first, 1 for doc first 48 | - ascending: up (0), down (1) 49 | - showWhat: 50 | - file name (0) 51 | - title (1) 52 | - page name (2) 53 | - tooltip: 54 | - file name (0) 55 | - title (1) 56 | - page name (2) 57 | - render: the dir of tpls which is placed in the 'project-dir/themes'. 58 | - tplFile: for render the index.html of the site, it should be a '.html' tpl-file inside the render dir. 59 | - js: JavaScript code, it'll site within < head > area of the index.html. 60 | - ad: The form should be: 'Image-file-name (whitespace) Link-address', one for pre row. It matched the {{ad}} tag from within a tpl. 61 | - modifyDate 62 | - needCreateHtml 63 | - stateAndSelect: the file tree's openness and selected state 64 | - resources: the form should be: 'name = path', one for pre row, allow empty line between rows. 65 | 'name': specified by user and will be showed in system menu 66 | 'path': full path of the resource 67 | 68 | - Dir: child tree(s) of wdtoProject 69 | - name: the name of this dir, it doesn't include any parent's name (path). 70 | - title: it also be the menu-text if it was set to a site menu 71 | - keywords 72 | - description 73 | - createDate 74 | - modifyDate 75 | - isMenu: if true, it will be a site-menu-item 76 | - tplFile: for render this dir's index.html 77 | - js: see above 78 | - needCreateHtml 79 | 80 | - Doc: child tree(s) of Dir (if a doc's name is 'tips' and belong to the root-item/project-item, it'll be the think-bank source and auto 'hide') 81 | - name: file name, it doesn't include file-extension and any parent path. 82 | - title 83 | - keywords 84 | - showKeywords 85 | - description 86 | - createDate 87 | - modifyDate 88 | - isMenu: the doc must not deep than 3 levels (relative to the root ('site/')) 89 | - tplFile: for render this doc 90 | - js 91 | - thumb: extract an image which in this doc as the doc's title-graph or not. 92 | - thumbName: name of the title-graph (image), it should begin with 'media/' 93 | - needCreateHtml 94 | - abbrev: form: (abbrev-name)(space)(original content), 1 per line 95 | - reviewDate 96 | - featured 97 | - hide: doesn't appear in all kinds of list, also don't put its keywords in to statis 98 | - archive: can't edit anymore, can't replace anything by default 99 | 100 | ### Tags (for developer. These tags could be placed in < head >) 101 | - {{siteRelativeRootPath}} relative root-path of a page. eg. the page is 'site/dir/subDir/00.html', 102 | its root-path should be '../../../'. 103 | Note: the last charactor must be '/'. 104 | This tag could be used in < head >, for link the external css-file 105 | 106 | - {{keywords}}: meta in < head > 107 | - {{description}}: meta in < head > 108 | - {{title}}: meta in < head > 109 | 110 | ### Tempalte Tags (for web/tpl designer. These tags should be placed in < body > area) 111 | - {{contentTitle}}: Title of the doc/dir. 112 | - {{contentDesc}}: Description of the doc/dir. 113 | - {{content}}: Content of the doc. 114 | 115 | - {{siteLogo}}: the logo image should place in 'site/add-in/' and its name should be 'logo.png'. 116 | - {{siteMenu}} 117 | - {{siteNavi}} 118 | - {{siteLink}}: the result is "ProjectTitle" 119 | 120 | - {{createAndModifyTime}} 121 | - {{previousAndNext}} 122 | - {{ad}}: see 'ad' of Project property. Note: ad images should place in 'site/add-in/'. 123 | - {{random}}: 5 random articles. 124 | - {{contact}} 125 | 126 | - {{toTop}}: click to the top of the page. 127 | - {{backPrevious}}: for 'book' tpls, click to back to the parent's index.html. 128 | - {{bottomCopyright}} 129 | 130 | - {{titleOfDir}} 131 | - {{blogList}}: for 'blog' index.html. Articles list. 10/page. 132 | - {{bookList}}: for 'book' index.html, include dir. all in one page. 133 | 134 | ### Shortcut Assign (totally 49+) 135 | 136 | - F1: help for markup syntax 137 | - Ctrl + F1: add the selected content to tips-bank 138 | - F2: sum all numbers of current row 139 | - Ctrl + F2: average all numbers of current row 140 | - F3: select next selection 141 | - Shift + F3: select previous selection 142 | - F4: sum all numbers of current column (table special) 143 | - Ctrl + F4: average all numbers of current column (table special) 144 | - F5: regenerate the current page and refresh it 145 | - F6: regenarate all the changed docs and dirs (not the whole site) 146 | - F7: insert timeline 147 | - F8: insert table of contents (TOC) 148 | - F9: insert endnote 149 | - F10: insert date and time of current 150 | 151 | - Ctrl + 1: popup right click menu (both for md editor and theme editor) 152 | - Ctrl + 2: show keywords table of current project 153 | - Ctrl + 3: insert hybrid markup 154 | - Ctrl + 4: postil the selected text 155 | - Ctrl + 5: insert back to top markup 156 | - Ctrl + 6: pick the selected text as the doc's title 157 | - Ctrl + 7: pick the selected text as the doc's description 158 | - Ctrl + 8: add the selected text to the doc's keywords list 159 | - Ctrl + 9: reset the editor's font size, font and background color to system default 160 | 161 | - Ctrl + A: select all content (text markup syntax) 162 | - Ctrl + B: bold (text markup syntax) 163 | - Ctrl + C: copy 164 | - Ctrl + D: switch silent/full mode 165 | - Ctrl + E: popup a dialog to insert a text hyperlink 166 | - Ctrl + F: active search 167 | - Ctrl + G: popup tips for the selected text (if it has) 168 | - Ctrl + H: hide (minimize) the app 169 | - Ctrl + I: italic (text markup syntax) 170 | - Ctrl + J: popup outline menu of editor 171 | - Ctrl + K: insert code block (text markup syntax) 172 | - Ctrl + L: insert inline code (text markup syntax) 173 | - Ctrl + M: insert images (text markup syntax) 174 | - Ctrl + N: align center (text markup syntax) 175 | - Ctrl + O: insert author (text markup syntax) 176 | - Ctrl + P: insert caption (text markup syntax) 177 | - Ctrl + Q: exit the app 178 | - Ctrl + R: align right (text markup syntax) 179 | - Ctrl + S: switch edit/preview 180 | - Ctrl + T: insert table (text markup syntax) 181 | - Ctrl + U: highlight text (text markup syntax) 182 | - Ctrl + V: intelligent paste 183 | - Ctrl + W: audio record (text markup syntax) 184 | - Ctrl + X: cut 185 | - Ctrl + Y: redo 186 | - Ctrl + Z: undo 187 | 188 | - Punctuation matching and auto popup tips menu... 189 | 190 | ### 3rd Library and 3rd Lib-hacked 191 | - JUCE: https://juce.com 192 | - ASIO: https://steinberg.net 193 | - JUCE lib-hacked source files: Source/libHackBackup 194 | -------------------------------------------------------------------------------- /Source/RecordComp.h: -------------------------------------------------------------------------------- 1 | /* 2 | ============================================================================== 3 | 4 | RecordAndEditComp.h 5 | Created: 8 Jun 2015 1:03:18am 6 | Author: mit2000 7 | 8 | ============================================================================== 9 | */ 10 | 11 | #ifndef RECORDANDCOMP_H_INCLUDED 12 | #define RECORDANDCOMP_H_INCLUDED 13 | 14 | class RecordingThumbnail; 15 | 16 | //============================================================================== 17 | /** Usage: whenever use this class, create object for each time! then setVisible()! 18 | */ 19 | class RecordComp : public Component, 20 | public ActionBroadcaster, 21 | public Button::Listener, 22 | public Slider::Listener, 23 | private AudioDataPlayer::Listener, 24 | private Timer 25 | { 26 | public: 27 | RecordComp (const File& docFile); 28 | ~RecordComp(); 29 | 30 | //void setRecToPlay (AudioFormatReader* reader); 31 | 32 | void paint (Graphics&) override; 33 | void resized() override; 34 | 35 | void buttonClicked (Button* button) override; 36 | virtual void sliderValueChanged (Slider* slider) override; 37 | 38 | // click to position the play line 39 | void mouseDown (const MouseEvent& event) override; 40 | void mouseDrag (const MouseEvent& event) override; 41 | void mouseUp (const MouseEvent& event) override; 42 | 43 | private: 44 | //========================================================================= 45 | enum Buttons { recBt = 0, playBt, cutBt, delBt, doneBt, totalButtons }; 46 | 47 | // refresh labels 48 | virtual void timerCallback() override; 49 | 50 | void setAudioReader (AudioFormatReader* reader); 51 | 52 | void startRecord(); 53 | void beginRecord(); 54 | void stopRecord(); 55 | 56 | virtual void playFinished (AudioDataPlayer* player) override; 57 | virtual void playerStarted (AudioDataPlayer* player) override; 58 | virtual void playerStopped (AudioDataPlayer* player) override; 59 | 60 | void writeMp3AudioToMediaDir (const String& fileName); 61 | 62 | //========================================================================= 63 | double currentSeconds, totalSeconds; 64 | uint32 baseTime; 65 | bool needSaveToMediaDir; 66 | const File mediaDir; 67 | 68 | AudioRecorder* recorder; 69 | AudioDataPlayer* player; 70 | RecordingThumbnail* recordThumbnail; 71 | DrawableRectangle currentPositionMarker; 72 | 73 | OwnedArray buttons; 74 | ScopedPointer