コード例 #1
0
void PopupMenuControl::currentIndexChanged (int index)
{
  if (! m_blockUpdate)
    {
      gh_manager::post_set (m_handle, "value",
			    octave_value (double (index + 1)),
			    false);
      gh_manager::post_callback (m_handle, "callback");
    }
}
コード例 #2
0
void PopupMenuControl::update (int pId)
{
  uicontrol::properties& up = properties<uicontrol> ();
  QComboBox* box = qWidget<QComboBox> ();

  switch (pId)
    {
    case uicontrol::properties::ID_STRING:
      m_blockUpdate = true;
	{
	  int oldCurrent = box->currentIndex ();

	  box->clear ();
	  box->addItems (Utils::fromStdString
			 (up.get_string_string ()).split ('|'));
	  if (box->count() > 0
	      && oldCurrent >= 0
	      && oldCurrent < box->count ())
	    {
	      box->setCurrentIndex (oldCurrent);
	    }
	  else
	    {
	      gh_manager::post_set (m_handle, "value",
				    octave_value (box->count () > 0
						  ? 1.0 : 0.0),
				    false);
	    }
	}
      m_blockUpdate = false;
      break;
    case uicontrol::properties::ID_VALUE:
	{
	  Matrix value = up.get_value ().matrix_value ();

	  if (value.numel () > 0)
	    {
	      int newIndex = int (value(0)) - 1;

	      if (newIndex >= 0 && newIndex < box->count ()
		  && newIndex != box->currentIndex ())
		{
		  box->setCurrentIndex (newIndex);
		}
	    }
	}
      break;
    default:
      BaseControl::update (pId);
      break;
    }
}
コード例 #3
0
ファイル: ListBoxControl.cpp プロジェクト: Htallon/QtHandles
void ListBoxControl::itemSelectionChanged (void)
{
  if (! m_blockCallback)
    {
      QListWidget* list = qWidget<QListWidget> ();

      QModelIndexList l = list->selectionModel ()->selectedIndexes ();
      Matrix value (dim_vector (1, l.size ()));
      int i = 0;

      foreach (const QModelIndex& idx, l)
       value(i++) = (idx.row () + 1);

      gh_manager::post_set (m_handle, "value", octave_value (value), false);
      gh_manager::post_callback (m_handle, "callback");
    }
コード例 #4
0
ファイル: stage16.5.cpp プロジェクト: brothers-morrison/ffi
extern "C" const char * stage16_5_blep (const char *foo) {
    string_vector argv(2);
    argv(0) = "embedded";
    argv(1) = "-q";
    octave_main(2, argv.c_str_vec(), 1);
    octave_exit = much_improved_octave_exit_func;

    int st=0;
    eval_string("source(\"stage17.m\")", true, st);

    octave_value_list args(1);
    args(octave_idx_type(0)) = octave_value(foo);
    octave_value_list out = feval("blep", args, 1);
    std::string orv = out(0).string_value();
    const char *rv = strdup(orv.c_str());

    clean_up_and_exit(0);
    return rv;
}