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

📄 main_tree.cpp

📁 用linux开发的安防暴警的有关代码
💻 CPP
字号:
#include "main_tree.h"//===============================================================================// FUNCTION		update_main_tree// SYNOPSIS		Creates the folderlist Fl_Toggle_Tree data from the currently//				available mailboxes and their views.//// ARGUMENTS	scr		(Fl_Scroll *)	Group the tree should be a part of.//// RETURNS		function returns no data//===============================================================================void update_main_tree (Fl_Scroll *scr){	if (!scr->window()->shown()) return;	int i;	int x,y;	char buf[512];	fl_mapcolor (FL_FREE_COL5,245,233,217 );	i = scr->children()-1;	while (i>=2)	{		scr->remove(scr->child(i-2));		i--;	}	y = scr->y()+5;	x = 0;	scr->begin();	main_tree = new Fl_Toggle_Tree (scr->x()+1, scr->y()+2, scr->w() - 4, 10);	main_tree->column_widths(wmain);	main_tree->textsize (16);	main_tree->selection_color (FL_FREE_COL5);	main_tree->selection_label_color (FL_BLACK);	main_tree->color(FL_FREE_COL5);	main_tree->label_offset(45);	main_tree->pixmap_offset(10);	main_tree->edit_on_reselect (0);	main_tree->column_char('\t');	scr->resizable (main_tree);	alert_device_t	*temp_device;	Fl_Toggle_Node *nod;	for (int i=1;i<3;i++)	for (temp_device=PROFILES.dev_head;temp_device;temp_device=temp_device->next)	{		if (temp_device->device_type==i)		{		if (temp_device->device_module==ALERT_ALWAYS)		{			if (temp_device->device_enable==DEVICE_ENABLE)			{				sprintf (buf, "%s\t%s\t%s\t%s\t%s",  temp_device->device_name,ALERT_TYPE[temp_device->alert_type],DEVICE_TYPE[temp_device->device_type],temp_device->device_position,DEVICE_MODULE[temp_device->device_module]);				nod =main_tree->add_next (buf, 0, Blue_Light,(void *)temp_device);			}			else			{				sprintf (buf, "%s\t%s\t%s\t%s\t%s",  temp_device->device_name,ALERT_TYPE[temp_device->alert_type],DEVICE_TYPE[temp_device->device_type],temp_device->device_position,DEVICE_MODULE[temp_device->device_module]);				nod =main_tree->add_next (buf, 0,0,(void *)temp_device);			}		}		else if (temp_device->device_module==ALERT_INNER)		{			if ((PROFILES.alert_defence_stat==DEFENCE_OUT)&&(temp_device->device_enable==DEVICE_ENABLE))			{				sprintf (buf, "%s\t%s\t%s\t%s\t%s",  temp_device->device_name,ALERT_TYPE[temp_device->alert_type],DEVICE_TYPE[temp_device->device_type],temp_device->device_position,DEVICE_MODULE[temp_device->device_module]);				nod =main_tree->add_next (buf, 0, Yellow_Light,(void *)temp_device);			}			else			{				sprintf (buf, "%s\t%s\t%s\t%s\t%s",  temp_device->device_name,ALERT_TYPE[temp_device->alert_type],DEVICE_TYPE[temp_device->device_type],temp_device->device_position,DEVICE_MODULE[temp_device->device_module]);				nod =main_tree->add_next (buf, 0, 0,(void *)temp_device);			}		}		else	if (temp_device->device_module==ALERT_OUT)		{			if ((PROFILES.alert_defence_stat==DEFENCE_OFF)||(temp_device->device_enable==DEVICE_DISENABLE))			{				sprintf (buf, "%s\t%s\t%s\t%s\t%s",  temp_device->device_name,ALERT_TYPE[temp_device->alert_type],DEVICE_TYPE[temp_device->device_type],temp_device->device_position,DEVICE_MODULE[temp_device->device_module]);				nod =main_tree->add_next (buf, 0, 0,(void *)temp_device);			}			else			{				sprintf (buf, "%s\t%s\t%s\t%s\t%s",  temp_device->device_name,ALERT_TYPE[temp_device->alert_type],DEVICE_TYPE[temp_device->device_type],temp_device->device_position,DEVICE_MODULE[temp_device->device_module]);				nod =main_tree->add_next (buf, 0, Red_Light,(void *)temp_device);			}			}		++x;		}	}	main_tree->callback ((Fl_Callback *) cb_main_tree);	main_tree->update_height();	main_tree->alternate_color(main_tree->color());	main_tree->trim_color (main_tree->color());//	main_tree->alternate_color(FL_LIGHT2);//	main_tree->trim_color(FL_LIGHT1);//	main_tree->sort_tree(Fl_Toggle_Tree::sort_by_label);	scr->end();	scr->redraw();	Fl::flush();}//===============================================================================// CALLBACK		cb_selectfolder// SENDER		folderlist tree// SYNOPSIS		Makes a new folder/view the current one, redraws the indexview.//===============================================================================//==============================// FL_TOGGLE_NONE = 0// FL_TOGGLE_SELECT = 1// FL_TOGGLE_RESELECT = 2// FL_TOGGLE_SELECT_MASK = 3// FL_TOGGLE_OPENED = 4// FL_TOGGLE_CLOSED = 8// FL_TOGGLE_HIT = 16//==============================void cb_main_tree (Fl_Widget *b, void *v){	if (PROFILES.current_user_class==0) return ;	Fl_Toggle_Node *X = (Fl_Toggle_Node *) main_tree->selected();	if (X!=NULL&&X->user_data() != NULL)	{		PROFILES.dev_current=(alert_device_t*)X->user_data();		init_user_setup();	}}void main_tree_clear (alert_device_t *M){	int depth = 0;	Fl_Toggle_Node *X = (Fl_Toggle_Node *) main_tree->traverse_start();	while (X)	{		if (X->user_data() != NULL)		{			alert_device_t *temp_device = (alert_device_t *) X->user_data();			if (temp_device == M)			{				((Fl_Widget*)X)->color(FL_BLACK);			}		}		X = main_tree->traverse_forward (0, depth);	}	main_tree->redraw();}

⌨️ 快捷键说明

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