Esempio n. 1
0
//
// evaluate
//
Value * Refers_to_Method::evaluate (Ocl_Context & res, 
                                    GAME::Mga::Object caller)
{
  GAME::Mga::Reference ref = GAME::Mga::Reference::_narrow (caller);

  return new Object_Value (ref->refers_to ());
}
Esempio n. 2
0
//
// handle_object_created
//
int CBML_MultiInput_Handler::
handle_object_created (GAME::Mga::Object_in obj)
{
  if (this->is_importing_)
    return 0;

  const std::string no_op_message = "A MultiInputAction has already been created for all facet operations.";

  GAME::Mga::Connection connection = GAME::Mga::Connection::_narrow (obj);
  GAME::Mga::Reference facet = GAME::Mga::Reference::_narrow (connection->src ());
  GAME::Mga::FCO input_action = connection->dst ();
  GAME::Mga::Model object = GAME::Mga::Model::_narrow (facet->refers_to ());

  // Collect the operations on the Object
  std::vector <GAME::Mga::Object> operations;
  this->get_operations (object, operations);

  // Get all the other MultiInputActions connected to the facet
  std::vector <GAME::Mga::Object> existing_actions;
  this->get_actions (facet, existing_actions);

  // Remove existing actions from the operations
  std::vector <GAME::Mga::Object> targets;
  this->narrow_targets (operations, existing_actions, targets);

  // The name to use for the MultiInputAction
  std::string name;

  if (targets.size () == 0)
  {
    ::AfxMessageBox (no_op_message.c_str (), MB_ICONINFORMATION | MB_OK);
    return 0;
  }
  else if (targets.size () == 1)
    name = targets.front ()->name ();
  else
  {
    AFX_MANAGE_STATE (::AfxGetStaticModuleState ());

    using GAME::Dialogs::Selection_List_Dialog_T;
    Selection_List_Dialog_T <GAME::Mga::Object> dlg (0, ::AfxGetMainWnd ());

    dlg.title ("Target Operation");
    dlg.directions ("Select the target Operation for the MultiInputAction");
    dlg.insert (targets);

    if (IDOK != dlg.DoModal ())
      return 0;

    name = dlg.selection ()->name ();
  }

  if (!name.empty())
    input_action->name (name);

  return 0;
}
Esempio n. 3
0
//
// create
//
BOOL PICML_Enum_Data_Value_Control::
Create (DWORD style, const RECT & rect, CWnd * parent, UINT id)
{
  // Calculate the size of the control to compensate the list.
  LOGFONT logfont;
  parent->GetFont ()->GetLogFont (&logfont);
  size_t font_height = abs (logfont.lfHeight);

  CRect combo_rect (rect.left,
                    rect.top,
                    rect.right,
                    rect.bottom + font_height * 5);

  // Update the style.
  style |= CBS_DROPDOWNLIST | CBS_SORT;

  if (PICML_Simple_Data_Value_Control <CComboBox>::Create (style, combo_rect, parent, id) == FALSE)
    return FALSE;

  // Populate the control with the enumeration values.
  GAME::Mga::Reference ref = GAME::Mga::Reference::_narrow (this->value_);
  GAME::Mga::Model e = GAME::Mga::Model::_narrow (ref->refers_to ());
  std::vector <GAME::Mga::Atom> values;

  if (e->children ("EnumValue", values))
    std::for_each (values.begin (),
                   values.end (),
                   boost::bind (&PICML_Enum_Data_Value_Control::visit_enum_value,
                                this,
                                _1));

  // Select the current value.
  const std::string selection =
    this->value_->attribute (attr::Value)->string_value ();

  if (!selection.empty ())
    this->SelectString (-1, selection.c_str ());

  return TRUE;
}