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
|
2014-01-23 03:59:48 -07:00
|
|
|
* GNU General Public License for more details.
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-23 03:59:48 -07:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2004-09-19 14:24:53 -06:00
|
|
|
*/
|
|
|
|
|
2013-05-27 05:20:16 -06:00
|
|
|
#ifndef GPARTED_DRAWINGAREAVISUALDISK_H
|
|
|
|
#define GPARTED_DRAWINGAREAVISUALDISK_H
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2016-10-18 16:45:28 -06:00
|
|
|
#include "Partition.h"
|
|
|
|
#include "PartitionVector.h"
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
#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();
|
2015-05-23 13:22:37 -06:00
|
|
|
|
|
|
|
void load_partitions( const PartitionVector & partitions, Sector device_length );
|
2015-05-16 10:06:22 -06:00
|
|
|
void set_selected( const Partition * partition_ptr );
|
2005-12-22 15:20:55 -07:00
|
|
|
void clear() ;
|
|
|
|
|
2015-05-16 10:06:22 -06:00
|
|
|
// Public signals for interclass communication
|
|
|
|
sigc::signal<void, const Partition *, bool> signal_partition_selected;
|
2005-12-23 17:06:05 -07:00
|
|
|
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
|
2015-05-23 13:22:37 -06:00
|
|
|
int get_total_separator_px( const PartitionVector & partitions );
|
|
|
|
|
|
|
|
void set_static_data( const PartitionVector & 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 ) ;
|
2012-01-21 10:12:38 -07:00
|
|
|
void calc_usage( std::vector<visual_partition> & visual_partitions ) ;
|
2005-12-22 15:20:55 -07:00
|
|
|
void calc_text( std::vector<visual_partition> & visual_partitions ) ;
|
2018-08-02 11:49:46 -06:00
|
|
|
|
|
|
|
void draw_partition(const Cairo::RefPtr<Cairo::Context>& cr,
|
|
|
|
const visual_partition& vp);
|
|
|
|
void draw_partitions(const Cairo::RefPtr<Cairo::Context>& cr,
|
|
|
|
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 ) ;
|
2015-05-16 10:06:22 -06:00
|
|
|
void set_selected( const std::vector<visual_partition> & visual_partitions, const Partition * partition_ptr );
|
|
|
|
|
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
|
|
|
|
2006-03-09 06:12:44 -07:00
|
|
|
//overridden signalhandlers
|
2018-08-03 11:31:11 -06:00
|
|
|
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
|
2006-03-09 06:12:44 -07:00
|
|
|
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
|
|
|
|
{
|
2012-01-21 10:12:38 -07:00
|
|
|
double fraction ; //Partition size as a fraction of containing disk or extended partition size
|
2005-12-22 15:20:55 -07:00
|
|
|
int x_start, length ;
|
|
|
|
int y_start, height ;
|
|
|
|
int x_used_start, used_length ;
|
|
|
|
int x_unused_start, unused_length ;
|
2012-01-21 10:12:38 -07:00
|
|
|
int x_unallocated_start, unallocated_length ;
|
|
|
|
int y_usage_start, usage_height ;
|
2005-12-22 15:20:55 -07:00
|
|
|
int x_text, y_text ;
|
|
|
|
|
2019-02-20 04:20:20 -07:00
|
|
|
Gdk::RGBA color;
|
2005-12-22 15:20:55 -07:00
|
|
|
Glib::RefPtr<Pango::Layout> pango_layout;
|
|
|
|
|
2015-05-17 03:06:38 -06:00
|
|
|
// Pointer to real partition. (Alias to element in Win_GParted::display_partitions[] vector).
|
|
|
|
const Partition * partition_ptr;
|
|
|
|
|
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()
|
|
|
|
{
|
2012-06-21 12:29:36 -06:00
|
|
|
fraction = 0.0 ;
|
2005-12-22 15:20:55 -07:00
|
|
|
x_start = length =
|
|
|
|
y_start = height =
|
|
|
|
x_used_start = used_length =
|
|
|
|
x_unused_start = unused_length =
|
2012-01-21 10:12:38 -07:00
|
|
|
x_unallocated_start = unallocated_length =
|
|
|
|
y_usage_start = usage_height =
|
2005-12-22 15:20:55 -07:00
|
|
|
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 ;
|
|
|
|
|
2019-02-20 04:20:20 -07:00
|
|
|
Gdk::RGBA color_used;
|
|
|
|
Gdk::RGBA color_unused;
|
|
|
|
Gdk::RGBA color_unallocated;
|
|
|
|
Gdk::RGBA color_text;
|
2004-09-19 14:24:53 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
} //GParted
|
2013-05-27 05:20:16 -06:00
|
|
|
|
|
|
|
#endif /* GPARTED_DRAWINGAREAVISUALDISK_H */
|