2004-09-19 14:24:53 -06:00
|
|
|
/* Copyright (C) 2004 Bart
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-03-09 06:12:44 -07:00
|
|
|
#ifndef DRAWINGAREA_VISUALDISK
|
|
|
|
#define DRAWINGAREA_VISUALDISK
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
#include "../include/Partition.h"
|
|
|
|
|
|
|
|
#include <gtkmm/drawingarea.h>
|
|
|
|
|
|
|
|
namespace GParted
|
|
|
|
{
|
|
|
|
|
2006-03-09 06:12:44 -07:00
|
|
|
class DrawingAreaVisualDisk : public Gtk::DrawingArea
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
|
|
|
public:
|
2006-03-09 06:12:44 -07:00
|
|
|
DrawingAreaVisualDisk();
|
|
|
|
~DrawingAreaVisualDisk();
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2005-12-28 09:43:06 -07:00
|
|
|
void load_partitions( const std::vector<Partition> & partitions, Sector device_length );
|
2005-12-22 15:20:55 -07:00
|
|
|
void set_selected( const Partition & partition ) ;
|
|
|
|
void clear() ;
|
|
|
|
|
2006-03-09 06:12:44 -07:00
|
|
|
//public signals for interclass communication
|
2005-12-23 17:06:05 -07:00
|
|
|
sigc::signal< void, const Partition &, bool > signal_partition_selected ;
|
|
|
|
sigc::signal< void > signal_partition_activated ;
|
|
|
|
sigc::signal< void, unsigned int, unsigned int > signal_popup_menu ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
private:
|
2005-12-22 15:20:55 -07:00
|
|
|
struct visual_partition ;
|
|
|
|
|
|
|
|
//private functions
|
|
|
|
int get_total_separator_px( const std::vector<Partition> & partitions ) ;
|
|
|
|
|
2006-03-09 06:12:44 -07:00
|
|
|
void set_static_data( const std::vector<Partition> & partitions,
|
|
|
|
std::vector<visual_partition> & visual_partitions,
|
|
|
|
Sector length ) ;
|
2005-12-22 15:20:55 -07:00
|
|
|
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_used_unused( std::vector<visual_partition> & visual_partitions ) ;
|
|
|
|
void calc_text( std::vector<visual_partition> & visual_partitions ) ;
|
|
|
|
|
2006-03-09 06:12:44 -07:00
|
|
|
void draw_partition( const visual_partition & vp ) ;
|
2005-12-22 15:20:55 -07:00
|
|
|
void draw_partitions( const std::vector<visual_partition> & visual_partitions ) ;
|
|
|
|
|
2006-03-20 03:12:55 -07:00
|
|
|
void set_selected( const std::vector<visual_partition> & visual_partitions, int x, int y ) ;
|
|
|
|
void set_selected( const std::vector<visual_partition> & visual_partitions, const Partition & partition ) ;
|
2005-12-22 15:20:55 -07:00
|
|
|
|
2006-03-02 14:55:04 -07:00
|
|
|
int spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels ) ;
|
2005-12-22 15:20:55 -07:00
|
|
|
void free_colors( std::vector<visual_partition> & visual_partitions ) ;
|
|
|
|
|
2006-03-09 06:12:44 -07:00
|
|
|
//overridden signalhandlers
|
|
|
|
void on_realize() ;
|
|
|
|
bool on_expose_event( GdkEventExpose * event ) ;
|
|
|
|
bool on_button_press_event( GdkEventButton * event ) ;
|
|
|
|
void on_size_allocate( Gtk::Allocation & allocation ) ;
|
2005-12-22 15:20:55 -07:00
|
|
|
|
|
|
|
//variables
|
|
|
|
struct visual_partition
|
|
|
|
{
|
|
|
|
double fraction ;
|
|
|
|
double fraction_used ;
|
|
|
|
|
|
|
|
int x_start, length ;
|
|
|
|
int y_start, height ;
|
|
|
|
int x_used_start, used_length ;
|
|
|
|
int x_unused_start, unused_length ;
|
|
|
|
int y_used_unused_start, used_unused_height ;
|
|
|
|
int x_text, y_text ;
|
|
|
|
|
|
|
|
Gdk::Color color ;
|
|
|
|
Glib::RefPtr<Pango::Layout> pango_layout;
|
|
|
|
|
|
|
|
//real partition
|
|
|
|
Partition partition ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2005-12-22 15:20:55 -07:00
|
|
|
std::vector<visual_partition> logicals ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2005-12-22 15:20:55 -07:00
|
|
|
visual_partition()
|
|
|
|
{
|
|
|
|
fraction = fraction_used =
|
|
|
|
x_start = length =
|
|
|
|
y_start = height =
|
|
|
|
x_used_start = used_length =
|
|
|
|
x_unused_start = unused_length =
|
|
|
|
y_used_unused_start = used_unused_height =
|
|
|
|
x_text = y_text = 0 ;
|
|
|
|
|
|
|
|
pango_layout .clear() ;
|
2005-12-28 09:43:06 -07:00
|
|
|
logicals .clear() ;
|
2005-12-22 15:20:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
~visual_partition()
|
|
|
|
{
|
|
|
|
pango_layout .clear() ;
|
|
|
|
logicals .clear() ;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<visual_partition> visual_partitions ;
|
2006-03-20 03:12:55 -07:00
|
|
|
const visual_partition * selected_vp ;
|
2005-12-22 15:20:55 -07:00
|
|
|
int TOT_SEP, MIN_SIZE ;
|
|
|
|
|
|
|
|
Glib::RefPtr<Gdk::GC> gc;
|
|
|
|
Gdk::Color color_used, color_unused, color_text;
|
2004-09-19 14:24:53 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
} //GParted
|
2006-03-09 06:12:44 -07:00
|
|
|
#endif //DRAWINGAREA_VISUALDISK
|