1/* 2* Copyright (c) 2018 (https://github.com/phase1geo/Minder) 3* 4* This program is free software; you can redistribute it and/or 5* modify it under the terms of the GNU General Public 6* License as published by the Free Software Foundation; either 7* version 2 of the License, or (at your option) any later version. 8* 9* This program is distributed in the hope that it will be useful, 10* but WITHOUT ANY WARRANTY; without even the implied warranty of 11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12* General Public License for more details. 13* 14* You should have received a copy of the GNU General Public 15* License along with this program; if not, write to the 16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17* Boston, MA 02110-1301 USA 18* 19* Authored by: Trevor Williams <phase1geo@gmail.com> 20*/ 21 22using Gtk; 23 24public class UndoStyleLinkWidth : UndoStyleChange { 25 26 private GenericArray<int> _values; 27 28 /* Constructor for a node name change */ 29 public UndoStyleLinkWidth( StyleAffects affects, int link_width, DrawArea da ) { 30 base( affects, da ); 31 _values = new GenericArray<int>(); 32 _values.add( link_width ); 33 load_styles( da ); 34 } 35 36 protected override void load_style_value( Style style ) { 37 _values.add( style.link_width ); 38 } 39 40 protected override void store_style_value( Style style, int index ) { 41 style.link_width = _values.get( index ); 42 } 43 44 protected override void replace_with_item( UndoItem item ) { 45 _values.set( 0, ((UndoStyleLinkWidth)item)._values.get( 0 ) ); 46 } 47 48 protected override string to_string() { 49 string[] sa = new string[_values.length]; 50 for( int i=0; i<_values.length; i++ ) { 51 sa[i] = _values.get( i ).to_string(); 52 } 53 return( base.to_string() + ", lwidth: %s".printf( string.joinv( ",", sa ) ) ); 54 } 55 56} 57