Exemplo n.º 1
0
void
ttoggle_panel::signal_handler_pre_left_button_click(const event::tevent event)
{
	DBG_GUI_E << get_control_type() << "[" << id() << "]: " << event << ".\n";

	set_value(1);

#if 0
	/*
	 * Disabled since it causes issues with gamestate inspector (bug #22095).
	 * It was added in b84f2ebff0b53c7e4194da315c43f62a08494c52 for the lobby,
	 * since that code is still experimental, prefer to fix a real issue caused
	 * by it.
	 *
	 * The issue is that the gui2::tlistbox::add_row code was changed to
	 * increase the content size. Before the list was shown the list was
	 * cleared. The clear operation did not reduce the size (since the widgets
	 * were not shown yet). The add operation afterwards again reserved the
	 * space causing the size of the listbox to be twice the required space.
	 *
	 * 2014.06.09 -- Mordante
	 */
	if(callback_state_change_) {
		callback_state_change_(*this);
	}
#endif
}
Exemplo n.º 2
0
tmatrix::tmatrix(const implementation::tbuilder_matrix& builder)
	: tbase(builder, get_control_type())
	, content_()
	, pane_(NULL)
{
	boost::intrusive_ptr<const tmatrix_definition::tresolution> cfg =
			boost::dynamic_pointer_cast<
				const tmatrix_definition::tresolution>(config());

	tbuilder_widget::treplacements replacements;
	replacements.insert(std::make_pair("_main", builder.builder_main));

	if(builder.builder_top) {
		replacements.insert(std::make_pair("_top", builder.builder_top));
	}

	if(builder.builder_left) {
		replacements.insert(std::make_pair("_left", builder.builder_left));
	}

	if(builder.builder_right) {
		replacements.insert(std::make_pair("_right", builder.builder_right));
	}

	if(builder.builder_bottom) {
		replacements.insert(std::make_pair("_bottom", builder.builder_bottom));
	}

	cfg->content->build(content_, replacements);
	content_.set_parent(this);

	pane_ = find_widget<tpane>(&content_, "pane", false, true);
}
Exemplo n.º 3
0
void tcontrol::layout_wrap(const unsigned maximum_width)
{
	// Inherited.
	twidget::layout_wrap(maximum_width);

	assert(config_);

	if(label_.empty()) {
		// FIXME see what to do on an empty label later.
		return;
	} else {

		tpoint size = get_best_text_size(
				tpoint(0,0),
				tpoint(maximum_width - config_->text_extra_width, 0));

		size.x += config_->text_extra_width;
		size.y += config_->text_extra_height;

		set_layout_size(size);

		DBG_G_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":"
				<< " maximum_width " << maximum_width
				<< " result " << size
				<< ".\n";

	}
}
Exemplo n.º 4
0
static void
print_control (CControl *control)
{
	if(HAS_VERBOSE()) {
		char *flags = get_control_flags(control->flags);

		printf("  %s\n    ID      : 0x%08x,\n    Type    : %s,\n    Flags   : { %s },\n", control->name,
				control->id, get_control_type(control->type), flags);

		if(control->type == CC_TYPE_CHOICE) {
			char *choices = get_control_choices(control);
			printf("    Values  : { %s },\n    Default : %d\n", choices, control->def.value);
			free(choices);
		}
		else {
			printf("    Values  : [ %d .. %d, step size: %d ],\n    Default : %d\n",
					control->min.value, control->max.value, control->step.value,
					control->def.value);
		}

		free(flags);
	}
	else {
		printf("  %s\n", control->name);
	}

}
Exemplo n.º 5
0
void tcontrol::load_config()
{
	if(!config()) {

		definition_load_configuration(get_control_type());

		load_config_extra();
	}
}
Exemplo n.º 6
0
void styled_widget::load_config()
{
	if(!config()) {

		definition_load_configuration(get_control_type());

		load_config_extra();
	}
}
Exemplo n.º 7
0
tpoint tcontrol::get_config_minimum_size() const
{
	assert(config_);

	tpoint result(config_->min_width, config_->min_height);

	DBG_G_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":"
		<< " result " << result
		<< ".\n";
	return result;
}
Exemplo n.º 8
0
void ttext_box::signal_handler_mouse_motion(const event::tevent event,
											bool& handled,
											const tpoint& coordinate)
{
	DBG_GUI_E << get_control_type() << "[" << id() << "]: " << event << ".\n";

	if(dragging_) {
		handle_mouse_selection(coordinate, false);
	}

	handled = true;
}
Exemplo n.º 9
0
void tcontrol::layout_shrink_width(const unsigned maximum_width)
{
	DBG_G_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":"
			<< " maximum_width " << maximum_width
			<< ".\n";

	/** @todo handle the tooltip properly. */

	shrunken_ = true;
	set_layout_size(tpoint(maximum_width, get_best_size().y));

	assert(static_cast<unsigned>(get_best_size().x) == maximum_width);
}
Exemplo n.º 10
0
listbox::listbox(const implementation::builder_styled_widget& builder,
		const generator_base::placement placement,
		builder_grid_ptr list_builder,
		const bool has_minimum,
		const bool has_maximum,
		const bool select)
	: scrollbar_container(builder, get_control_type())
	, generator_(generator_base::build(has_minimum, has_maximum, placement, select))
	, is_horizontal_(placement == generator_base::horizontal_list)
	, list_builder_(list_builder)
	, need_layout_(false)
	, orders_()
{
}
Exemplo n.º 11
0
void tcontrol::layout_fit_width(const unsigned maximum_width,
		const tfit_flags flags)
{
	assert(get_visible() != twidget::INVISIBLE);

	log_scope2(gui_layout,
			"tcontrol(" + get_control_type() + ") " + __func__);
	DBG_G_L << "maximum_width " << maximum_width
			<< " flags " << flags
			<< ".\n";

	// Already fits.
	if(get_best_size().x <= static_cast<int>(maximum_width)) {
		DBG_G_L << "Already fits.\n";
		return;
	}

	// Wrap.
	if((flags & twidget::WRAP) && can_wrap()) {
		layout_wrap(maximum_width);

		if(get_best_size().x <= static_cast<int>(maximum_width)) {
			DBG_G_L << "Success: Wrapped.\n";
			return;
		}
	}

	// Horizontal scrollbar.
	if((flags & twidget::SCROLLBAR) && has_horizontal_scrollbar()) {
		layout_use_horizontal_scrollbar(maximum_width);

		if(get_best_size().x <= static_cast<int>(maximum_width)) {
			DBG_G_L << "Success: Horizontal scrollbar.\n";
			return;
		}
	}

	// Shrink.
	if((flags & twidget::SHRINK) && can_shrink_width()) {
		layout_shrink_width(maximum_width);
		DBG_G_L << "Success: Shrunken.\n";
	}

	DBG_G_L << "Failed.\n";
}
Exemplo n.º 12
0
tpoint tcontrol::calculate_best_size() const
{
	assert(config_);
	tpoint result(config_->default_width, config_->default_height);
	if(! label_.empty()) {
		// If no label text set we use the predefined value.

		/**
		 * @todo The value send should subtract the border size
		 * and readd it after calculation to get the proper result.
		 */
		result = get_best_text_size(result);
	}

	DBG_G_L << "tcontrol(" + get_control_type() + ") " + __func__ + ":"
		<< " empty label " << label_.empty()
		<< " result " << result
		<< ".\n";
	return result;
}
Exemplo n.º 13
0
static BOOL is_control_displayonly(HWND control)
{
	BOOL displayonly = 0;
	switch(get_control_type(control))
	{
		case CT_STATIC:
			displayonly = TRUE;
			break;

		case CT_EDIT:
			displayonly = (GetWindowLong(control, GWL_STYLE) & ES_READONLY) ? TRUE : FALSE;
			break;

		default:
			displayonly = FALSE;
			break;
	}

	if (!IsWindowEnabled(control))
		displayonly = TRUE;
	return displayonly;
}
Exemplo n.º 14
0
//	---------------------------------------------------------------------------------------------------
void info_display_object_placement(int show_all)
{
	static	int	old_Cur_object_index;
	static	int	old_type;
	static	int	old_movement_type;
	static	int	old_control_type;
	static	int	old_mode;

	char		name[30];

	if (init_info | show_all) {
		old_Cur_object_index = -2;
		old_type = -2;
		old_movement_type = -2;
		old_control_type = -2;
		old_mode = -2;
	}

	if ( ( Cur_object_index != old_Cur_object_index) || 
			( Objects[Cur_object_index].type != old_type) || 
			( Objects[Cur_object_index].movement_type != old_movement_type) || 
			( Objects[Cur_object_index].control_type != old_control_type) || 
			( Objects[Cur_object_index].ctype.ai_info.behavior != old_mode) ) {

		gr_uprintf( 0, 0, "Object id: %4d\n", Cur_object_index);
		gr_uprintf( 0, 16, "Type: %s\n", get_object_type(Objects[Cur_object_index].type , name));
		gr_uprintf( 0, 32, "Movmnt: %s\n", get_movement_type(Objects[Cur_object_index].movement_type, name));
		gr_uprintf( 0, 48, "Cntrl: %s\n", get_control_type(Objects[Cur_object_index].control_type, name));
		gr_uprintf( 0, 64, "Mode: %s\n", get_ai_behavior(Objects[Cur_object_index].ctype.ai_info.behavior, name));

		old_Cur_object_index = Cur_object_index;
		old_type = Objects[Cur_object_index].type;
		old_movement_type = Objects[Cur_object_index].movement_type;
		old_mode = Objects[Cur_object_index].control_type;
		old_mode = Objects[Cur_object_index].ctype.ai_info.behavior;
	}

}
Exemplo n.º 15
0
menu_button::menu_button(const implementation::builder_menu_button& builder)
	: styled_widget(builder, get_control_type())
	, selectable_item()
	, state_(ENABLED)
	, retval_(0)
	, values_()
	, selected_()
	, keep_open_(false)
{
	values_.emplace_back(::config {"label", this->get_label()});

	connect_signal<event::MOUSE_ENTER>(
			std::bind(&menu_button::signal_handler_mouse_enter, this, _2, _3));
	connect_signal<event::MOUSE_LEAVE>(
			std::bind(&menu_button::signal_handler_mouse_leave, this, _2, _3));

	connect_signal<event::LEFT_BUTTON_DOWN>(std::bind(
			&menu_button::signal_handler_left_button_down, this, _2, _3));
	connect_signal<event::LEFT_BUTTON_UP>(
			std::bind(&menu_button::signal_handler_left_button_up, this, _2, _3));
	connect_signal<event::LEFT_BUTTON_CLICK>(std::bind(
			&menu_button::signal_handler_left_button_click, this, _2, _3));
}
Exemplo n.º 16
0
multimenu_button::multimenu_button(const implementation::builder_multimenu_button& builder)
	: styled_widget(builder, get_control_type())
	, state_(ENABLED)
	, retval_(0)
	, max_shown_(1)
	, values_()
	, toggle_states_()
	, droplist_(nullptr)
{
	values_.emplace_back(::config {"label", this->get_label()});

	connect_signal<event::MOUSE_ENTER>(
			std::bind(&multimenu_button::signal_handler_mouse_enter, this, _2, _3));
	connect_signal<event::MOUSE_LEAVE>(
			std::bind(&multimenu_button::signal_handler_mouse_leave, this, _2, _3));

	connect_signal<event::LEFT_BUTTON_DOWN>(std::bind(
			&multimenu_button::signal_handler_left_button_down, this, _2, _3));
	connect_signal<event::LEFT_BUTTON_UP>(
			std::bind(&multimenu_button::signal_handler_left_button_up, this, _2, _3));
	connect_signal<event::LEFT_BUTTON_CLICK>(std::bind(
			&multimenu_button::signal_handler_left_button_click, this, _2, _3));
}
Exemplo n.º 17
0
void tcontrol::set_block_easy_close(const bool block)
{
	twindow* window = get_window();
	if(!window) {
		/*
		 * This can happen in a listbox when the row data is manipulated before
		 * the listbox is finalized. In that case that widget should do set the
		 * state in its finalizer.
		 */
		DBG_GUI << "tcontrol(" + get_control_type() + ") " + __func__ + ": "
			"No window set, this might be a bug.\n";
		return;
	}

	if(block) {
		if(id().empty()) {
			set_id(get_uid());
		}
		window->add_easy_close_blocker(id());
	} else if(!id().empty()) {
		// It might never have been enabled so the id might be empty.
		window->remove_easy_close_blocker(id());
	}
}
Exemplo n.º 18
0
void list_rdr(SaHpiSessionIdT session_id, SaHpiResourceIdT resource_id)
{
        SaErrorT             	err;
        SaHpiEntryIdT        	current_rdr;
        SaHpiEntryIdT        	next_rdr;
        SaHpiRdrT            	rdr;

	SaHpiSensorReadingT	reading;
	SaHpiSensorTypeT	sensor_type;
	SaHpiSensorNumT		sensor_num;
	SaHpiEventCategoryT	category;
	SaHpiSensorThresholdsT	thres; 

	SaHpiCtrlNumT   	ctrl_num;
	SaHpiCtrlStateT 	state;
	SaHpiCtrlTypeT  	ctrl_type;

        SaHpiEirIdT             l_eirid;
        SaHpiInventoryDataT*    l_inventdata;
	const SaHpiUint32T	l_inventsize = 16384;
        SaHpiUint32T            l_actualsize;


        printf("RDR Info:\n");
        next_rdr = SAHPI_FIRST_ENTRY;
        do {
                char tmp_epath[128];
                current_rdr = next_rdr;
                err = saHpiRdrGet(session_id, resource_id, current_rdr, 
                                  &next_rdr, &rdr);
                if (SA_OK != err) {
                        if (current_rdr == SAHPI_FIRST_ENTRY)
                                printf("Empty RDR table\n");
                        else
                                error("saHpiRdrGet", err);
                        return;                        
                }
                
                printf("\tRecordId: %x\n", rdr.RecordId);
                printf("\tRdrType: %s\n", rdrtype2str(rdr.RdrType));
		
		if (rdr.RdrType == SAHPI_SENSOR_RDR)
		{			
			SaErrorT val;
			
			sensor_num = rdr.RdrTypeUnion.SensorRec.Num;
			
			val = saHpiSensorTypeGet(session_id, resource_id, 
						 sensor_num, &sensor_type, 
						 &category);
			
			printf("\tSensor num: %i\n\tType: %s\n", sensor_num, get_sensor_type(sensor_type)); 
			printf("\tCategory: %s\n", get_sensor_category(category)); 

			memset(&reading, 0, sizeof(SaHpiSensorReadingT));

			err = saHpiSensorReadingGet(session_id, resource_id, sensor_num, &reading);
			if (err != SA_OK) {
				printf("Error=%d reading sensor data {sensor, %d}\n", err, sensor_num);
				continue;
			}

			if (reading.ValuesPresent & SAHPI_SRF_RAW) {
				printf("\tValues Present: RAW\n");
				printf("\t\tRaw value: %d\n", reading.Raw);
			}

			if (reading.ValuesPresent & SAHPI_SRF_INTERPRETED) {
				printf("\tValues Present: Interpreted\n");
                                printf("\t\t");
				interpreted2str(reading.Interpreted);
			}

			if (reading.ValuesPresent & SAHPI_SRF_EVENT_STATE) {
				printf("\tValues Present: Event State\n");
			}

			if (rdr.RdrTypeUnion.SensorRec.ThresholdDefn.IsThreshold == SAHPI_TRUE) {
                                memset(&thres, 0, sizeof(SaHpiSensorThresholdsT));
				err = saHpiSensorThresholdsGet(session_id, resource_id, sensor_num, &thres);
				if (err != SA_OK) {
					printf("Error=%d reading sensor thresholds {sensor, %d}\n", err, sensor_num);
					continue;
				}
				
				if (thres.LowCritical.ValuesPresent) {
					printf("\t\tThreshold:  Low Critical Values\n");
					printreading(thres.LowCritical);
				}
				if (thres.LowMajor.ValuesPresent) {
					printf("\t\tThreshold:  Low Major Values\n");
					printreading(thres.LowMajor);
				}
				if (thres.LowMinor.ValuesPresent) {
					printf("\t\tThreshold:  Low Minor Values\n");
					printreading(thres.LowMinor);
				}
				if (thres.UpCritical.ValuesPresent) {
					printf("\t\tThreshold:  Up Critical Values\n");
					printreading(thres.UpCritical);
				}
				if (thres.UpMajor.ValuesPresent) {
					printf("\t\tThreshold:  Up Major Values\n");
					printreading(thres.UpMajor);
				}
				if (thres.UpMinor.ValuesPresent) {
					printf("\t\tThreshold:  Up Minor Values\n");
					printreading(thres.UpMinor);
				}
				if (thres.PosThdHysteresis.ValuesPresent) {
					printf("\t\tThreshold:  Pos Threshold Hysteresis Values\n");
					printreading(thres.PosThdHysteresis);
				}
				if (thres.NegThdHysteresis.ValuesPresent) {
					printf("\t\tThreshold:  Neg Threshold Hysteresis Values\n");
					printreading(thres.NegThdHysteresis);
				}
			}
		}
		
		if (rdr.RdrType == SAHPI_CTRL_RDR)
		{    
			ctrl_num = rdr.RdrTypeUnion.CtrlRec.Num;
			err = saHpiControlTypeGet(session_id, resource_id, ctrl_num, &ctrl_type);
			if (err != SA_OK) {
				printf("Error=%d reading control type {control, %d}\n", err, ctrl_num);
				continue;
			}
			printf("\tControl num: %i\n\tType: %s\n", ctrl_num, get_control_type(ctrl_type)); 
		
			err = saHpiControlStateGet(session_id, resource_id, ctrl_num, &state);
			if (err != SA_OK) {
				printf("Error=%d reading control state {control, %d}\n", err, ctrl_num);
				continue;
			}
			if (ctrl_type != state.Type) {
				printf("Control Type mismatch between saHpiControlTypeGet=%d and saHpiControlStateGet = %d\n", 
				       ctrl_type, state.Type);
			}

			switch (state.Type) {
				case SAHPI_CTRL_TYPE_DIGITAL:
					printf("\t\tControl Digital State: %s\n", 
					       ctrldigital2str(state.StateUnion.Digital));
					break;
				case SAHPI_CTRL_TYPE_DISCRETE:
					printf("\t\tControl Discrete State: %x\n", state.StateUnion.Discrete);
					break;
				case SAHPI_CTRL_TYPE_ANALOG:
					printf("\t\tControl Analog State: %x\n", state.StateUnion.Analog);
					break;
				case SAHPI_CTRL_TYPE_STREAM:
					printf("\t\tControl Stream Repeat: %d\n", state.StateUnion.Stream.Repeat);
					printf("\t\tControl Stream Data: ");
					display_oembuffer(state.StateUnion.Stream.StreamLength, state.StateUnion.Stream.Stream);
					break;
				case SAHPI_CTRL_TYPE_TEXT:
					printf("\t\tControl Text Line Num: %c\n", state.StateUnion.Text.Line);
					display_textbuffer(state.StateUnion.Text.Text);
					break;
				case SAHPI_CTRL_TYPE_OEM:
					printf("\t\tControl OEM Manufacturer: %d\n", state.StateUnion.Oem.MId);
					printf("\t\tControl OEM Data: ");
					display_oembuffer((SaHpiUint32T)state.StateUnion.Oem.BodyLength, 
						  state.StateUnion.Oem.Body);
					break;
				default:
					printf("\t\tInvalid control type (%d) from saHpiControlStateGet\n", 
					       state.Type);
			}
                }

                if (rdr.RdrType == SAHPI_INVENTORY_RDR)
                {
                        l_eirid = rdr.RdrTypeUnion.InventoryRec.EirId;

                        l_inventdata = (SaHpiInventoryDataT *)g_malloc(l_inventsize);
                        err = saHpiEntityInventoryDataRead(session_id, resource_id,
                                                            l_eirid, l_inventsize,
                                                            l_inventdata, &l_actualsize);

			if (err != SA_OK) {
				printf("Error=%d reading inventory type {EirId, %d}\n", err, l_eirid);
				continue;
			} else if (l_inventdata->Validity ==  SAHPI_INVENT_DATA_VALID) {
                        	printf("\tFound Inventory RDR with EirId: %x\n", l_eirid);
				printf("\tRDR l_inventsize = %d, actualsize = %d\n", l_inventsize, l_actualsize);
				switch (l_inventdata->DataRecords[0]->RecordType)
				{
					case SAHPI_INVENT_RECTYPE_INTERNAL_USE:
						printf( "Internal Use\n");
						break;
					case SAHPI_INVENT_RECTYPE_PRODUCT_INFO:
						printf( "Product Info\n");
						break;
					case SAHPI_INVENT_RECTYPE_CHASSIS_INFO:
						printf( "Chassis Info\n");
						break;
					case SAHPI_INVENT_RECTYPE_BOARD_INFO:
						printf( "Board Info\n");
						break;
					case SAHPI_INVENT_RECTYPE_OEM:
						printf( "OEM Record\n");
						break;
					default:
						printf(" Invalid Invent Rec Type =%x\n",
								l_inventdata->DataRecords[0]->RecordType);
						break;
				} 

			}

                        g_free(l_inventdata);
                }

                printf("\tEntity: \n");
                entitypath2string(&rdr.Entity, tmp_epath, sizeof(tmp_epath));
                printf("\t\t%s\n", tmp_epath);
                printf("\tIdString: ");
                display_textbuffer(rdr.IdString);
                printf("\n"); /* Produce blank line between rdrs. */
        }while(next_rdr != SAHPI_LAST_ENTRY);
}
Exemplo n.º 19
0
scrollbar_panel::scrollbar_panel(const implementation::builder_scrollbar_panel& builder)
	: scrollbar_container(builder, get_control_type())
{
}
Exemplo n.º 20
0
static void populate_control(datamap *map, HWND control, windows_options *opts, datamap_entry *entry, const char *option_name)
{
	int i = 0;
	BOOL bool_value = 0;
	int int_value = 0;
	float float_value = 0;
	const char *string_value;
	const char *item_string;
	int selected_index = 0;
	char buffer[128];
	int trackbar_range = 0;
	int trackbar_pos = 0;
	double trackbar_range_d = 0;

	// use default populate control value
	switch(get_control_type(control))
	{
		case CT_BUTTON:
			assert(entry->type == DM_BOOL);
			bool_value = opts->bool_value(option_name);
			Button_SetCheck(control, bool_value);
			break;

		case CT_EDIT:
		case CT_STATIC:
			switch(entry->type)
			{
				case DM_STRING:
					string_value = opts->value(option_name);
					break;

				case DM_INT:
					int_value = opts->int_value(option_name);
					if (entry->int_format != NULL)
						snprintf(buffer, ARRAY_LENGTH(buffer), entry->int_format, int_value);
					else
						snprintf(buffer, ARRAY_LENGTH(buffer), "%d", int_value);
					string_value = buffer;
					break;

				case DM_FLOAT:
					float_value = opts->float_value(option_name);
					if (entry->float_format != NULL)
						snprintf(buffer, ARRAY_LENGTH(buffer), entry->float_format, float_value);
					else
						snprintf(buffer, ARRAY_LENGTH(buffer), "%f", float_value);
					string_value = buffer;
					break;

				default:
					string_value = "";
					break;
			}
			if (string_value == NULL)
				string_value = "";
			win_set_window_text_utf8(control, string_value);
			break;

		case CT_COMBOBOX:
			selected_index = 0;
			switch(entry->type)
			{
				case DM_INT:
					int_value = opts->int_value(option_name);
					for (i = 0; i < ComboBox_GetCount(control); i++)
					{
						if (int_value == (int) ComboBox_GetItemData(control, i))
						{
							selected_index = i;
							break;
						}
					}
					break;

				case DM_STRING:
					string_value = opts->value(option_name);
					for (i = 0; i < ComboBox_GetCount(control); i++)
					{
						item_string = (const char *) ComboBox_GetItemData(control, i);
						if (!core_stricmp(string_value, item_string ? item_string : ""))
						{
							selected_index = i;
							break;
						}
					}
					break;

				default:
					break;
			}
			(void)ComboBox_SetCurSel(control, selected_index);
			break;

		case CT_TRACKBAR:
			// do we need to set the trackbar options?
/*          if (!entry->use_trackbar_options)
            {
                switch(options_get_range_type(opts, option_name))
                {
                    case OPTION_RANGE_NONE:
                        // do nothing
                        break;

                    case OPTION_RANGE_INT:
                        options_get_range_int(opts, option_name, &minval_int, &maxval_int);
                        entry->use_trackbar_options = TRUE;
                        entry->trackbar_min = minval_int;
                        entry->trackbar_max = maxval_int;
                        entry->trackbar_increments = 1;
                        break;

                    case OPTION_RANGE_FLOAT:
                        options_get_range_float(opts, option_name, &minval_float, &maxval_float);
                        entry->use_trackbar_options = TRUE;
                        entry->trackbar_min = minval_float;
                        entry->trackbar_max = maxval_float;
                        entry->trackbar_increments = (float)0.05;
                        break;
                }
            }
        */

			// do we specify default options for this control?  if so, we need to specify
			// the range
			if (entry->use_trackbar_options)
			{
				trackbar_range_d = floor(((entry->trackbar_max - entry->trackbar_min)
					/ entry->trackbar_increments) + 0.5);
				trackbar_range = (int) trackbar_range_d;
				SendMessage(control, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 0);
				SendMessage(control, TBM_SETRANGEMAX, (WPARAM) FALSE, (LPARAM) trackbar_range);
			}

			switch(entry->type)
			{
				case DM_INT:
					int_value = opts->int_value(option_name);
					trackbar_pos = trackbar_position_from_value(entry, int_value);
					break;

				case DM_FLOAT:
					float_value = opts->float_value(option_name);
					trackbar_pos = trackbar_position_from_value(entry, float_value);
					break;

				default:
					trackbar_pos = 0;
					break;
			}
			SendMessage(control, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) trackbar_pos);
			break;

		case CT_LISTVIEW:
		case CT_UNKNOWN:
			// non applicable
			break;
	}
}
Exemplo n.º 21
0
static void read_control(datamap *map, HWND control, windows_options *opts, datamap_entry *entry, const char *option_name)
{
	BOOL bool_value = 0;
	int int_value = 0;
	float float_value = 0;
	const char *string_value;
	int selected_index = 0;
	int trackbar_pos = 0;
	std::string error;
	// use default read value behavior
	switch(get_control_type(control))
	{
		case CT_BUTTON:
			assert(entry->type == DM_BOOL);
			bool_value = Button_GetCheck(control);
			opts->set_value(option_name, bool_value, OPTION_PRIORITY_CMDLINE,error);
			break;

		case CT_COMBOBOX:
			selected_index = ComboBox_GetCurSel(control);
			if (selected_index >= 0)
			{
				switch(entry->type)
				{
					case DM_INT:
						int_value = (int) ComboBox_GetItemData(control, selected_index);
						opts->set_value(option_name, int_value, OPTION_PRIORITY_CMDLINE,error);
						break;

					case DM_STRING:
						string_value = (const char *) ComboBox_GetItemData(control, selected_index);
						opts->set_value(option_name, string_value ? string_value : "", OPTION_PRIORITY_CMDLINE,error);
						break;

					default:
						break;
				}
			}
			break;

		case CT_TRACKBAR:
			trackbar_pos = SendMessage(control, TBM_GETPOS, 0, 0);
			float_value = trackbar_value_from_position(entry, trackbar_pos);
			switch(entry->type)
			{
				case DM_INT:
					int_value = (int) float_value;
					if (int_value != opts->int_value(option_name)) {
						opts->set_value(option_name, int_value, OPTION_PRIORITY_CMDLINE,error);
					}
					break;

				case DM_FLOAT:
					// Use tztrim(float_value) or we get trailing zero's that break options_equal().
					if (float_value != opts->float_value(option_name)) {
						opts->set_value(option_name, tztrim(float_value), OPTION_PRIORITY_CMDLINE,error);
					}
					break;

				default:
					break;
			}
			break;

		case CT_EDIT:
			// NYI
			break;

		case CT_STATIC:
		case CT_LISTVIEW:
		case CT_UNKNOWN:
			// non applicable
			break;
	}
}