- holt_container: added menu to select holt graph disposition
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1111 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
fe024ef461
commit
bd2999990e
|
@ -20,12 +20,21 @@
|
|||
|
||||
#include "holt_container_window.hh"
|
||||
|
||||
#include <glibmm/refptr.h>
|
||||
#include <gtkmm/action.h>
|
||||
#include <gtkmm/actiongroup.h>
|
||||
#include <gtkmm/menu.h>
|
||||
#include <gtkmm/uimanager.h>
|
||||
|
||||
|
||||
using namespace sgpem;
|
||||
using namespace Gtk;
|
||||
using namespace Glib;
|
||||
|
||||
|
||||
HoltContainerWindow::HoltContainerWindow(Simulation& simulation)
|
||||
: _holt_widget(simulation)
|
||||
{
|
||||
HoltContainerWindow::HoltContainerWindow(Simulation& simulation)
|
||||
: _holt_widget(simulation), _auto_dispose(true)
|
||||
{
|
||||
// This just sets the title of our new window.
|
||||
set_title(_("Holt Graph"));
|
||||
add(_holt_widget);
|
||||
|
@ -33,14 +42,122 @@ using namespace sgpem;
|
|||
_holt_widget.show();
|
||||
_holt_widget.set_show_threads(true);
|
||||
//set_keep_above();
|
||||
}
|
||||
|
||||
HoltContainerWindow::~HoltContainerWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void HoltContainerWindow::on_size_request(Gtk::Requisition* /* requisition */ )
|
||||
{
|
||||
set_disposition();
|
||||
}
|
||||
|
||||
HoltWidget& HoltContainerWindow::get_holt_widget()
|
||||
{
|
||||
return _holt_widget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool
|
||||
HoltContainerWindow::on_button_press_event(GdkEventButton* event)
|
||||
{
|
||||
if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) )
|
||||
{
|
||||
Glib::ustring ui_info =
|
||||
"<ui>"
|
||||
" <popup name='PopupMenu'>";
|
||||
|
||||
HoltWidget::arrange_mode arrange = _holt_widget.get_arrange_mode();
|
||||
|
||||
RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create();
|
||||
|
||||
if(_auto_dispose || arrange!=HoltWidget::arrange_vertical)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("DisposeVertical", "Dispose _Vertical"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_dispose_vertical) );
|
||||
ui_info += " <menuitem action='DisposeVertical'/>";
|
||||
}
|
||||
|
||||
HoltContainerWindow::~HoltContainerWindow()
|
||||
if(_auto_dispose || arrange!=HoltWidget::arrange_horizontal)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("DisposeHorizontal", "Dispose _Horizontal"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_dispose_horizontal) );
|
||||
ui_info += " <menuitem action='DisposeHorizontal'/>";
|
||||
}
|
||||
|
||||
void HoltContainerWindow::on_size_request(Gtk::Requisition* /* requisition */ )
|
||||
if(_auto_dispose || arrange!=HoltWidget::arrange_circular)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("DisposeCircular", "Dispose _Circular"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_dispose_circular) );
|
||||
ui_info += " <menuitem action='DisposeCircular'/>";
|
||||
}
|
||||
|
||||
if(!_auto_dispose)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("DisposeAuto", "_Auto Dispose"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_dispose_auto) );
|
||||
ui_info += " <menuitem action='DisposeAuto'/>";
|
||||
}
|
||||
|
||||
RefPtr<UIManager> UIManager = Gtk::UIManager::create();
|
||||
UIManager->insert_action_group(action_group);
|
||||
|
||||
ui_info +=
|
||||
" </popup>"
|
||||
"</ui>";
|
||||
|
||||
UIManager->add_ui_from_string(ui_info);
|
||||
Gtk::Menu* menu = dynamic_cast<Gtk::Menu*>(UIManager->get_widget("/PopupMenu"));
|
||||
|
||||
menu->popup(event->button, event->time);
|
||||
return true; //It has been handled.
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
HoltContainerWindow::_on_dispose_vertical()
|
||||
{
|
||||
_auto_dispose = false;
|
||||
_holt_widget.set_arrange_mode(HoltWidget::arrange_vertical);
|
||||
_holt_widget.resize_redraw();
|
||||
}
|
||||
|
||||
void
|
||||
HoltContainerWindow::_on_dispose_circular()
|
||||
{
|
||||
_auto_dispose = false;
|
||||
_holt_widget.set_arrange_mode(HoltWidget::arrange_circular);
|
||||
_holt_widget.resize_redraw();
|
||||
}
|
||||
|
||||
void
|
||||
HoltContainerWindow::_on_dispose_horizontal()
|
||||
{
|
||||
_auto_dispose = false;
|
||||
_holt_widget.set_arrange_mode(HoltWidget::arrange_horizontal);
|
||||
_holt_widget.resize_redraw();
|
||||
}
|
||||
|
||||
void
|
||||
HoltContainerWindow::_on_dispose_auto()
|
||||
{
|
||||
_auto_dispose = true;
|
||||
set_disposition();
|
||||
_holt_widget.resize_redraw();
|
||||
}
|
||||
|
||||
void HoltContainerWindow::set_disposition()
|
||||
{
|
||||
if(_auto_dispose){
|
||||
int height = get_height();
|
||||
int width = get_width();
|
||||
// if height/width >=5/3
|
||||
|
@ -56,12 +173,5 @@ using namespace sgpem;
|
|||
{
|
||||
_holt_widget.set_arrange_mode(HoltWidget::arrange_circular);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
HoltWidget& HoltContainerWindow::get_holt_widget()
|
||||
{
|
||||
return _holt_widget;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,9 +48,21 @@ namespace sgpem {
|
|||
virtual ~HoltContainerWindow();
|
||||
|
||||
HoltWidget& get_holt_widget();
|
||||
|
||||
protected:
|
||||
virtual void on_size_request (Gtk::Requisition* requisition);
|
||||
bool on_button_press_event(GdkEventButton* event);
|
||||
|
||||
void set_disposition();
|
||||
|
||||
private:
|
||||
void _on_dispose_vertical();
|
||||
void _on_dispose_circular();
|
||||
void _on_dispose_horizontal();
|
||||
void _on_dispose_auto();
|
||||
|
||||
HoltWidget _holt_widget;
|
||||
bool _auto_dispose;
|
||||
};
|
||||
|
||||
} // ~ namespace sgpem
|
||||
|
|
Loading…
Reference in New Issue