1 /* 2 FXiTe - The Free eXtensIble Text Editor 3 Copyright (c) 2009-2012 Jeffrey Pohlmeyer <yetanothergeek@gmail.com> 4 5 This program is free software; you can redistribute it and/or modify it 6 under the terms of the GNU General Public License version 3 as 7 published by the Free Software Foundation. 8 9 This software is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19 20 class UserMenuHelper; 21 22 class UserMenu: public FXObject { 23 FXDECLARE(UserMenu) UserMenu()24 UserMenu(){} 25 friend class UserMenuHelper; 26 private: 27 bool hasitems; 28 FXObjectListOf<FXMenuPane> panes; 29 FXMenuCascade*topcasc; 30 FXString toplabel; 31 FXString topdir; 32 FXMenuPane *topowner; 33 int level; 34 FXWindow *target; 35 FXSelector selector; 36 const char**_flags; 37 char _tag; 38 protected: 39 int count; 40 void ScanDir(FXMenuPane*parent, const char *directory); 41 void create(); 42 void DeletePanes(); 43 public: getTarget()44 FXWindow*getTarget() { return target; } getSelector()45 FXSelector getSelector() { return selector; } getCount()46 int getCount() { return count; } 47 UserMenu(FXMenuPane *owner, 48 const FXString &label, const FXString &dirname, char tag, FXObject *tgt, FXSelector sel, const char**flags=NULL); 49 ~UserMenu(); 50 void rescan(); 51 void enable(); 52 void disable(); 53 FXString getText(); 54 void setText(const FXString &s); getFlags()55 const char** getFlags() const { return _flags; }; menu()56 const FXMenuPane*menu() const { return (panes.no()>0)?panes[0]:NULL; } 57 FXString helptext; helpText(const char * txt)58 void helpText(const char*txt) { helptext=txt; } getTopDir()59 const char*getTopDir(){ return topdir.text(); } 60 static bool MakeLabelFromPath(const char*path, FXString &label); Tag()61 char Tag() { return _tag; } 62 }; 63 64 65 66 67 class HistMenu: public FXMenuPane { 68 private: FXDECLARE(HistMenu)69 FXDECLARE(HistMenu) 70 HistMenu(){} 71 protected: 72 FXString group; 73 FXMenuCascade*casc; 74 FXApp*app; 75 bool created; 76 void add_item(const FXString &txt, bool prepended); 77 void append(const FXString &txt); 78 FXMenuCommand*find(const FXString &txt); 79 public: 80 long onItemClick(FXObject*o,FXSelector sel,void*p); 81 enum { 82 ID_ITEM_CLICK=FXMenuPane::ID_LAST, 83 ID_LAST 84 }; 85 HistMenu(FXWindow *p, const FXString &caption, const FXString &groupname, FXObject *tgt, FXSelector sel); 86 ~HistMenu(); 87 virtual void create(); 88 void prepend(const FXString &txt); 89 void remove(const FXString &txt); 90 }; 91 92