tooltip.hh

来自「蒙特卡洛仿真源代码很有参考价值要按照步骤进行操作」· HH 代码 · 共 82 行

HH
82
字号
#ifndef TOOLTIP_HH#define TOOLTIP_HH  1#ifdef HAVE_CONFIG_H#include    "config.h"#endif /* HAVE_CONFIG_H */#include <string>#include <vector>#include <X11/Xlib.h>#include <pthread.h>#include <semaphore.h>#include <sys/time.h>#include <time.h>using namespace std;typedef enum direction_type { top_left = 0, top_right, bottom_left, bottom_right };typedef void *(*pfunc_t)(void *);const int no_delay = 0;// Forward declarationclass BToolTip;#ifdef DELAYED_TOOLTIPSvoid *waiter_thread_helper_function(void *waiter_object);class Waiter {    public:	Waiter();	~Waiter();		void waiter_loop(void);	void wait(const int _secs, void (BToolTip::*_func)(), BToolTip *_param);	void cancel(void);    private:	struct timeval wait_from;	int wait_secs;	bool fire, end;	void (BToolTip::*func)();	BToolTip *param;	pthread_t wait_thread;	sem_t run_waiter;};#endif /* DELAYED_TOOLTIPS */class BToolTip {    public:	BToolTip();	~BToolTip();	// Member functions	void createToolTipWindow(const int _x, const int _y, const unsigned int _w, const unsigned int _h);	void setText(const string &tooltip_text);	void setTimeout(const int seconds);	void setPosition(const int _x, const int _y, const direction_type _direction = bottom_right);	void redraw(const int _x, const int _y, const unsigned int _w, const unsigned int _h);	void processEvent(const XEvent &event);	void show(void);	void showNow(void);	void hide(void);	bool isShown(void) const;	int getTimeout(void) const;    private:	vector<string> current_tooltip_text;	int x, y, real_x, real_y, timeout;	unsigned int real_w, real_h;	bool is_visible, is_created;	direction_type direction;	Pixmap tooltip_pixmap;	Window tooltip_window;#ifdef DELAYED_TOOLTIPS	Waiter waiter;#endif /* DELAYED_TOOLTIPS */	pthread_mutex_t show_hide_syn;};#endif /* TOOLTIP_HH */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?