1 /******************************************************************************* 2 * Goggles Music Manager * 3 ******************************************************************************** 4 * Copyright (C) 2006-2021 by Sander Jansen. All Rights Reserved * 5 * --- * 6 * This program is free software: you can redistribute it and/or modify * 7 * it under the terms of the GNU General Public License as published by * 8 * the Free Software Foundation, either version 3 of the License, or * 9 * (at your option) any later version. * 10 * * 11 * This program is distributed in the hope that it will be useful, * 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 * GNU General Public License for more details. * 15 * * 16 * You should have received a copy of the GNU General Public License * 17 * along with this program. If not, see http://www.gnu.org/licenses. * 18 ********************************************************************************/ 19 #ifndef GMLIST_H 20 #define GMLIST_H 21 22 extern FXint genre_list_sort(const FXListItem* pa,const FXListItem* pb); 23 extern FXint genre_list_sort_reverse(const FXListItem* pa,const FXListItem* pb); 24 25 extern FXint generic_name_sort(const FXListItem* pa,const FXListItem* pb); 26 extern FXint generic_name_sort_reverse(const FXListItem* pa,const FXListItem* pb); 27 28 extern FXint source_list_sort(const FXTreeItem* pa,const FXTreeItem* pb); 29 extern FXint source_list_sort_reverse(const FXTreeItem* pa,const FXTreeItem* pb); 30 31 class GMList; 32 33 class GMListItem : public FXListItem { 34 FXDECLARE(GMListItem) 35 friend class GMList; 36 private: 37 GMListItem(const GMListItem&); 38 GMListItem& operator=(const GMListItem&); 39 protected: GMListItem()40 GMListItem() {} 41 42 // unhide to keep compiler happy over hiding virtual 43 using FXListItem::draw; 44 45 virtual void draw(const GMList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 46 public: 47 /// Construct new item with given text, icon, and user-data FXListItem(text,ic,ptr)48 GMListItem(const FXString& text,FXIcon* ic=nullptr,void* ptr=nullptr): FXListItem(text,ic,ptr) { } 49 }; 50 51 52 53 class GMList : public FXList { 54 FXDECLARE(GMList) 55 protected: 56 FXFont * thickfont = nullptr; 57 FXColor rowcolor = 0; 58 protected: GMList()59 GMList(){} 60 void recompute(); 61 virtual FXListItem *createItem(const FXString& text,FXIcon* icon,void* ptr); 62 private: 63 GMList(const GMList&); 64 GMList &operator=(const GMList&); 65 public: 66 long onPaint(FXObject*,FXSelector,void*); 67 public: 68 /// Construct a list with initially no items in it 69 GMList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=LIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 70 getRowColor()71 FXColor getRowColor() const { return rowcolor; } 72 setRowColor(FXColor c)73 void setRowColor(FXColor c) { rowcolor=c; update(); } 74 setThickFont(FXFont * f)75 void setThickFont(FXFont * f) { thickfont=f;} 76 77 virtual ~GMList(); 78 }; 79 80 /// Tree list Item 81 class GMTreeItem : public FXTreeItem { 82 FXDECLARE(GMTreeItem) 83 friend class GMTreeList; 84 protected: 85 GMTreeItem(); 86 private: 87 GMTreeItem(const GMTreeItem&); 88 GMTreeItem& operator=(const GMTreeItem&); 89 protected: 90 virtual void draw(const FXTreeList* list,FXDC& dc,FXint x,FXint y,FXint w,FXint h) const; 91 public: 92 /// Constructor FXTreeItem(text,oi,ci,ptr)93 GMTreeItem(const FXString& text,FXIcon* oi=nullptr,FXIcon* ci=nullptr,void* ptr=nullptr): FXTreeItem(text,oi,ci,ptr){} 94 95 /// Return height of item as drawn in list 96 virtual FXint getHeight(const FXTreeList* list) const; 97 }; 98 99 class GMTreeList : public FXTreeList { 100 FXDECLARE(GMTreeList) 101 protected: 102 FXColor rowcolor = 0; 103 protected: GMTreeList()104 GMTreeList() {} 105 virtual FXTreeItem* createItem(const FXString& text,FXIcon* oi,FXIcon* ci,void* ptr); 106 private: 107 GMTreeList(const GMTreeList&); 108 GMTreeList& operator=(const GMTreeList&); 109 public: 110 long onPaint(FXObject*,FXSelector,void*); 111 public: 112 /// Construct a new, initially empty tree list 113 GMTreeList(FXComposite *p,FXObject* tgt=nullptr,FXSelector sel=0,FXuint opts=TREELIST_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0); 114 setRowColor(FXColor c)115 void setRowColor(FXColor c) { rowcolor=c; update(); } 116 }; 117 #endif 118