1 /*
2   FXiTe - The Free eXtensIble Text Editor
3   Copyright (c) 2010-2011 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 // Dialog box that implements an editable list of items and descriptions.
21 // Entries can be edited, re-ordered, reverted to previous state, or reverted
22 // to application defaults. Each subclass should provide its own definition
23 // of the Verify(), RestoreAppDefaults(), setText() and getText() methods.
24 class DescListDlg: public FXDialogBox {
25   FXDECLARE(DescListDlg)
26 protected:
27   int desc_max_len;
28   int item_max_len;
29   int items_max;
30   bool has_browse_btn;
DescListDlg()31   DescListDlg(){}
32   FXString before;
33   FXString after;
34   FXIconList*items;
35   FXButton*raise_btn;
36   FXButton*lower_btn;
37   FXButton*edit_btn;
38   FXButton*delete_btn;
39   FXButton*new_btn;
40   FXLabel* intro_label;
41   FXString item_comment;
42   void enableButtons();
setText(const FXString str)43   virtual void setText(const FXString str) {}
getText()44   virtual const FXString& getText() { return after; }
Verify(FXString & item)45   virtual bool Verify(FXString&item) { return true; }
RestoreAppDefaults()46   virtual void RestoreAppDefaults() {}
Browse(FXString & text)47   virtual bool Browse(FXString &text) { return false; }
48 public:
49   bool editItem(const FXString &desc, const FXString &item, bool focus_item=false);
50   long onCommand(FXObject* sender,FXSelector sel,void *ptr);
51   long onClose(FXObject* sender,FXSelector sel,void *ptr);
52   long onBrowse(FXObject* sender,FXSelector sel,void *ptr);
53   enum{
54     ID_LIST_SEL=FXDialogBox::ID_LAST,
55     ID_DEFAULTS_CMD,
56     ID_REVERT_CMD,
57     ID_RAISE_CMD,
58     ID_LOWER_CMD,
59     ID_EDIT_CMD,
60     ID_DELETE_CMD,
61     ID_NEW_CMD,
62     ID_BROWSE,
63     ID_LAST
64   };
65   // For max_desc_len, max_item_len, max_items: zero means unlimited.
66   // For max_desc_len: (-1) creates an item list only, no descriptions.
67   DescListDlg( FXWindow* w, const char*name, const char*hdr2,
68                const char*howto, const char*intro=NULL,
69                int max_desc_len=0, int max_item_len=0, int max_items=0, bool browse_btn=false);
70   virtual void create();
71 };
72 
73