2018-10-05 01:48:59 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Conky, a system monitor, based on torsmo
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
2018-10-18 22:51:08 +00:00
|
|
|
* Copyright (C) 2018 François Revol et al.
|
2018-10-05 01:48:59 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DISPLAY_OUTPUT_HH
|
|
|
|
#define DISPLAY_OUTPUT_HH
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <string>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
#include "luamm.hh"
|
|
|
|
|
|
|
|
namespace conky {
|
|
|
|
|
|
|
|
bool initialize_display_outputs();
|
|
|
|
|
|
|
|
bool shutdown_display_outputs();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A base class for all display outputs.
|
|
|
|
* API consists of two functions:
|
|
|
|
* - get_number should return numeric representation of the data (if available).
|
|
|
|
* This can then be used when drawing graphs, bars, ... The default
|
|
|
|
* implementation returns NaN.
|
|
|
|
* - get_text should return textual representation of the data. This is used
|
|
|
|
* when simple displaying the value of the data source. The default
|
|
|
|
* implementation converts get_number() to a string, but you can override to
|
|
|
|
* return anything (e.g. add units)
|
|
|
|
*/
|
|
|
|
class display_output_base {
|
|
|
|
private:
|
|
|
|
// copying is a REALLY bad idea
|
|
|
|
display_output_base(const display_output_base &) = delete;
|
|
|
|
display_output_base &operator=(const display_output_base &) = delete;
|
|
|
|
|
|
|
|
public:
|
|
|
|
const std::string name;
|
|
|
|
bool is_active;
|
2018-10-05 03:51:56 +00:00
|
|
|
bool is_graphical;
|
2018-10-05 01:48:59 +00:00
|
|
|
int priority;
|
|
|
|
|
|
|
|
explicit display_output_base(const std::string &name_);
|
|
|
|
|
|
|
|
virtual ~display_output_base() {}
|
|
|
|
|
|
|
|
static bool priority_compare(const display_output_base *a,
|
|
|
|
const display_output_base *b) {
|
|
|
|
return a->priority > b->priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if available and enabled in settings
|
|
|
|
virtual bool detect() { return false; };
|
|
|
|
// connect to DISPLAY and other stuff
|
|
|
|
virtual bool initialize() { return false; };
|
|
|
|
virtual bool shutdown() { return false; };
|
|
|
|
|
2018-10-05 02:47:27 +00:00
|
|
|
// drawing primitives
|
2018-10-05 03:46:50 +00:00
|
|
|
virtual bool set_foreground_color(long c) { return false; }
|
|
|
|
|
2018-10-05 02:47:27 +00:00
|
|
|
virtual bool begin_draw_text() { return false; };
|
|
|
|
virtual bool end_draw_text() { return false; };
|
|
|
|
virtual bool draw_string(const char *s, int w) { return false; };
|
2018-10-05 03:46:50 +00:00
|
|
|
virtual void line_inner_done() {}
|
|
|
|
|
|
|
|
virtual int getx() { return 0; };
|
|
|
|
virtual int gety() { return 0; };
|
|
|
|
virtual bool gotox(int x) { return false; };
|
|
|
|
virtual bool gotoy(int y) { return false; };
|
|
|
|
virtual bool gotoxy(int x, int y) { return false; };
|
|
|
|
|
|
|
|
virtual bool flush() { return false; };
|
2018-10-05 02:47:27 +00:00
|
|
|
|
2018-10-05 01:48:59 +00:00
|
|
|
friend bool conky::initialize_display_outputs();
|
|
|
|
friend bool conky::shutdown_display_outputs();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool active() { return is_active; };
|
2018-10-05 03:51:56 +00:00
|
|
|
virtual bool graphical() { return is_graphical; };
|
2018-10-05 01:48:59 +00:00
|
|
|
};
|
|
|
|
|
2018-10-05 02:47:27 +00:00
|
|
|
/*
|
2018-10-05 03:08:34 +00:00
|
|
|
* The selected and active display outputs.
|
2018-10-05 02:47:27 +00:00
|
|
|
*/
|
2018-10-05 03:08:34 +00:00
|
|
|
extern std::vector<display_output_base *> active_display_outputs;
|
2018-10-05 02:47:27 +00:00
|
|
|
|
2018-10-05 01:48:59 +00:00
|
|
|
/*
|
|
|
|
* Use this to declare a display output that has been disabled during
|
|
|
|
* compilation. We can then print a nice error message telling the used which
|
|
|
|
* setting to enable.
|
|
|
|
*/
|
|
|
|
class disabled_display_output : public display_output_base {
|
|
|
|
public:
|
|
|
|
const std::string define;
|
|
|
|
disabled_display_output(const std::string &name, const std::string &define);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace conky
|
|
|
|
|
|
|
|
#endif /* DISPLAY_OUTPUT_HH */
|