Example #1
0
void SelectableControl::update(){
	for(unsigned i=0;i<selectables.size();i++){
		selectables.at(i)->clear_state();
	}
	find_selected();
	selectables.clear();
}
Example #2
0
char *wd_filemask(const char *mask)
{
	int button;
	int i;
	XDINFO info;
	boolean stop = FALSE, redraw, dc, ok;
	FTYPE *f;
	SNAME name, newmask;			/* HR 240203 */
	char *result;
	SLIDER sl;

	sl.type = 1;
	sl.up_arrow = FTUP;
	sl.down_arrow = FTDOWN;
	sl.slider = FTSLIDER;
	sl.sparent = FTSPAR;
	sl.lines = NLINES;
	sl.n = cnt_types();
	sl.line = 0;
	sl.set_selector = set_selector;
	sl.first = FTYPE1;
	sl.findsel = find_selected;

	/* DjV 004 290103 ---vvv--- */
	if ( mask == NULL )
	{
		setmask[FILETYPE].ob_state |= DISABLED;
		*setmask[FILETYPE].ob_spec.tedinfo->te_ptext = 0;
	}		
	else
	{
	/* DjV 004 290103 ---^^^--- */
		cv_fntoform(setmask + FILETYPE, mask);			/* HR 240103 */
		setmask[FILETYPE].ob_state &= ~DISABLED;	/* DjV 004 290103 */
	}												/* DjV 004 290103 */

	/* DjV 004 020103 Put file attributes buttons into right state */
	set_opt( setmask, options.attribs, FA_HIDDEN, MSKHID );
	set_opt( setmask, options.attribs, FA_SYSTEM, MSKSYS );
	set_opt( setmask, options.attribs, FA_SUBDIR, MSKDIR );
	set_opt( setmask, options.attribs, FA_PARDIR, MSKPAR );

	sl_init(setmask, &sl);

	xd_open(setmask, &info);

	while (stop == FALSE)
	{
		redraw = FALSE;

		button = sl_form_do(setmask, FILETYPE, &sl, &info);
		dc = (button & 0x8000) ? TRUE : FALSE;
		button &= 0x7FFF;

		if ((button < FTYPE1) || (button > FTYPE4))
		{
			switch (button)
			{
			case FTADD:
				name[0] = 0;

				if (filetype_dialog(name) == TRUE)
				{
					add(name);
					sl.n = cnt_types();
					redraw = TRUE;
					sl_set_slider(setmask, &sl, &info);
				}
				break;
			case FTDELETE:
				i = find_selected() + sl.line;
				if ((f = get_item(i)) != NULL)
				{
					rem(f);
					sl.n = cnt_types();
					redraw = TRUE;
					sl_set_slider(setmask, &sl, &info);
				}
				break;
			default:
				ok = (button == FTOK) ? TRUE : FALSE;
				stop = TRUE;
				break;
			}
			xd_change(&info, button, NORMAL, (stop == FALSE) ? 1 : 0);
		}
		else if ( button >= MSKHID && button <= MSKPAR )
		{
			/* DjV 004 020103 do nothing until exit */	
		}		
		else
		{
			strcpy(filetype, setmask[button].ob_spec.tedinfo->te_ptext);
			xd_draw(&info, FILETYPE, 1);
			if (dc == TRUE)
			{
				ok = TRUE;
				stop = TRUE;
			}
		}

		if (redraw == TRUE)
			set_selector(&sl, TRUE, &info);
	}

	xd_close(&info);

	if (ok == TRUE)
	{
		/* DjV 004 030103 ---vvv--- */
		get_opt( setmask, &options.attribs, FA_HIDDEN, MSKHID );
		get_opt( setmask, &options.attribs, FA_SYSTEM, MSKSYS );
		get_opt( setmask, &options.attribs, FA_SUBDIR, MSKDIR ); /* DjV 004 280103 wrongly was MSKHID */ 
		get_opt( setmask, &options.attribs, FA_PARDIR, MSKPAR );
		/* DjV 004 020103 ---^^^--- */

		if ( mask == NULL )		/* DjV 004 290103 */
			return NULL;		/* DjV 004 290103 */
		else					/* DjV 004 290103 */
		{						/* DjV 004 290103 */
			cv_formtofn(newmask, filetype);
			if ((result = malloc(strlen(newmask) + 1)) != NULL)
				strcpy(result, newmask);
			else
				xform_error(ENSMEM);
			return result;
		}						/* DjV 004 290103 */
	}
	else
		return NULL;
}