- holt_container: partial implemented (and commented) scaling menu
- simulation_widget: added scaling popup menu git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1138 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
da0aabcf61
commit
4872d56461
|
@ -76,37 +76,56 @@ HoltContainerWindow::on_button_press_event(GdkEventButton* event)
|
|||
"<ui>"
|
||||
" <popup name='PopupMenu'>";
|
||||
|
||||
HoltWidget::arrange_mode arrange = _holt_widget.get_arrange_mode();
|
||||
HoltWidget::arrange_mode arrange = _holt_widget.get_arrange_mode();
|
||||
CairoWidget::scaling_mode scaling = _holt_widget.get_scaling_mode();
|
||||
|
||||
RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create();
|
||||
|
||||
if(_auto_dispose || arrange!=HoltWidget::arrange_vertical)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("DisposeVertical", "Dispose _Vertical"),
|
||||
action_group->add( Gtk::Action::create("DisposeVertical", "Dispose _vertical"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_dispose_vertical) );
|
||||
ui_info += " <menuitem action='DisposeVertical'/>";
|
||||
}
|
||||
|
||||
if(_auto_dispose || arrange!=HoltWidget::arrange_horizontal)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("DisposeHorizontal", "Dispose _Horizontal"),
|
||||
action_group->add( Gtk::Action::create("DisposeHorizontal", "Dispose _horizontal"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_dispose_horizontal) );
|
||||
ui_info += " <menuitem action='DisposeHorizontal'/>";
|
||||
}
|
||||
|
||||
if(_auto_dispose || arrange!=HoltWidget::arrange_circular)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("DisposeCircular", "Dispose _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"),
|
||||
action_group->add( Gtk::Action::create("DisposeAuto", "_Auto dispose"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_dispose_auto) );
|
||||
ui_info += " <menuitem action='DisposeAuto'/>";
|
||||
}
|
||||
|
||||
/* disabled scaling options
|
||||
if(scaling==CairoWidget::scaling_min)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("ScalingNone", "Auto _resize window"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_no_scaling) );
|
||||
ui_info += " <separator/>"
|
||||
" <menuitem action='ScalingNone'/>";
|
||||
}
|
||||
else
|
||||
{
|
||||
// scaling==scaling_none
|
||||
action_group->add( Gtk::Action::create("ScalingFit", "_Fit in window"),
|
||||
sigc::mem_fun(*this, &HoltContainerWindow::_on_fit_scaling) );
|
||||
ui_info += " <separator/>"
|
||||
" <menuitem action='ScalingFit'/>";
|
||||
}
|
||||
*/
|
||||
|
||||
RefPtr<UIManager> UIManager = Gtk::UIManager::create();
|
||||
UIManager->insert_action_group(action_group);
|
||||
|
@ -157,6 +176,20 @@ HoltContainerWindow::_on_dispose_auto()
|
|||
_holt_widget.resize_redraw();
|
||||
}
|
||||
|
||||
void
|
||||
HoltContainerWindow::_on_no_scaling()
|
||||
{
|
||||
_holt_widget.set_scaling_mode(CairoWidget::scaling_none);
|
||||
_holt_widget.resize_redraw();
|
||||
}
|
||||
|
||||
void
|
||||
HoltContainerWindow::_on_fit_scaling()
|
||||
{
|
||||
_holt_widget.set_scaling_mode(CairoWidget::scaling_min);
|
||||
_holt_widget.resize_redraw();
|
||||
}
|
||||
|
||||
void HoltContainerWindow::set_disposition()
|
||||
{
|
||||
if(_auto_dispose){
|
||||
|
|
|
@ -60,6 +60,9 @@ namespace sgpem {
|
|||
void _on_dispose_circular();
|
||||
void _on_dispose_horizontal();
|
||||
void _on_dispose_auto();
|
||||
void _on_no_scaling();
|
||||
void _on_fit_scaling();
|
||||
|
||||
|
||||
HoltWidget _holt_widget;
|
||||
bool _auto_dispose;
|
||||
|
|
|
@ -19,11 +19,15 @@
|
|||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
#include "simulation_widget.hh"
|
||||
|
||||
#include "cairo_elements.hh"
|
||||
|
||||
#include <glibmm/refptr.h>
|
||||
#include <gtkmm/action.h>
|
||||
#include <gtkmm/actiongroup.h>
|
||||
#include <gtkmm/menu.h>
|
||||
#include <gtkmm/uimanager.h>
|
||||
|
||||
#include <sgpemv2/history.hh>
|
||||
#include <sgpemv2/simulation.hh>
|
||||
#include <sgpemv2/string_utils.hh>
|
||||
|
@ -35,6 +39,8 @@
|
|||
#endif
|
||||
|
||||
using namespace sgpem;
|
||||
using namespace Gtk;
|
||||
using namespace Glib;
|
||||
|
||||
|
||||
SimulationWidget::SimulationWidget(Simulation& simulation)
|
||||
|
@ -272,7 +278,6 @@ SimulationWidget::draw_grid(cairo_t* ctx)
|
|||
// - draw right VER line
|
||||
cairo_move_to(ctx, left_graph_margin + graph_width, top_margin);
|
||||
cairo_rel_line_to(ctx, 0, graph_height);
|
||||
|
||||
}
|
||||
|
||||
cairo_stroke(ctx);
|
||||
|
@ -281,7 +286,7 @@ SimulationWidget::draw_grid(cairo_t* ctx)
|
|||
cairo_save(ctx);
|
||||
cairo_set_line_width(ctx, 0.125 * cairo_get_line_width(ctx));
|
||||
cairo_set_source_rgb(ctx, 0.3, 0.3, 0.3);
|
||||
for(double step = 2.0 + _x_unit; step < graph_width - _x_unit; step += 5 * _x_unit)
|
||||
for(double step = _x_unit; step < graph_width - _x_unit; step += 5 * _x_unit)
|
||||
{
|
||||
cairo_new_path(ctx);
|
||||
cairo_move_to(ctx, left_graph_margin + step, top_margin);
|
||||
|
@ -529,3 +534,101 @@ SimulationWidget::make_gradients()
|
|||
cairo_pattern_add_color_stop_rgb(_blocked_process_gradient, 1.0, 0.65, 0.0, 0.0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool
|
||||
SimulationWidget::on_button_press_event(GdkEventButton* event)
|
||||
{
|
||||
if((event->type & Gdk::BUTTON_PRESS) == Gdk::BUTTON_PRESS && (event->button == 3))
|
||||
{
|
||||
Glib::ustring ui_info =
|
||||
"<ui>"
|
||||
" <popup name='PopupMenu'>";
|
||||
|
||||
CairoWidget::scaling_mode scaling = get_scaling_mode();
|
||||
|
||||
RefPtr<ActionGroup> action_group = Gtk::ActionGroup::create();
|
||||
|
||||
|
||||
if(scaling!=CairoWidget::scaling_none)
|
||||
{
|
||||
action_group->add( Gtk::Action::create("ScalingNone", "_No scaling"),
|
||||
sigc::mem_fun(*this, &SimulationWidget::_on_no_scaling) );
|
||||
ui_info += " <menuitem action='ScalingNone'/>";
|
||||
}
|
||||
|
||||
if(scaling!=CairoWidget::scaling_min)
|
||||
{
|
||||
// scaling==scaling_none
|
||||
action_group->add( Gtk::Action::create("ScalingFit", "_Fit in window"),
|
||||
sigc::mem_fun(*this, &SimulationWidget::_on_fit_scaling) );
|
||||
ui_info += " <menuitem action='ScalingFit'/>";
|
||||
}
|
||||
|
||||
if(scaling!=CairoWidget::scaling_all)
|
||||
{
|
||||
// scaling==scaling_none
|
||||
action_group->add( Gtk::Action::create("ScalingStretch", "_Stretch in window"),
|
||||
sigc::mem_fun(*this, &SimulationWidget::_on_stretch_scaling) );
|
||||
ui_info += " <menuitem action='ScalingStretch'/>";
|
||||
}
|
||||
|
||||
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
|
||||
SimulationWidget::_on_no_scaling()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
std::cout << "before SimulationWidget::_on_no_scaling mode=" << get_scaling_mode() << std::endl;
|
||||
#endif
|
||||
set_scaling_mode(CairoWidget::scaling_none);
|
||||
#ifndef NDEBUG
|
||||
std::cout << "after SimulationWidget::_on_no_scaling mode=" << get_scaling_mode() << std::endl;
|
||||
#endif
|
||||
resize_redraw();
|
||||
set_size_request (20, 20); // force container redimensioning
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
SimulationWidget::_on_fit_scaling()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
std::cout << "before SimulationWidget::_on_fit_scaling mode=" << get_scaling_mode() << std::endl;
|
||||
#endif
|
||||
set_scaling_mode(CairoWidget::scaling_min);
|
||||
#ifndef NDEBUG
|
||||
std::cout << "after SimulationWidget::_on_fit_scaling mode=" << get_scaling_mode() << std::endl;
|
||||
#endif
|
||||
resize_redraw();
|
||||
set_size_request (20, 20); // force container redimensioning
|
||||
}
|
||||
|
||||
void
|
||||
SimulationWidget::_on_stretch_scaling()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
std::cout << "before SimulationWidget::_on_stretch_scaling mode=" << get_scaling_mode() << std::endl;
|
||||
#endif
|
||||
set_scaling_mode(CairoWidget::scaling_all);
|
||||
#ifndef NDEBUG
|
||||
std::cout << "after SimulationWidget::_on_stretch_scaling mode=" << get_scaling_mode() << std::endl;
|
||||
#endif
|
||||
resize_redraw();
|
||||
set_size_request (20, 20); // force container redimensioning
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace sgpem
|
|||
bool set_show_threads(bool show);
|
||||
|
||||
protected:
|
||||
//virtual bool on_button_press_event(GdkEventButton* event);
|
||||
virtual bool on_button_press_event(GdkEventButton* event);
|
||||
// void change_scaling_mode();
|
||||
|
||||
void draw_widget(cairo_t* ctx);
|
||||
|
@ -60,6 +60,10 @@ namespace sgpem
|
|||
|
||||
|
||||
private:
|
||||
void _on_no_scaling();
|
||||
void _on_fit_scaling();
|
||||
void _on_stretch_scaling();
|
||||
|
||||
Simulation* _simulation;
|
||||
bool _show_threads;
|
||||
|
||||
|
|
Loading…
Reference in New Issue