CARDS 2.3.99
Package manager for the NuTyX GNU/Linux distribution
tableau.h
1 /*
2  * tableau.h
3  *
4  * Copyright 2015-2017 Thierry Nuttens <tnut@nutyx.org>
5  * Copyright 2017 Gianni Peschiutta <artemia@nutyx.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20  * MA 02110-1301, USA.
21  *
22  *
23  */
24 
25 #ifndef TABLEAU_H
26 #define TABLEAU_H
27 
28 #include <stdio.h>
29 #include <string.h>
30 #include <vector>
31 #include <algorithm>
32 
33 #include <ctype.h>
34 
35 #include <FL/Fl.H>
36 #include <FL/fl_ask.H>
37 #include <FL/Fl_Double_Window.H>
38 #include <FL/fl_draw.H>
39 #include <FL/Fl_Table_Row.H>
40 #include <FL/Fl_Menu.H>
41 #include "cards_wrapper.h"
42 #include "pixmaps/checked.xpm"
43 
44 #define MARGIN 20
45 #define COLHEADER { "Inst","Collection", "Name", "Description", "Version", "", "", "", ""}
46 
47 using namespace std;
48 
49 // A single row of columns
50 class Row
51 {
52 public:
53  vector<string> cols;
54  bool installed;
55 };
56 
57 // Class for handling the sorting column using std::sort
59 {
60 private:
61  int _col, _reverse;
62 
63 public:
64  SortColumn (int col, int reverse);
65  bool operator() (const Row &a, const Row &b);
66 };
67 
74 class Tableau : public Fl_Table_Row, public Cards_event_handler
75 {
76 public:
83  Tableau(int x, int y, int w, int h, const char *l=0);
84 
92 
99  void refresh_table(); // Load the packages list
100  void autowidth(int pad); // Automatically set the columns widths to the longuest string
101  void resize_window(); // Resize the parent window to size of table
102  void setFilter(const string& pValue);
103 
104 protected:
105  // table cell drawing
106  void draw_cell(TableContext context, int R=0, int C=0, int X=0, int Y=0, int W=0, int H=0);
107  // sort the table by a column
108  void sort_column(int col, int reverse=0);
109  void draw_sort_arrow(int X, int Y, int W, int H);
110  void OnDoJobListFinished (const CEH_RC rc);
111  void OnRefreshPackageFinished (const CEH_RC rc);
112 private:
113  string _filter;
114  vector<Row> _rowdata;
115  int _sort_reverse;
116  int _sort_lastcol;
117  Cards_wrapper* _cards;
118 static void event_callback(Fl_Widget*,void*);
119 static void ContextMenu_Callback(Fl_Widget*,void*);
120  void event_callback2();
121 };
122 
123 #endif
GUI interfacing wrapper for CARDS.
Definition: cards_wrapper.h:47
widget to manage cards package list
Definition: tableau.h:74
Definition: tableau.h:50
Abstract class to handle event from cards_wrapper.
Definition: cards_event_handler.h:51
~Tableau()
Destructor.
Definition: tableau.h:91
Definition: tableau.h:58