Program Listing for File panel_interface.h
↰ Return to documentation for file (/tmp/ws/src/log_view/include/log_view/panel_interface.h
)
#ifndef LOG_VIEW_PANEL_INTERFACE_H_
#define LOG_VIEW_PANEL_INTERFACE_H_
#include <memory>
#include <string>
#include <curses.h>
#include <panel.h>
#define KEY_ENTER_VAL 10
namespace log_view {
class PanelInterface {
public:
PanelInterface(int height, int width, int y, int x);
virtual ~PanelInterface();
virtual void refresh() = 0;
virtual void forceRefresh();
virtual void resize(int height, int width, int y, int x);
virtual bool handleInput(int key);
virtual bool handleNavigation(int key);
virtual bool handleMouse(const MEVENT& event) { return false; }
virtual bool handleKey(int key) { return false; }
virtual bool encloses(int y, int x);
virtual void hide(bool enable);
virtual bool setFocus(bool enable);
virtual void toTop();
virtual bool setCursor();
virtual int x() const;
virtual int y() const;
virtual int width() const;
virtual int height() const;
virtual bool hidden() const;
virtual bool visible() const;
virtual bool focus() const;
virtual bool scrollbar() const;
protected:
virtual bool canFocus() const { return false; }
virtual void drawScrollBar(size_t count, int height, int y, int x);
// text input
virtual bool canInput() const { return false; }
virtual void activate(bool enable) {}
virtual int inputOffset() const { return 0; }
// navigation
virtual bool canNavigate() const { return false; }
virtual bool canSelect() const { return false; }
virtual size_t getContentSize() const { return 0; }
virtual int getContentHeight() const { return height_; }
virtual int getContentWidth() const { return width_; }
virtual void setCursor(int64_t cursor) {}
virtual int64_t getCursor() const { return 0; }
virtual void follow(bool enable);
virtual void pageUp();
virtual void pageDown();
virtual void move(int step);
virtual void moveTo(size_t index);
virtual void shift(int cols);
virtual void select() {};
virtual bool following() { return getCursor() < 0; }
WINDOW* window_ = nullptr;
PANEL* panel_ = nullptr;
int x_;
int y_;
int width_;
int height_;
bool cleared_ = false;
bool hidden_ = false;
// text input
bool focus_ = false;
std::string input_text_;
int input_loc_ = -1;
// navigation
bool follow_ = true;
size_t last_content_size_ = 0;
int64_t last_cursor_ = 0;
size_t max_length_ = 0;
int shift_ = 0;
};
typedef std::shared_ptr<PanelInterface> PanelInterfacePtr;
} // namespace log_view
#endif // LOG_VIEW_PANEL_INTERFACE_H_