コード例 #1
0
//------------------------------------------------------------------------------
std::string mforms::gtk::ToolBarImpl::get_item_text(mforms::ToolBarItem *item) {
  std::string text;

  switch (item->get_type()) {
    case mforms::FlatSelectorItem:
    case mforms::SelectorItem: {
      Gtk::ComboBoxText *ct = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
      if (ct)
        text = ct->get_active_text();
      break;
    }
    case mforms::ColorSelectorItem: {
      const Gtk::ComboBox *combo = cast<Gtk::ComboBox *>(item->get_data_ptr());
      if (combo) {
        const Gtk::TreeIter iter = combo->get_active();
        const Gtk::TreeRow row = *iter;
        text = row.get_value(color_combo_columns->color);
      }
      break;
    }
    case mforms::SearchFieldItem: {
      Gtk::Entry *e = cast<Gtk::Entry *>(item->get_data_ptr());
      if (e)
        text = e->get_text();
      break;
    }
    default: {
      Gtk::Widget *btn = cast<Gtk::Widget *>(item->get_data_ptr());
      if (btn)
        text = btn->get_name();
    }
  }

  return text;
}
コード例 #2
0
ファイル: npc_list.cpp プロジェクト: bjorn/graal-gonstruct
void level_editor::npc_list::on_edit_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    
    // get selected npc
    npc& current_npc = *row.get_value(columns.iter);
    edit_npc dialog;
    dialog.set(current_npc);
    if (dialog.run() == Gtk::RESPONSE_OK) {
      Graal::npc new_npc = dialog.get_npc();
      level_display* display = m_window.get_current_level_display();
      // TODO: urgh -- move this into level_display (edit_npc() or something)
      /*if (new_npc != current_npc) {
        display->add_undo_diff(new npc_diff(current_npc));
      }*/
      // save npc
      current_npc = new_npc;
      // TODO: this should probably not be here
      display->clear_selection();
      display->queue_draw();
    }

    get();
  }
}
コード例 #3
0
ファイル: sign_list.cpp プロジェクト: fry/graal-gonstruct
void level_editor::sign_list::on_delete_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    m_window.get_current_level()->signs.erase(row.get_value(columns.iter));
    get();
    m_window.get_current_level_display()->queue_draw();
  }
}
コード例 #4
0
void ModelAvailFctAdapterModelImpl::setSelectedRow(Gtk::TreeRow Row)
{
  if (Row)
  {
    std::string SelectedId = Row.get_value(m_Columns.m_Id);
    if (Row && m_SignaturesById.find(SelectedId) != m_SignaturesById.end())
      mp_SelectedSignature = m_SignaturesById[SelectedId];
    else
      mp_SelectedSignature = 0;
  }
}
コード例 #5
0
ファイル: tileset_list.cpp プロジェクト: fry/graal-gonstruct
void level_editor::tileset_list::on_active_toggled(const Glib::ustring& path) {
  Gtk::TreeModel::iterator iter = m_list_store->get_iter(path);
  
  if (iter) {
    // Toggle the active state of the currently selected tileset
    Gtk::TreeRow row = *iter;
    tileset_list_type::iterator tileset_iter = row.get_value(columns.iter);

    bool active = !tileset_iter->active;
    tileset_iter->active = active;
    row.set_value(columns.active, active);
    m_window.update_matching_level_displays(tileset_iter->prefix);
  }
}
コード例 #6
0
ファイル: tileset_list.cpp プロジェクト: fry/graal-gonstruct
void level_editor::tileset_list::on_delete_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    tileset_list_type::iterator tileset_iter = row.get_value(columns.iter);
    // Cache prefix to update tileset after
    std::string prefix = tileset_iter->prefix;
    m_preferences.tilesets.erase(tileset_iter);

    m_window.update_matching_level_displays(prefix);
    get();
  }
}
コード例 #7
0
ファイル: npc_list.cpp プロジェクト: bjorn/graal-gonstruct
void level_editor::npc_list::on_delete_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    level_display* display = m_window.get_current_level_display();
    Graal::level::npc_list_type::iterator npc_iter = row.get_value(columns.iter);
    // TODO: move this into level_display, too
    /*display->add_undo_diff(new delete_npc_diff(*npc_iter));
    display->get_current_level()->npcs.erase(npc_iter);*/
    get();

    display->clear_selection();
    display->queue_draw();
  }
}
コード例 #8
0
ファイル: tileset_list.cpp プロジェクト: fry/graal-gonstruct
void level_editor::tileset_list::on_edit_clicked() {
  Glib::RefPtr<Gtk::TreeView::Selection> selection = m_tree_view.get_selection();
  Gtk::TreeModel::iterator iter = selection->get_selected();
  if (iter) {
    Gtk::TreeRow row = *iter;
    
    // get selected tileset
    tileset& _tileset = *row.get_value(columns.iter);
    edit_tileset dialog;
    dialog.get(_tileset);
    if (dialog.run() == Gtk::RESPONSE_OK) {
      std::string old_prefix = _tileset.prefix;
      std::string old_name = _tileset.name;
      // save tileset
      dialog.set(_tileset);
      // update levels with the previous prefix and new levels
      if (old_prefix != _tileset.prefix)
        m_window.update_matching_level_displays(old_prefix);
      m_window.update_matching_level_displays(_tileset.prefix);
    }

    get();
  }
}
コード例 #9
0
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_item_text(mforms::ToolBarItem *item, const std::string &label) {
  const mforms::ToolBarItemType type = item->get_type();

  switch (type) {
    case mforms::TextActionItem:
    case mforms::ActionItem:
    case mforms::SegmentedToggleItem:
    case mforms::ToggleItem:
    case mforms::SwitcherItem: {
      Gtk::Button *btn = cast<Gtk::Button *>(item->get_data_ptr());
      if (type == mforms::SwitcherItem) {
        btn->set_label(label);
        btn->get_style_context()->add_class("SwitcherItem");
      } else
        btn->add_label(label);
      btn->set_name(label);
      break;
    }
    case mforms::TitleItem:
    case mforms::LabelItem: {
      Gtk::Label *lbl = cast<Gtk::Label *>(item->get_data_ptr());
      if (lbl) {
        lbl->set_markup("<small>" + label + "</small>");
        lbl->set_name(label);
      }
      break;
    }
    case mforms::FlatSelectorItem:
    case mforms::SelectorItem: {
      Gtk::ComboBoxText *ct = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
      if (ct)
        ct->set_active_text(label);
      break;
    }
    case mforms::ColorSelectorItem: {
      Gtk::ComboBox *combo = cast<Gtk::ComboBox *>(item->get_data_ptr());
      if (combo) {
        Glib::RefPtr<Gtk::TreeModel> model = combo->get_model();
        if (model) {
          const Gtk::TreeModel::Children children = model->children();
          const Gtk::TreeIter last = children.end();
          Gtk::TreeRow row;

          for (Gtk::TreeIter it = children.begin(); it != last; ++it) {
            row = *it;
            if (row.get_value(color_combo_columns->color) == label) {
              combo->set_active(it);
              break;
            }
          }
        }
      }
      break;
    }
    case mforms::SearchFieldItem:
    case mforms::TextEntryItem: {
      Gtk::Entry *e = cast<Gtk::Entry *>(item->get_data_ptr());
      if (e)
        e->set_text(label);
      break;
    }
    case mforms::SeparatorItem:
    case mforms::ExpanderItem:
    case mforms::ImageBoxItem:
      break;
  }
}