Ejemplo n.º 1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//controltype_button_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int controltype_button_message(control *c, int tokencount, char *tokens[])
{
	//Get the details
	controltype_button_details *details = (controltype_button_details *) c->controldetails;

	//If it's set control property
	if (tokencount == 6 && !stricmp(tokens[2], szBActionSetControlProperty))
	{
		//Only pressed, only for two state buttons
		if (details->is_twostate && !stricmp(tokens[4], "Pressed") && config_set_bool(tokens[5], &details->is_on))
		{
			style_draw_invalidate(c);
			return 0;
		}
		else if (!strcmp(tokens[4],"VAlign"))
		{
			int i;
			if (-1 != (i = get_string_index(tokens[5], button_valigns)))
			{
				details->valign = i;
				controltype_button_updatesettings(details);
				style_draw_invalidate(c);
				return 0;
			}
		}
		else if (!strcmp(tokens[4],"HAlign"))
		{
			int i;
			if (-1 != (i = get_string_index(tokens[5], button_haligns)))
			{
				details->halign = i;
				controltype_button_updatesettings(details);
				style_draw_invalidate(c);
				return 0;
			}
		}

		//Must be an error
		return 1;
	}

	//Must be an agent message?
	if (details->is_twostate)
		return agent_controlmessage(c, tokencount, tokens, CONTROLTYPE_TWOSTATEBUTTON_AGENTCOUNT, details->agents, controltype_switchbutton_agentnames, controltype_switchbutton_agenttypes);
	else
		return agent_controlmessage(c, tokencount, tokens, CONTROLTYPE_BUTTON_AGENTCOUNT, details->agents, controltype_button_agentnames, controltype_button_agenttypes);
}
Ejemplo n.º 2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//controltype_label_message
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int controltype_label_message(control *c, int tokencount, char *tokens[])
{
	// token strings

	enum
	{
		T_NONE          = 0,
		T_STYLE         ,
		T_VALIGN        ,
		T_HALIGN        ,
		T_HASTITLE      ,
		T_LOCKPOS       ,

		T_PLUGINLOAD    ,
		T_PLUGINUNLOAD  ,
		T_PLUGINSETPOS  ,
		T_PLUGINSHOW    ,

		T_PLUGINABOUT
	};

	extern char szWPStyle [];

	static struct token_check controltype_label_property_tokens[] =
	{
		{ szWPStyle,            T_STYLE         , 1 },
		{ "VAlign",             T_VALIGN        , 1 },
		{ "HAlign",             T_HALIGN        , 1 },
		{ "HasTitleBar",        T_HASTITLE      , 1 },
		{ "IsLocked",           T_LOCKPOS       , 1 },
		{ NULL }
	};

	static struct token_check controltype_label_plugin_property_tokens[] =
	{
		{ "IsVisible",          T_PLUGINSHOW    , 1 },
		{ "Position",           T_PLUGINSETPOS  , 2 },
		{ NULL }
	};

	static struct token_check controltype_label_plugin_tokens[] =
	{
		{ "Load",               T_PLUGINLOAD    , 1 },
		{ "Unload",             T_PLUGINUNLOAD  , 1 },
		{ "About",              T_PLUGINABOUT   , 0 },
		{ szBActionPluginSetProperty, (UINT_PTR)controltype_label_plugin_property_tokens  , 2 },
		{ NULL }
	};

	static struct token_check controltype_label_message_tokens[] =
	{
		{ szBActionSetControlProperty, (UINT_PTR)controltype_label_property_tokens, 2 },
		{ szBActionPlugin, (UINT_PTR)controltype_label_plugin_tokens, 2 },
		{ NULL }
	};

	// -----------------
	//Get the details
	controltype_label_details *details = (controltype_label_details *) c->controldetails;

	//If set control details
	int i;
	int curtok = 2;
	switch (token_check(controltype_label_message_tokens, &curtok, tokencount, tokens))
	{
		// -----------------
	case T_STYLE:
		if (-1 != (i = get_string_index(tokens[curtok], szStyleNames)))
		{
			c->windowptr->style = i;
			style_draw_invalidate(c);
			return 0;
		}
		break;

		// -----------------
	case T_HALIGN:
		if (-1 != (i = get_string_index(tokens[curtok], label_haligns)))
		{
			details->halign = i;
			controltype_label_updatesettings(details);
			style_draw_invalidate(c);
			return 0;
		}
		break;

		// -----------------
	case T_VALIGN:
		if (-1 != (i = get_string_index(tokens[curtok], label_valigns)))
		{
			details->valign = i;
			controltype_label_updatesettings(details);
			style_draw_invalidate(c);
			return 0;
		}
		break;

		// -----------------
	case T_HASTITLE:
		if (details->is_frame && config_set_bool(tokens[curtok], &details->has_titlebar))
		{
			style_draw_invalidate(c);
			return 0;
		}
		break;

		// -----------------
	case T_LOCKPOS:
		if (details->is_frame && config_set_bool(tokens[curtok], &details->is_locked))
			return 0;
		break;

		// -----------------
	case T_PLUGINLOAD:
		if (details->is_frame)
		{
			char *plugin_name = tokens[curtok];
			if (0 == strcmp(plugin_name, "*browse*"))
			{
				// "open file" dialog
				plugin_name = dialog_file("Plugins\0*.dll\0", "Add Plugin" , NULL, ".dll", false);
				if (NULL == plugin_name)
				{
					//message_override = true;
					return 2;
				}
			}
			ModuleInfo * m = loadPlugin(&details->module_info, c->windowptr->hwnd, plugin_name);
			if (m)
			{
				variables_set(false, "LastPlugin", m->module_name);
				return 0;
			}
		}
		break;

		// -----------------
	case T_PLUGINUNLOAD:
		if (unloadPlugin(&details->module_info, tokens[curtok]))
			return 0;
		break;

		// -----------------
	case T_PLUGINSETPOS:
	{
		int x, y;
		if (config_set_int(tokens[curtok], &x)
				&& config_set_int(tokens[1+curtok], &y)
				&& plugin_setpos(details->plugin_info, tokens[-2+curtok], x, y)
		   )
			return 0;

		return 0; // dont generate an error here...
	}
	break;

	// -----------------
	case T_PLUGINSHOW:
	{
		bool show;
		if (plugin_getset_show_state(details->plugin_info, tokens[-2+curtok],
									 config_set_bool(tokens[curtok], &show) ? show : 2)
		   )
			return 0;

		return 0; // dont generate an error here...
	}
	break;

	// -----------------
	case T_PLUGINABOUT:
	{
		aboutPlugins(details->module_info, c->controlname);
		return 0;
	}
	break;

	// -----------------
	//Must be an agent message
	default:
		return agent_controlmessage(c, tokencount, tokens, CONTROLTYPE_LABEL_AGENT_COUNT, details->agents, controltype_label_agentnames, controltype_label_agenttypes);
	}
	return 1;
}