⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 animated_icon.cpp

📁 Siemens 的SIMpad是一个多媒体设备
💻 CPP
字号:
#include <FL/Fl.H>#include <stdio.h>#include "Animated_Icon.h"#define TRUE 1#define FALSE 0Animated_Icon::Animated_Icon(int x, int y, int w, int h, const char *l = 0) :	Fl_Box(x, y, w, h, l){	first = current = 0;	running_ = 0;	run_once = FALSE;}//-----------------------------------------------------------------------------Animated_Icon::~Animated_Icon(){	icon_list *l, *n;	stop();	l = first;	while (l) {		n = l->next;		delete l->icon;		delete l;		l = n;	}}//-----------------------------------------------------------------------------void Animated_Icon::add(Fl_Pixmap *pm, float d){	icon_list *l = new icon_list;	l->icon = pm;	l->delay = d;	l->next = 0;		if (first == 0) 	{	   first = current = l;	} else 	{	   l->next = current->next;	   current->next = l;	   current = l;	}}//-----------------------------------------------------------------------------void Animated_Icon::icon_cb(Animated_Icon *a){	icon_list *current = a->current;	if (current->next == 0) 	{	   if(a->run_once == TRUE)	     a->stop();	   else	     current = a->first;	} else 	{	   current = current->next;	}	a->current = current;	current->icon->label(a);	a->redraw();	Fl::add_timeout(current->delay,		(void (*)(void *))Animated_Icon::icon_cb, (void *)a);}//-----------------------------------------------------------------------------void Animated_Icon::start(){	if (current == 0) {		return;	}	current->icon->label(this);	redraw();	Fl::add_timeout(current->delay,		(void (*)(void *))icon_cb, (void *)this);	running_ = 1;}//-----------------------------------------------------------------------------void Animated_Icon::stop(){	Fl::remove_timeout((void (*)(void *))icon_cb, (void *)this);	running_ = 0;}//-----------------------------------------------------------------------------void Animated_Icon::set(int n){	icon_list *l = first;	if (n < 0 || l == 0) return;	while (n--) {		l = l->next;		if (l == 0) return;	}	l->icon->label(this);	current = l;}//-----------------------------------------------------------------------------

⌨️ 快捷键说明

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