Exemplo n.º 1
0
void AbstractButton::SetDown (bool down)
{
  if (is_checkable()) {
    if (is_checked() != down) RequestRedraw();

    set_checked(down);

    if (group_) {
      group_->Toggle(this, is_checked());
    } else {
      toggled_.Invoke(is_checked());
    }

  } else {

    if (is_down() != down) RequestRedraw();

    set_down(down);
    if (group_) {
      group_->Click(this);
    } else {
      clicked_.Invoke();
    }
  }
}
Exemplo n.º 2
0
Response AbstractButton::PerformMouseRelease (AbstractWindow* context)
{
  if (context->GetMouseButton() == MouseButtonLeft) {
    int fire_event = 0;	// 0: no event, 1: click event, 2: toggled event

    if (is_checkable()) {
      if (is_pressed()) {
        fire_event = 2;
      }
    } else {
      if (is_pressed() && is_down()) {
        fire_event = 1;
      }
    }

    RequestRedraw();

    switch (fire_event) {

      case 0:
        break;

      case 1: {
        if (group_) {
          group_->Click(this);
        } else {
          clicked_.Invoke();
        }
        break;
      }

      case 2: {
        if (is_checked() != is_last_checked()) {

          if (group_) {
            group_->Toggle(this, is_checked());
          } else {
            toggled_.Invoke(is_checked());
          }
        }
        break;
      }

      default:
        break;
    }

    set_pressed(false);
    set_down(false);

    released_.Invoke();

    return Finish;
  }

  return Ignore;
}
Exemplo n.º 3
0
void on_Game_Fix_OK(GtkButton *button, gpointer user_data)
{

    Config.GameFixes = 0;
    Config.GameFixes |= is_checked(GameFixDlg, "check_VU_Add_Sub") ? FLAG_VU_ADD_SUB : 0;
    Config.GameFixes |= is_checked(GameFixDlg, "check_FPU_Clamp") ? FLAG_FPU_CLAMP : 0;
    Config.GameFixes |= is_checked(GameFixDlg, "check_VU_FCOR_hack") ? FLAG_VU_FCOR_HACK : 0;

    SaveConfig();
    gtk_widget_destroy(GameFixDlg);
    gtk_widget_set_sensitive(MainWindow, TRUE);
    gtk_main_quit();
}
Exemplo n.º 4
0
static gchar* get_prefix(glong index)
{
    gchar* prefix;
    gchar space = ' ';
    if (view.current == index && (view.top_x > 0 || is_white(index)) )
        space = '>';
    prefix = g_strnfill(1, space);

    if (conf.numbers)
    {
        gchar* tmp = prefix;
        glong max_n = num_digits(SL);
        glong n = num_digits(index);
        gchar* str_index = g_strdup_printf("%ld", index);
        gchar* num_prefix = g_strnfill(max_n - n, ' ');
        prefix = g_strconcat(num_prefix, str_index, tmp, NULL);
        g_free(tmp);
        g_free(num_prefix);
        g_free(str_index);
    }

    if (conf.checkbox)
    {
        gchar* symbol = " ";
        if (is_checked(index))
        {
            symbol = "x";
            if (conf.radiobox) symbol = "o";
        }
        gchar* tmp = prefix;
        prefix = g_strconcat(tmp, "[", symbol, "]", NULL);
        g_free(tmp);
    }
    return prefix;
}
Exemplo n.º 5
0
		void toggle()
		{
			if (is_checked())
				uncheck();
			else
				check();
		}
Exemplo n.º 6
0
	void toolbar_button::init()
	{
		if (iAction.is_checkable())
			set_checkable();
		label().set_placement(label_placement::ImageVertical);
		text().set_text(iAction.button_text());
		image().set_image(iAction.image());
		iSink += iAction.enabled([this]() { enable(); });
		iSink += iAction.disabled([this]() { disable(); });
		enable(iAction.is_enabled());
		auto update_checked = [this]()
		{
			if (is_checked())
			{
				iAction.check();
				image().set_image(iAction.checked_image());
			}
			else
			{
				iAction.uncheck();
				image().set_image(iAction.image());
			}
		};
		iSink += checked(update_checked);
		iSink += unchecked(update_checked);
		iSink += iAction.checked([this]() {set_checked(true); });
		iSink += iAction.unchecked([this]() {set_checked(false); });
		set_checked(iAction.is_checked());
	}
Exemplo n.º 7
0
	void button::toggle()
	{
		if (is_checked() || is_indeterminate())
			set_checked(false);
		else
			set_checked(true);
	}
Exemplo n.º 8
0
void AbstractButton::SetChecked (bool checked)
{
  if (is_checkable()) {

    if (is_checked() == checked) return;

    set_checked(checked);
    RequestRedraw();

    if (group_) {
      group_->Toggle(this, is_checked());
    } else {
      toggled_.Invoke(is_checked());
    }
  }
}
Exemplo n.º 9
0
/* Used to return the partial solutions from a sub-tree of the complete search-tree. Returns the solutions recursively.
 */
int worker_recursion(int counter, int board[], int boardSize){
    int workerSols = 0;
    if (counter >= boardSize) {
        if (is_checked(counter,board)) {
            workerSols++;
            return workerSols;
        }
    }
    else if (is_checked(counter,board)){
        for(int row=0; row<boardSize; row++){
            board[counter] = row;
            workerSols += worker_recursion(counter+1, board, boardSize);
        }
    }
    return workerSols;
}
Exemplo n.º 10
0
void on_Speed_Hack_OK(GtkButton *button, gpointer user_data)
{
    Config.Hacks = 0;

    if is_checked(SpeedHacksDlg, "check_default_cycle_rate")
        Config.Hacks = 0;
    else if is_checked(SpeedHacksDlg, "check_1_5_cycle_rate")
	// The standard version of this command does not support checked or disabled
	// commands, so we use our own version.
	virtual bool get_display(t_uint32 p_index, pfc::string_base & p_text, t_uint32 & p_flags)
	{
		p_flags = 0;
		if (is_checked(p_index))
			p_flags |= flag_checked;
		get_name(p_index,p_text);
		return true;
	}
Exemplo n.º 12
0
Response AbstractButton::PerformMousePress (AbstractWindow* context)
{
  if (context->GetMouseButton() == MouseButtonLeft) {
    set_pressed(true);
    set_down(true);

    if (is_checkable()) {
      set_last_checked(is_checked());
      set_checked(!is_checked());
    }

    RequestRedraw();

    pressed_.Invoke();
  }

  return Finish;
}
Exemplo n.º 13
0
void AbstractButton::PerformHoverIn (AbstractWindow* context)
{
  if (is_pressed()) {
    set_down(true);

    if (is_checkable()) {
      set_checked(!is_checked());
    }

    RequestRedraw();
  }
}
Exemplo n.º 14
0
	void toolbar_button::handle_clicked()
	{
		push_button::handle_clicked();
		if (iAction.is_enabled() && !iAction.is_separator())
		{
			iAction.triggered.trigger();
			if (iAction.is_checkable())
			{
				if (is_checked())
					iAction.check();
				else
					iAction.uncheck();
			}
		}
	}
Exemplo n.º 15
0
	bool button::set_checked_state(const boost::optional<bool>& aCheckedState)
	{
		if (iCheckedState == aCheckedState)
			return false;
		if (aCheckedState == boost::none && iCheckable != TriState)
			throw not_tri_state_checkable();
		iCheckedState = aCheckedState;
		update();
		if (is_checked())
			checked.trigger();
		else if (is_unchecked())
			unchecked.trigger();
		else if (is_indeterminate())
			indeterminate.trigger();
		return true;
	}
Exemplo n.º 16
0
Response RadioButton::Draw (AbstractWindow* context)
{
  AbstractWindow::shaders()->widget_inner_program()->use();

  glUniform1i(
      AbstractWindow::shaders()->location(Shaders::WIDGET_INNER_GAMMA), 0);
  glUniform1i(
      AbstractWindow::shaders()->location(Shaders::WIDGET_INNER_SHADED),
      context->theme()->radio_button().shaded);
  if (is_checked()) {
    glUniform4fv(AbstractWindow::shaders()->location(Shaders::WIDGET_INNER_COLOR), 1,
                 AbstractWindow::theme()->radio_button().inner_sel.data());
  } else {
    glUniform4fv(AbstractWindow::shaders()->location(Shaders::WIDGET_INNER_COLOR), 1,
                 AbstractWindow::theme()->radio_button().inner.data());
  }

  glBindVertexArray(vao_[0]);
  glDrawArrays(GL_TRIANGLE_FAN, 0, outline_vertex_count(round_type()) + 2);

  AbstractWindow::shaders()->widget_outer_program()->use();

  glUniform2f(AbstractWindow::shaders()->location(Shaders::WIDGET_OUTER_OFFSET), 0.f, 0.f);
  glUniform4fv(AbstractWindow::shaders()->location(Shaders::WIDGET_OUTER_COLOR), 1,
               AbstractWindow::theme()->radio_button().outline.data());

  glBindVertexArray(vao_[1]);
  glDrawArrays(GL_TRIANGLE_STRIP, 0,
               outline_vertex_count(round_type()) * 2 + 2);

  if (emboss()) {
    glUniform4f(AbstractWindow::shaders()->location(Shaders::WIDGET_OUTER_COLOR), 1.0f,
                1.0f, 1.0f, 0.16f);
    glUniform2f(AbstractWindow::shaders()->location(Shaders::WIDGET_OUTER_OFFSET),
                0.f, 0.f - 1.f);
    glDrawArrays(GL_TRIANGLE_STRIP, 0,
                 emboss_vertex_count(round_type()) * 2);
  }

  if (is_down()) {
    DrawIconText(context->theme()->radio_button().text_sel.data(), 0);
  } else {
    DrawIconText(context->theme()->radio_button().text.data(), 0);
  }

  return Finish;
}
Exemplo n.º 17
0
void OnConf_Ok(GtkButton *button, gpointer user_data)
{
	GtkWidget *Btn;
	GtkWidget *treeview;
	GtkTreeModel *treemodel;
	GtkTreeIter treeiter;
	gboolean treeoptval;
	gchar *gbuf;
	char *str;
	int i;

	conf.bilinear = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(Conf, "checkBilinear")));
	// restore
	if (conf.bilinear && prevbilinearfilter)
		conf.bilinear = prevbilinearfilter;

	//conf.mrtdepth = 1;//IsDlgButtonChecked(hW, IDC_CONFIG_DEPTHWRITE);

	if is_checked(Conf, "radioAANone")
		conf.aa = 0;
	else if is_checked(Conf, "radioAA2X")
Exemplo n.º 18
0
void on_Advanced_OK(GtkButton *button, gpointer user_data)
{
	Config.sseMXCSR &= 0x1fbf;
	Config.sseVUMXCSR &= 0x1fbf;
	Config.eeOptions = 0;
	Config.vuOptions = 0;

	Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Near") ? FLAG_ROUND_NEAR : 0;
	Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0;
	Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Positive") ? FLAG_ROUND_POSITIVE : 0;
	Config.sseMXCSR |= is_checked(AdvDlg, "radio_EE_Round_Zero") ? FLAG_ROUND_ZERO : 0;

	Config.sseMXCSR |= is_checked(AdvDlg, "check_EE_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0;
	Config.sseMXCSR |= is_checked(AdvDlg, "check_EE_Flush_Zero") ? FLAG_FLUSH_ZERO : 0;

	Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Near") ? FLAG_ROUND_NEAR : 0;
	Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Negative") ? FLAG_ROUND_NEGATIVE : 0;
	Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Positive") ? FLAG_ROUND_POSITIVE : 0;
	Config.sseVUMXCSR |= is_checked(AdvDlg, "radio_VU_Round_Zero") ? FLAG_ROUND_ZERO : 0;

	Config.sseVUMXCSR |= is_checked(AdvDlg, "check_VU_Denormal_Zero") ? FLAG_DENORMAL_ZERO : 0;
	Config.sseVUMXCSR |= is_checked(AdvDlg, "check_VU_Flush_Zero") ? FLAG_FLUSH_ZERO : 0;

	Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_None") ? FLAG_EE_CLAMP_NONE : 0;
	Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_Normal") ? FLAG_EE_CLAMP_NORMAL : 0;
	Config.eeOptions |= is_checked(AdvDlg, "radio_EE_Clamp_Extra_Preserve") ? FLAG_EE_CLAMP_EXTRA_PRESERVE : 0;

	Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_None") ? FLAG_VU_CLAMP_NONE : 0;
	Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Normal") ? FLAG_VU_CLAMP_NORMAL : 0;
	Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Extra") ? FLAG_VU_CLAMP_EXTRA : 0;
	Config.vuOptions |= is_checked(AdvDlg, "radio_VU_Clamp_Extra_Preserve") ? FLAG_VU_CLAMP_EXTRA_PRESERVE : 0;

	SetCPUState(Config.sseMXCSR, Config.sseVUMXCSR);
	SaveConfig();

	gtk_widget_destroy(AdvDlg);
	gtk_widget_set_sensitive(MainWindow, TRUE);
	gtk_main_quit();
}
	is_checked_iterator is_checked_end()
	{
		winstl::listview_sequence lv_seq(*(static_cast<List*>(this)));
		return boost::make_filter_iterator<is_checked>(is_checked(this), lv_seq.end(), lv_seq.end());
	}
Exemplo n.º 20
0
static void
search_clicked (G_GNUC_UNUSED GtkWidget *widget, DialogState *dd)
{
	GtkBuilder *gui = dd->gui;
	WBCGtk *wbcg = dd->wbcg;
	WorkbookControl *wbc = WORKBOOK_CONTROL (wbcg);
	GnmSearchReplace *sr;
	char *err;
	int i;
	GnmSearchReplaceScope scope;
	char *text;
	gboolean is_regexp, is_number;

	i = go_gtk_builder_group_value (gui, scope_group);
	scope = (i == -1) ? GNM_SRS_SHEET : (GnmSearchReplaceScope)i;

	i = go_gtk_builder_group_value (gui, search_type_group);
	is_regexp = (i == 1);
	is_number = (i == 2);

	text = gnm_search_normalize (gtk_entry_get_text (dd->gentry));

	sr = g_object_new (GNM_SEARCH_REPLACE_TYPE,
			   "sheet", wb_control_cur_sheet (wbc),
			   "scope", scope,
			   "range-text", gnm_expr_entry_get_text (dd->rangetext),
			   "search-text", text,
			   "is-regexp", is_regexp,
			   "is-number", is_number,
			   "ignore-case", is_checked (gui, "ignore_case"),
			   "match-words", is_checked (gui, "match_words"),
			   "search-strings", is_checked (gui, "search_string"),
			   "search-other-values", is_checked (gui, "search_other"),
			   "search-expressions", is_checked (gui, "search_expr"),
			   "search-expression-results", is_checked (gui, "search_expr_results"),
			   "search-comments", is_checked (gui, "search_comments"),
			   "by-row", go_gtk_builder_group_value (gui, direction_group) == 0,
			   NULL);

	g_free (text);

	err = gnm_search_replace_verify (sr, FALSE);
	if (err) {
		go_gtk_notice_dialog (GTK_WINDOW (dd->dialog),
				      GTK_MESSAGE_ERROR, "%s", err);
		g_free (err);
		g_object_unref (sr);
		return;
	} else if (!sr->search_strings &&
		   !sr->search_other_values &&
		   !sr->search_expressions &&
		   !sr->search_expression_results &&
		   !sr->search_comments) {
		go_gtk_notice_dialog (GTK_WINDOW (dd->dialog), GTK_MESSAGE_ERROR,
				      _("You must select some cell types to search."));
		g_object_unref (sr);
		return;
	}

	if  (is_checked (gui, "save-in-prefs"))
		dialog_search_save_in_prefs (dd);

	{
		GnumericLazyList *ll;
		GPtrArray *cells;

		/* Clear current table.  */
		gtk_tree_view_set_model (dd->matches_table, NULL);
		gnm_search_filter_matching_free (dd->matches);

		cells = gnm_search_collect_cells (sr);
		dd->matches = gnm_search_filter_matching (sr, cells);
		gnm_search_collect_cells_free (cells);

		ll = make_matches_model (dd, dd->matches->len);
		gtk_tree_view_set_model (dd->matches_table, GTK_TREE_MODEL (ll));
		g_object_unref (ll);

		/* Set sensitivity of buttons.  */
		cursor_change (dd->matches_table, dd);
	}

	gtk_notebook_set_current_page (dd->notebook, dd->notebook_matches_page);
	gtk_widget_grab_focus (GTK_WIDGET (dd->matches_table));

	g_object_unref (sr);
}