removed the frame from the visualdiskwidget and changed some visual

* include/DrawingAreaVisualDisk.h,
  include/Makefile.am,
  include/Win_GParted.h
  src/DrawingAreaVisualDisk.cc,
  src/Makefile.am
  src/Win_GParted.cc: removed the frame from the visualdiskwidget and
  changed some visual details. Also changed visual representation of
  selected partition. The latter might be considered as a work in
  progress.
* include/FrameVisualDisk.h,
  src/FrameVisualDisk.cc: Removed.
This commit is contained in:
Bart Hakvoort 2006-03-09 13:12:44 +00:00
parent 4f84cff781
commit 8777cbd125
7 changed files with 260 additions and 168 deletions

View File

@ -1,3 +1,17 @@
2006-03-09 Bart Hakvoort <hakvoort@cvs.gnome.org>
* include/DrawingAreaVisualDisk.h,
include/Makefile.am,
include/Win_GParted.h
src/DrawingAreaVisualDisk.cc,
src/Makefile.am
src/Win_GParted.cc: removed the frame from the visualdiskwidget and
changed some visual details. Also changed visual representation of
selected partition. The latter might be considered as a work in
progress.
* include/FrameVisualDisk.h,
src/FrameVisualDisk.cc: Removed.
2006-03-07 Bart Hakvoort <hakvoort@cvs.gnome.org> 2006-03-07 Bart Hakvoort <hakvoort@cvs.gnome.org>
* src/Dialog_Partition_Copy.cc, * src/Dialog_Partition_Copy.cc,

View File

@ -15,29 +15,27 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#ifndef FRAME_VISUALDISK #ifndef DRAWINGAREA_VISUALDISK
#define FRAME_VISUALDISK #define DRAWINGAREA_VISUALDISK
#include "../include/Partition.h" #include "../include/Partition.h"
#include <gtkmm/frame.h>
#include <gtkmm/drawingarea.h> #include <gtkmm/drawingarea.h>
namespace GParted namespace GParted
{ {
class FrameVisualDisk : public Gtk::Frame class DrawingAreaVisualDisk : public Gtk::DrawingArea
{ {
public: public:
FrameVisualDisk(); DrawingAreaVisualDisk();
~FrameVisualDisk(); ~DrawingAreaVisualDisk();
void load_partitions( const std::vector<Partition> & partitions, Sector device_length ); void load_partitions( const std::vector<Partition> & partitions, Sector device_length );
void set_selected( const Partition & partition ) ; void set_selected( const Partition & partition ) ;
void clear() ; void clear() ;
//public signal for interclass communication //public signals for interclass communication
sigc::signal< void, const Partition &, bool > signal_partition_selected ; sigc::signal< void, const Partition &, bool > signal_partition_selected ;
sigc::signal< void > signal_partition_activated ; sigc::signal< void > signal_partition_activated ;
sigc::signal< void, unsigned int, unsigned int > signal_popup_menu ; sigc::signal< void, unsigned int, unsigned int > signal_popup_menu ;
@ -48,12 +46,16 @@ private:
//private functions //private functions
int get_total_separator_px( const std::vector<Partition> & partitions ) ; int get_total_separator_px( const std::vector<Partition> & partitions ) ;
void set_static_data( const std::vector<Partition> & partitions, std::vector<visual_partition> & visual_partitions, Sector length ) ; void set_static_data( const std::vector<Partition> & partitions,
std::vector<visual_partition> & visual_partitions,
Sector length ) ;
int calc_length( std::vector<visual_partition> & visual_partitions, int length_px ) ; int calc_length( std::vector<visual_partition> & visual_partitions, int length_px ) ;
void calc_position_and_height( std::vector<visual_partition> & visual_partitions, int start, int border ) ; void calc_position_and_height( std::vector<visual_partition> & visual_partitions, int start, int border ) ;
void calc_used_unused( std::vector<visual_partition> & visual_partitions ) ; void calc_used_unused( std::vector<visual_partition> & visual_partitions ) ;
void calc_text( std::vector<visual_partition> & visual_partitions ) ; void calc_text( std::vector<visual_partition> & visual_partitions ) ;
void draw_partition( const visual_partition & vp ) ;
void draw_selection_effects( const visual_partition & vp ) ;
void draw_partitions( const std::vector<visual_partition> & visual_partitions ) ; void draw_partitions( const std::vector<visual_partition> & visual_partitions ) ;
bool set_selected( std::vector<visual_partition> & visual_partitions, int x, int y ) ; bool set_selected( std::vector<visual_partition> & visual_partitions, int x, int y ) ;
@ -62,11 +64,11 @@ private:
int spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels ) ; int spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels ) ;
void free_colors( std::vector<visual_partition> & visual_partitions ) ; void free_colors( std::vector<visual_partition> & visual_partitions ) ;
//signalhandlers //overridden signalhandlers
void drawingarea_on_realize(); void on_realize() ;
bool drawingarea_on_expose( GdkEventExpose * event ); bool on_expose_event( GdkEventExpose * event ) ;
bool on_drawingarea_button_press( GdkEventButton * event ); bool on_button_press_event( GdkEventButton * event ) ;
void on_resize( Gtk::Allocation & allocation ) ; void on_size_allocate( Gtk::Allocation & allocation ) ;
//variables //variables
struct visual_partition struct visual_partition
@ -118,10 +120,9 @@ private:
visual_partition selected_vp ; visual_partition selected_vp ;
int TOT_SEP, MIN_SIZE ; int TOT_SEP, MIN_SIZE ;
Gtk::DrawingArea drawingarea;
Glib::RefPtr<Gdk::GC> gc; Glib::RefPtr<Gdk::GC> gc;
Gdk::Color color_used, color_unused, color_text; Gdk::Color color_used, color_unused, color_text;
}; };
} //GParted } //GParted
#endif //FRAME_VISUALDISK #endif //DRAWINGAREA_VISUALDISK

View File

@ -7,7 +7,7 @@ EXTRA_DIST = \
Frame_Resizer_Base.h\ Frame_Resizer_Base.h\
i18n.h\ i18n.h\
Partition.h \ Partition.h \
FrameVisualDisk.h \ DrawingAreaVisualDisk.h \
Dialog_Partition_Info.h\ Dialog_Partition_Info.h\
ext3.h \ ext3.h \
Frame_Resizer_Extended.h\ Frame_Resizer_Extended.h\

View File

@ -19,7 +19,7 @@
#define WIN_GPARTED #define WIN_GPARTED
#include "../include/Device.h" #include "../include/Device.h"
#include "../include/FrameVisualDisk.h" #include "../include/DrawingAreaVisualDisk.h"
#include "../include/Partition.h" #include "../include/Partition.h"
#include "../include/TreeView_Detail.h" #include "../include/TreeView_Detail.h"
#include "../include/Operation.h" #include "../include/Operation.h"
@ -182,7 +182,7 @@ private:
Gtk::ProgressBar pulsebar ; Gtk::ProgressBar pulsebar ;
Gtk::TreeRow treerow; Gtk::TreeRow treerow;
FrameVisualDisk frame_visualdisk; DrawingAreaVisualDisk drawingarea_visualdisk ;
TreeView_Detail treeview_detail; TreeView_Detail treeview_detail;
//device combo //device combo

View File

@ -15,20 +15,19 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../include/FrameVisualDisk.h" #include "../include/DrawingAreaVisualDisk.h"
#define BORDER 8 #define MAIN_BORDER 5
#define BORDER 6
#define SEP 5 #define SEP 5
#define HEIGHT 70 #define HEIGHT 70 + 2 * MAIN_BORDER
#define SHADOW 4
namespace GParted namespace GParted
{ {
FrameVisualDisk::FrameVisualDisk() DrawingAreaVisualDisk::DrawingAreaVisualDisk()
{ {
this ->set_border_width( 5 ) ;
this ->set_shadow_type( Gtk::SHADOW_ETCHED_OUT ) ;
//set and allocated some standard colors //set and allocated some standard colors
color_used .set( Utils::Get_Color( GParted::FS_USED ) ); color_used .set( Utils::Get_Color( GParted::FS_USED ) );
this ->get_colormap() ->alloc_color( color_used ) ; this ->get_colormap() ->alloc_color( color_used ) ;
@ -39,44 +38,37 @@ FrameVisualDisk::FrameVisualDisk()
color_text .set( "black" ); color_text .set( "black" );
this ->get_colormap() ->alloc_color( color_text ) ; this ->get_colormap() ->alloc_color( color_text ) ;
//prepare drawingarea and frame and pack them set_events( Gdk::BUTTON_PRESS_MASK );
drawingarea .set_events( Gdk::BUTTON_PRESS_MASK );
drawingarea .signal_realize() .connect( sigc::mem_fun(*this, &FrameVisualDisk::drawingarea_on_realize) ) ; set_size_request( -1, HEIGHT ) ;
drawingarea .signal_expose_event() .connect( sigc::mem_fun(*this, &FrameVisualDisk::drawingarea_on_expose) ) ;
drawingarea .signal_button_press_event() .connect( sigc::mem_fun( *this, &FrameVisualDisk::on_drawingarea_button_press) ) ;
drawingarea .set_size_request( -1, HEIGHT ) ;
this ->add( drawingarea ) ;
} }
void FrameVisualDisk::load_partitions( const std::vector<Partition> & partitions, Sector device_length ) void DrawingAreaVisualDisk::load_partitions( const std::vector<Partition> & partitions, Sector device_length )
{ {
clear() ; clear() ;
TOT_SEP = get_total_separator_px( partitions ) ; TOT_SEP = get_total_separator_px( partitions ) ;
set_static_data( partitions, visual_partitions, device_length ) ; set_static_data( partitions, visual_partitions, device_length ) ;
drawingarea .queue_resize() ; queue_resize() ;
} }
void FrameVisualDisk::set_selected( const Partition & partition ) void DrawingAreaVisualDisk::set_selected( const Partition & partition )
{ {
set_selected( visual_partitions, partition ) ; set_selected( visual_partitions, partition ) ;
draw_partitions( visual_partitions ) ; queue_draw() ;
} }
void FrameVisualDisk::clear() void DrawingAreaVisualDisk::clear()
{ {
free_colors( visual_partitions ) ; free_colors( visual_partitions ) ;
visual_partitions .clear() ; visual_partitions .clear() ;
drawingarea .queue_resize() ; queue_resize() ;
} }
int FrameVisualDisk::get_total_separator_px( const std::vector<Partition> & partitions ) int DrawingAreaVisualDisk::get_total_separator_px( const std::vector<Partition> & partitions )
{ {
for ( unsigned int t = 0 ; t < partitions .size() ; t++ ) for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
if ( partitions[ t ] .type == GParted::TYPE_EXTENDED ) if ( partitions[ t ] .type == GParted::TYPE_EXTENDED )
@ -86,7 +78,9 @@ int FrameVisualDisk::get_total_separator_px( const std::vector<Partition> & part
return ( partitions .size() -1 ) * SEP ; return ( partitions .size() -1 ) * SEP ;
} }
void FrameVisualDisk::set_static_data( const std::vector<Partition> & partitions, std::vector<visual_partition> & visual_partitions, Sector length ) void DrawingAreaVisualDisk::set_static_data( const std::vector<Partition> & partitions,
std::vector<visual_partition> & visual_partitions,
Sector length )
{ {
Sector p_length ; Sector p_length ;
visual_partition vp ; visual_partition vp ;
@ -103,7 +97,8 @@ void FrameVisualDisk::set_static_data( const std::vector<Partition> & partitions
if ( partitions[ t ] .type == GParted::TYPE_UNALLOCATED || partitions[ t ] .type == GParted::TYPE_EXTENDED ) if ( partitions[ t ] .type == GParted::TYPE_UNALLOCATED || partitions[ t ] .type == GParted::TYPE_EXTENDED )
visual_partitions .back() .fraction_used = -1 ; visual_partitions .back() .fraction_used = -1 ;
else if ( partitions[ t ] .sectors_used > 0 ) else if ( partitions[ t ] .sectors_used > 0 )
visual_partitions .back() .fraction_used = partitions[ t ] .sectors_used / static_cast<double>( p_length ) ; visual_partitions .back() .fraction_used =
partitions[ t ] .sectors_used / static_cast<double>( p_length ) ;
visual_partitions .back() .color = partitions[ t ] .color; visual_partitions .back() .color = partitions[ t ] .color;
this ->get_colormap() ->alloc_color( visual_partitions .back() .color ); this ->get_colormap() ->alloc_color( visual_partitions .back() .color );
@ -113,12 +108,12 @@ void FrameVisualDisk::set_static_data( const std::vector<Partition> & partitions
visual_partitions .back() .logicals, visual_partitions .back() .logicals,
partitions[ t ] .sector_end - partitions[ t ] .sector_start ) ; partitions[ t ] .sector_end - partitions[ t ] .sector_start ) ;
else else
visual_partitions .back() .pango_layout = drawingarea .create_pango_layout( visual_partitions .back() .pango_layout = create_pango_layout(
partitions[ t ] .partition + "\n" + Utils::format_size( partitions[ t ] .get_length() ) ) ; partitions[ t ] .partition + "\n" + Utils::format_size( partitions[ t ] .get_length() ) ) ;
} }
} }
int FrameVisualDisk::calc_length( std::vector<visual_partition> & visual_partitions, int length_px ) int DrawingAreaVisualDisk::calc_length( std::vector<visual_partition> & visual_partitions, int length_px )
{ {
int calced_length = 0 ; int calced_length = 0 ;
@ -128,7 +123,8 @@ int FrameVisualDisk::calc_length( std::vector<visual_partition> & visual_partiti
if ( visual_partitions[ t ] .logicals .size() > 0 ) if ( visual_partitions[ t ] .logicals .size() > 0 )
visual_partitions[ t ] .length = visual_partitions[ t ] .length =
calc_length( visual_partitions[ t ] .logicals, visual_partitions[ t ] .length - (2 * BORDER) ) + (2 * BORDER) ; calc_length( visual_partitions[ t ] .logicals,
visual_partitions[ t ] .length - (2 * BORDER) ) + (2 * BORDER) ;
else if ( visual_partitions[ t ] .length < MIN_SIZE ) else if ( visual_partitions[ t ] .length < MIN_SIZE )
visual_partitions[ t ] .length = MIN_SIZE ; visual_partitions[ t ] .length = MIN_SIZE ;
@ -138,7 +134,9 @@ int FrameVisualDisk::calc_length( std::vector<visual_partition> & visual_partiti
return calced_length + (visual_partitions .size() - 1) * SEP ; return calced_length + (visual_partitions .size() - 1) * SEP ;
} }
void FrameVisualDisk::calc_position_and_height( std::vector<visual_partition> & visual_partitions, int start, int border ) void DrawingAreaVisualDisk::calc_position_and_height( std::vector<visual_partition> & visual_partitions,
int start,
int border )
{ {
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ ) for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
{ {
@ -149,13 +147,13 @@ void FrameVisualDisk::calc_position_and_height( std::vector<visual_partition> &
if ( visual_partitions[ t ] .logicals .size() > 0 ) if ( visual_partitions[ t ] .logicals .size() > 0 )
calc_position_and_height( visual_partitions[ t ] .logicals, calc_position_and_height( visual_partitions[ t ] .logicals,
visual_partitions[ t ] .x_start + BORDER, visual_partitions[ t ] .x_start + BORDER,
BORDER ) ; visual_partitions[ t ] .y_start + BORDER ) ;
start += visual_partitions[ t ] .length + SEP ; start += visual_partitions[ t ] .length + SEP ;
} }
} }
void FrameVisualDisk::calc_used_unused( std::vector<visual_partition> & visual_partitions ) void DrawingAreaVisualDisk::calc_used_unused( std::vector<visual_partition> & visual_partitions )
{ {
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ ) for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
{ {
@ -169,9 +167,10 @@ void FrameVisualDisk::calc_used_unused( std::vector<visual_partition> & visual_p
Utils::Round( ( visual_partitions[ t ] .length - (2*BORDER) ) * visual_partitions[ t ] .fraction_used ) ; Utils::Round( ( visual_partitions[ t ] .length - (2*BORDER) ) * visual_partitions[ t ] .fraction_used ) ;
//unused //unused
visual_partitions[ t ] .x_unused_start = visual_partitions[ t ] .x_used_start + visual_partitions[ t ] .used_length ; visual_partitions[ t ] .x_unused_start =
visual_partitions[ t ] .unused_length visual_partitions[ t ] .x_used_start + visual_partitions[ t ] .used_length ;
= visual_partitions[ t ] .length - (2 * BORDER) - visual_partitions[ t ] .used_length ; visual_partitions[ t ] .unused_length =
visual_partitions[ t ] .length - (2 * BORDER) - visual_partitions[ t ] .used_length ;
//y position and height //y position and height
visual_partitions[ t ] .y_used_unused_start = visual_partitions[ t ] .y_start + BORDER ; visual_partitions[ t ] .y_used_unused_start = visual_partitions[ t ] .y_start + BORDER ;
@ -183,7 +182,7 @@ void FrameVisualDisk::calc_used_unused( std::vector<visual_partition> & visual_p
} }
} }
void FrameVisualDisk::calc_text( std::vector<visual_partition> & visual_partitions ) void DrawingAreaVisualDisk::calc_text( std::vector<visual_partition> & visual_partitions )
{ {
int length, height ; int length, height ;
@ -210,87 +209,157 @@ void FrameVisualDisk::calc_text( std::vector<visual_partition> & visual_partitio
} }
} }
void FrameVisualDisk::draw_partitions( const std::vector<visual_partition> & visual_partitions ) void DrawingAreaVisualDisk::draw_partition( const visual_partition & vp )
{
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
{ {
//partition... //partition...
gc ->set_foreground( visual_partitions[ t ] .color ); gc ->set_foreground( vp .color );
drawingarea .get_window() ->draw_rectangle( gc, get_window() ->draw_rectangle( gc,
true, true,
visual_partitions[ t ] .x_start, vp .x_start,
visual_partitions[ t ] .y_start, vp .y_start,
visual_partitions[ t ] .length, vp .length,
visual_partitions[ t ] .height ); vp .height );
//used.. //used..
if ( visual_partitions[ t ] .used_length > 0 ) if ( vp .used_length > 0 )
{ {
gc ->set_foreground( color_used ); gc ->set_foreground( color_used );
drawingarea .get_window() ->draw_rectangle( gc, get_window() ->draw_rectangle( gc,
true, true,
visual_partitions[ t ] .x_used_start, vp .x_used_start,
visual_partitions[ t ] .y_used_unused_start, vp .y_used_unused_start,
visual_partitions[ t ] .used_length, vp .used_length,
visual_partitions[ t ] .used_unused_height ); vp .used_unused_height );
} }
//unused //unused
if ( visual_partitions[ t ] .unused_length > 0 ) if ( vp .unused_length > 0 )
{ {
gc ->set_foreground( color_unused ); gc ->set_foreground( color_unused );
drawingarea .get_window() ->draw_rectangle( gc, get_window() ->draw_rectangle( gc,
true, true,
visual_partitions[ t ] .x_unused_start, vp .x_unused_start,
visual_partitions[ t ] .y_used_unused_start, vp .y_used_unused_start,
visual_partitions[ t ] .unused_length, vp .unused_length,
visual_partitions[ t ] .used_unused_height ); vp .used_unused_height );
} }
//text //text
if ( visual_partitions[ t ] .x_text > 0 ) if ( vp .x_text > 0 )
{ {
gc ->set_foreground( color_text ); gc ->set_foreground( color_text );
drawingarea .get_window() ->draw_layout( gc, get_window() ->draw_layout( gc,
visual_partitions[ t ] .x_text, vp .x_text,
visual_partitions[ t ] .y_text, vp .y_text,
visual_partitions[ t ] .pango_layout ) ; vp .pango_layout ) ;
}
} }
//selection rectangle... void DrawingAreaVisualDisk::draw_selection_effects( const visual_partition & vp )
if ( visual_partitions[ t ] .selected )
{ {
gc ->set_foreground( color_used ); gc ->set_foreground( color_text );
//selection start and ends at 4px from the borders, hence the >8 restriction
if ( visual_partitions[ t ] .length > 8 ) //bottom shadow
drawingarea .get_window() ->draw_rectangle( gc, get_window() ->draw_rectangle( gc,
false,
visual_partitions[ t ] .x_start +4,
visual_partitions[ t ] .y_start +4,
visual_partitions[ t ] .length -9,
visual_partitions[ t ] .height -9 );
else
drawingarea .get_window() ->draw_rectangle( gc,
true, true,
visual_partitions[ t ] .x_start, vp .x_start + SHADOW,
visual_partitions[ t ] .y_start +9, vp .y_start + vp .height,
visual_partitions[ t ] .length, vp .length,
visual_partitions[ t ] .height -19 ); SHADOW ) ;
//righthand shadow
get_window() ->draw_rectangle( gc,
true,
vp .x_start + vp .length,
vp .y_start + SHADOW,
SHADOW,
vp .height ) ;
//if selected contains logicals we need to add more shadows and color
if ( vp .logicals .size() > 0 )
{
//inner shadows
for ( unsigned int t = 0 ; t < vp .logicals .size() ; t++ )
{
//top shadows
get_window() ->draw_rectangle( gc,
true,
vp .logicals[ t ] .x_start - SHADOW,
vp .logicals[ t ] .y_start - SHADOW,
vp .logicals[ t ] .length,
SHADOW ) ;
//lefthand shadows
get_window() ->draw_rectangle( gc,
true,
vp .logicals[ t ] .x_start - SHADOW,
vp .logicals[ t ] .y_start,
SHADOW,
vp .logicals[ t ] .height - SHADOW ) ;
} }
if ( visual_partitions[ t ] .logicals .size() > 0 ) //create extra 'extended' to create the illusion of floating above the logicals
draw_partitions( visual_partitions[ t ] .logicals ) ; gc ->set_foreground( vp .color );
//bottomline..
get_window() ->draw_rectangle( gc,
true,
vp .x_start + BORDER + SHADOW,
vp .y_start + vp .height - BORDER,
vp .length - BORDER * 2,
SHADOW ) ;
//small rectangles on the righthandside of each logical..
for ( unsigned int t = 0 ; t < vp .logicals .size() ; t++ )
get_window() ->draw_rectangle( gc,
true,
vp .logicals[ t ] .x_start + vp .logicals[ t ] .length - SHADOW,
vp .logicals[ t ] .y_start,
SHADOW,
vp .logicals[ t ] .height - SHADOW ) ;
} }
} }
bool FrameVisualDisk::set_selected( std::vector<visual_partition> & visual_partitions, int x, int y ) void DrawingAreaVisualDisk::draw_partitions( const std::vector<visual_partition> & visual_partitions )
{
visual_partition vp ;
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
{
vp = visual_partitions[ t ] ;
if ( vp .selected )
{
vp .x_start -= SHADOW ;
vp .y_start -= SHADOW ;
vp .x_used_start -= SHADOW ;
vp .x_unused_start -= SHADOW ;
vp .y_used_unused_start -= SHADOW ;
vp .x_text -= SHADOW ;
vp .y_text -= SHADOW ;
}
draw_partition( vp ) ;
if ( vp .logicals .size() > 0 )
draw_partitions( vp .logicals ) ;
if ( vp .selected )
draw_selection_effects( vp ) ;
}
}
bool DrawingAreaVisualDisk::set_selected( std::vector<visual_partition> & visual_partitions, int x, int y )
{ {
bool found = false ; bool found = false ;
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ ) for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
{ {
if ( visual_partitions[ t ] .x_start <= x && x < visual_partitions[ t ] .x_start + visual_partitions[ t ] .length && if ( visual_partitions[ t ] .x_start <= x &&
visual_partitions[ t ] .y_start <= y && y < visual_partitions[ t ] .y_start + visual_partitions[ t ] .height ) x < visual_partitions[ t ] .x_start + visual_partitions[ t ] .length &&
visual_partitions[ t ] .y_start <= y &&
y < visual_partitions[ t ] .y_start + visual_partitions[ t ] .height )
{ {
visual_partitions[ t ] .selected = true ; visual_partitions[ t ] .selected = true ;
selected_vp = visual_partitions[ t ] ; selected_vp = visual_partitions[ t ] ;
@ -306,7 +375,7 @@ bool FrameVisualDisk::set_selected( std::vector<visual_partition> & visual_parti
return found ; return found ;
} }
void FrameVisualDisk::set_selected( std::vector<visual_partition> & visual_partitions, const Partition & partition ) void DrawingAreaVisualDisk::set_selected( std::vector<visual_partition> & visual_partitions, const Partition & partition )
{ {
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ ) for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
{ {
@ -323,25 +392,28 @@ void FrameVisualDisk::set_selected( std::vector<visual_partition> & visual_parti
} }
} }
void FrameVisualDisk::drawingarea_on_realize() void DrawingAreaVisualDisk::on_realize()
{ {
gc = Gdk::GC::create( drawingarea .get_window() ); Gtk::DrawingArea::on_realize() ;
//connect here to prevent premature signalling (only relevant at startup) gc = Gdk::GC::create( get_window() );
drawingarea .signal_size_allocate() .connect( sigc::mem_fun( *this, &FrameVisualDisk::on_resize ) ) ;
} }
bool FrameVisualDisk::drawingarea_on_expose( GdkEventExpose * event ) bool DrawingAreaVisualDisk::on_expose_event( GdkEventExpose * event )
{ {
bool ret_val = Gtk::DrawingArea::on_expose_event( event ) ;
draw_partitions( visual_partitions ) ; draw_partitions( visual_partitions ) ;
return true ; return ret_val ;
} }
bool FrameVisualDisk::on_drawingarea_button_press( GdkEventButton * event ) bool DrawingAreaVisualDisk::on_button_press_event( GdkEventButton * event )
{ {
bool ret_val = Gtk::DrawingArea::on_button_press_event( event ) ;
set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) ; set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) ;
draw_partitions( visual_partitions ) ; queue_draw() ;
signal_partition_selected .emit( selected_vp .partition, false ) ; signal_partition_selected .emit( selected_vp .partition, false ) ;
@ -350,45 +422,50 @@ bool FrameVisualDisk::on_drawingarea_button_press( GdkEventButton * event )
else if ( event ->button == 3 ) else if ( event ->button == 3 )
signal_popup_menu .emit( event ->button, event ->time ) ; signal_popup_menu .emit( event ->button, event ->time ) ;
return true ; return ret_val ;
} }
void FrameVisualDisk::on_resize( Gtk::Allocation & allocation ) void DrawingAreaVisualDisk::on_size_allocate( Gtk::Allocation & allocation )
{ {
Gtk::DrawingArea::on_size_allocate( allocation ) ;
MIN_SIZE = 20 ; MIN_SIZE = 20 ;
int calced = 0, TOTAL ; int available_size = allocation .get_width() - (2 * MAIN_BORDER),
calced = 0,
px_left ;
do do
{ {
TOTAL = allocation .get_width() - TOT_SEP ; px_left = available_size - TOT_SEP ;
calced = allocation .get_width() ; //for first time :) calced = available_size ; //for first time :)
do do
{ {
TOTAL -= ( calced - allocation .get_width() ) ; px_left -= ( calced - available_size ) ;
calced = calc_length( visual_partitions, TOTAL ) ; calced = calc_length( visual_partitions, px_left ) ;
} }
while ( calced > allocation .get_width() && TOTAL > 0 ) ; while ( calced > available_size && px_left > 0 ) ;
MIN_SIZE-- ; MIN_SIZE-- ;
} }
while ( TOTAL <= 0 && MIN_SIZE > 0 ) ; while ( px_left <= 0 && MIN_SIZE > 0 ) ;
//due to rounding a few px may be lost. here we salvage them.. //due to rounding a few px may be lost. here we salvage them..
if ( visual_partitions .size() && calced > 0 ) if ( visual_partitions .size() && calced > 0 )
{ {
int px_left = allocation .get_width() - calced ; px_left = available_size - calced ;
while ( px_left > 0 ) while ( px_left > 0 )
px_left = spreadout_leftover_px( visual_partitions, px_left ) ; px_left = spreadout_leftover_px( visual_partitions, px_left ) ;
} }
//and calculate the rest.. //and calculate the rest..
calc_position_and_height( visual_partitions, 0, 0 ) ; calc_position_and_height( visual_partitions, MAIN_BORDER, MAIN_BORDER ) ;//0, 0 ) ;
calc_used_unused( visual_partitions ) ; calc_used_unused( visual_partitions ) ;
calc_text( visual_partitions ) ; calc_text( visual_partitions ) ;
} }
int FrameVisualDisk::spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels ) int DrawingAreaVisualDisk::spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels )
{ {
int extended = -1 ; int extended = -1 ;
@ -411,7 +488,7 @@ int FrameVisualDisk::spreadout_leftover_px( std::vector<visual_partition> & visu
return pixels ; return pixels ;
} }
void FrameVisualDisk::free_colors( std::vector<visual_partition> & visual_partitions ) void DrawingAreaVisualDisk::free_colors( std::vector<visual_partition> & visual_partitions )
{ {
for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ ) for ( unsigned int t = 0 ; t < visual_partitions .size() ; t++ )
{ {
@ -422,7 +499,7 @@ void FrameVisualDisk::free_colors( std::vector<visual_partition> & visual_partit
} }
} }
FrameVisualDisk::~FrameVisualDisk() DrawingAreaVisualDisk::~DrawingAreaVisualDisk()
{ {
clear() ; clear() ;

View File

@ -19,6 +19,7 @@ gparted_SOURCES = \
Dialog_Partition_New.cc\ Dialog_Partition_New.cc\
Dialog_Partition_Resize_Move.cc\ Dialog_Partition_Resize_Move.cc\
Dialog_Progress.cc\ Dialog_Progress.cc\
DrawingAreaVisualDisk.cc\
FileSystem.cc\ FileSystem.cc\
Frame_Resizer_Base.cc\ Frame_Resizer_Base.cc\
Frame_Resizer_Extended.cc\ Frame_Resizer_Extended.cc\
@ -27,7 +28,6 @@ gparted_SOURCES = \
Partition.cc\ Partition.cc\
TreeView_Detail.cc\ TreeView_Detail.cc\
Utils.cc\ Utils.cc\
FrameVisualDisk.cc\
Win_GParted.cc\ Win_GParted.cc\
ext2.cc\ ext2.cc\
ext3.cc\ ext3.cc\

View File

@ -68,14 +68,14 @@ Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices )
init_toolbar() ; init_toolbar() ;
vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK ); vbox_main.pack_start( hbox_toolbar, Gtk::PACK_SHRINK );
//frame_visualdisk... ( contains the visual represenation of the disks ) //drawingarea_visualdisk... ( contains the visual represenation of the disks )
frame_visualdisk .signal_partition_selected .connect( drawingarea_visualdisk .signal_partition_selected .connect(
sigc::mem_fun( this, &Win_GParted::on_partition_selected ) ) ; sigc::mem_fun( this, &Win_GParted::on_partition_selected ) ) ;
frame_visualdisk .signal_partition_activated .connect( drawingarea_visualdisk .signal_partition_activated .connect(
sigc::mem_fun( this, &Win_GParted::on_partition_activated ) ) ; sigc::mem_fun( this, &Win_GParted::on_partition_activated ) ) ;
frame_visualdisk .signal_popup_menu .connect( drawingarea_visualdisk .signal_popup_menu .connect(
sigc::mem_fun( this, &Win_GParted::on_partition_popup_menu ) ); sigc::mem_fun( this, &Win_GParted::on_partition_popup_menu ) );
vbox_main .pack_start( frame_visualdisk, Gtk::PACK_SHRINK ) ; vbox_main .pack_start( drawingarea_visualdisk, Gtk::PACK_SHRINK ) ;
//hpaned_main (NOTE: added to vpaned_main) //hpaned_main (NOTE: added to vpaned_main)
init_hpaned_main() ; init_hpaned_main() ;
@ -475,7 +475,7 @@ void Win_GParted::show_pulsebar( const Glib::ustring & status_message )
combo_devices .set_sensitive( false ) ; combo_devices .set_sensitive( false ) ;
menu_partition .set_sensitive( false ) ; menu_partition .set_sensitive( false ) ;
treeview_detail .set_sensitive( false ) ; treeview_detail .set_sensitive( false ) ;
frame_visualdisk .set_sensitive( false ) ; drawingarea_visualdisk .set_sensitive( false ) ;
//the actual 'pulsing' //the actual 'pulsing'
while ( pulse ) while ( pulse )
@ -498,7 +498,7 @@ void Win_GParted::show_pulsebar( const Glib::ustring & status_message )
combo_devices .set_sensitive( true ) ; combo_devices .set_sensitive( true ) ;
menu_partition .set_sensitive( true ) ; menu_partition .set_sensitive( true ) ;
treeview_detail .set_sensitive( true ) ; treeview_detail .set_sensitive( true ) ;
frame_visualdisk .set_sensitive( true ) ; drawingarea_visualdisk .set_sensitive( true ) ;
} }
void Win_GParted::Fill_Label_Device_Info( bool clear ) void Win_GParted::Fill_Label_Device_Info( bool clear )
@ -629,7 +629,7 @@ void Win_GParted::Refresh_Visual()
} }
//frame visualdisk //frame visualdisk
frame_visualdisk .load_partitions( partitions, devices[ current_device ] .length ) ; drawingarea_visualdisk .load_partitions( partitions, devices[ current_device ] .length ) ;
//treeview details //treeview details
treeview_detail .load_partitions( partitions ) ; treeview_detail .load_partitions( partitions ) ;
@ -905,12 +905,12 @@ void Win_GParted::menu_gparted_refresh_devices( )
menubar_main .items()[ 3 ] .set_sensitive( false ) ; menubar_main .items()[ 3 ] .set_sensitive( false ) ;
menubar_main .items()[ 4 ] .set_sensitive( false ) ; menubar_main .items()[ 4 ] .set_sensitive( false ) ;
toolbar_main .set_sensitive( false ) ; toolbar_main .set_sensitive( false ) ;
frame_visualdisk .set_sensitive( false ) ; drawingarea_visualdisk .set_sensitive( false ) ;
treeview_detail .set_sensitive( false ) ; treeview_detail .set_sensitive( false ) ;
Fill_Label_Device_Info( true ) ; Fill_Label_Device_Info( true ) ;
frame_visualdisk .clear() ; drawingarea_visualdisk .clear() ;
treeview_detail .clear() ; treeview_detail .clear() ;
//hmzz, this is really paranoid, but i think it's the right thing to do ;) //hmzz, this is really paranoid, but i think it's the right thing to do ;)
@ -932,7 +932,7 @@ void Win_GParted::menu_gparted_refresh_devices( )
menubar_main .items()[ 4 ] .set_sensitive( true ) ; menubar_main .items()[ 4 ] .set_sensitive( true ) ;
toolbar_main .set_sensitive( true ) ; toolbar_main .set_sensitive( true ) ;
frame_visualdisk .set_sensitive( true ) ; drawingarea_visualdisk .set_sensitive( true ) ;
treeview_detail .set_sensitive( true ) ; treeview_detail .set_sensitive( true ) ;
refresh_combo_devices() ; refresh_combo_devices() ;
@ -1053,7 +1053,7 @@ void Win_GParted::on_partition_selected( const Partition & partition, bool src_i
set_valid_operations() ; set_valid_operations() ;
if ( src_is_treeview ) if ( src_is_treeview )
frame_visualdisk .set_selected( partition ) ; drawingarea_visualdisk .set_selected( partition ) ;
else else
treeview_detail .set_selected( partition ) ; treeview_detail .set_selected( partition ) ;
} }