コード例 #1
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//controltype_label_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void controltype_label_notify(control *c, int notifytype, void *messagedata)
{
	//Variables
	controltype_label_details *details;
	int i;

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

	//Find out what to do
	switch (notifytype)
	{
	case NOTIFY_NEEDUPDATE:
		//When we are told we need an update, figure out what to do
		//Update the caption first
		if (details->agents[CONTROLTYPE_LABEL_AGENT_CAPTION])
		{
			details->caption = (char *) agent_getdata(details->agents[CONTROLTYPE_LABEL_AGENT_CAPTION], DATAFETCH_VALUE_TEXT);
		}
		else
		{
			details->caption = NULL;
		}

		//Tell the label to draw itself again
		style_draw_invalidate(c);
		break;

	case NOTIFY_SAVE_CONTROL:
		//Save all local values
		config_write(config_get_control_setcontrolprop_c(c, "HAlign", label_haligns[details->halign]));
		config_write(config_get_control_setcontrolprop_c(c, "VAlign", label_valigns[details->valign]));
		if (details->is_frame)
		{
			config_write(config_get_control_setcontrolprop_b(c, "HasTitleBar", &details->has_titlebar));
			config_write(config_get_control_setcontrolprop_b(c, "IsLocked", &details->is_locked));
		}

		for (i = 0; i < CONTROLTYPE_LABEL_AGENT_COUNT; i++)
			agent_notify(details->agents[i], NOTIFY_SAVE_AGENT, NULL);

		if (details->is_frame)
			controltype_frame_saveplugins(c);
		break;

	case NOTIFY_DRAGACCEPT:
		DragAcceptFiles(c->windowptr->hwnd, NULL != details->agents[CONTROLTYPE_LABEL_AGENT_ONDROP]);
		break;
	}
}
コード例 #2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//controltype_button_notify
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void controltype_button_notify(control *c, int notifytype, void *messagedata)
{
	//Variables
	controltype_button_details *details;
	bool *newvalueptr;

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

	//Find out what to do
	switch (notifytype)
	{       
		case NOTIFY_NEEDUPDATE:
			//When we are told we need an update, figure out what to do
			//Update the caption first
			if (details->agents[CONTROLTYPE_BUTTON_CAPTION])
			{
				details->caption = (char *) agent_getdata(details->agents[CONTROLTYPE_BUTTON_CAPTION], DATAFETCH_VALUE_TEXT);
			}
			else
			{
				details->caption = NULL;
			}

			//Only two state buttons need updates at this point
			if (details->is_twostate)
			{
				//Get the value
				newvalueptr = (bool *)(agent_getdata(details->agents[CONTROLTYPE_TWOSTATEBUTTON_AGENT_VALUECHANGE], DATAFETCH_VALUE_BOOL));
				if (newvalueptr)
				{
					//Set the new value
					details->is_on = *newvalueptr;
				}
			}

			//Tell the button to draw itself again
			style_draw_invalidate(c);
			break;

		case NOTIFY_SAVE_CONTROL:
			//Save all local values
			config_write(config_get_control_setcontrolprop_c(c, "HAlign", button_haligns[details->halign]));
			config_write(config_get_control_setcontrolprop_c(c, "VAlign", button_valigns[details->valign]));
			int i;
			for (i = 0; i < CONTROLTYPE_BUTTON_AGENTCOUNT; i++)
				agent_notify(details->agents[i], NOTIFY_SAVE_AGENT, NULL);
			if (details->is_twostate)
				config_write(config_get_control_setcontrolprop_b(c, "Pressed", &details->is_on));
			break;

		case NOTIFY_DRAGACCEPT:
			DragAcceptFiles(c->windowptr->hwnd, NULL != details->agents[details->is_twostate ? CONTROLTYPE_TWOSTATEBUTTON_AGENT_ONDROP : CONTROLTYPE_BUTTON_AGENT_ONDROP]);
			break;

	}
}