2004-09-19 14:24:53 -06:00
|
|
|
/* Copyright (C) 2004 Bart
|
2010-05-25 16:25:21 -06:00
|
|
|
* Copyright (C) 2010 Curtis Gedak
|
2004-09-19 14:24:53 -06:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../include/Frame_Resizer_Base.h"
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
Frame_Resizer_Base::Frame_Resizer_Base()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
BORDER = 8 ;
|
|
|
|
GRIPPER = 10 ;
|
2010-05-25 16:25:21 -06:00
|
|
|
X_MIN_SPACE_BEFORE = 0 ;
|
2006-03-01 12:16:13 -07:00
|
|
|
|
|
|
|
fixed_start = false ;
|
|
|
|
init() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
void Frame_Resizer_Base::init()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
drawingarea .set_size_request( 500 + GRIPPER * 2 + BORDER *2, 50 );
|
2004-12-12 07:57:04 -07:00
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
drawingarea .signal_realize() .connect(
|
|
|
|
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_realize) ) ;
|
|
|
|
drawingarea .signal_expose_event() .connect(
|
|
|
|
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_expose) ) ;
|
|
|
|
drawingarea .signal_motion_notify_event() .connect(
|
|
|
|
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_mouse_motion) ) ;
|
|
|
|
drawingarea .signal_button_press_event() .connect(
|
|
|
|
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_button_press_event) ) ;
|
|
|
|
drawingarea .signal_button_release_event() .connect(
|
|
|
|
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_button_release_event) ) ;
|
|
|
|
drawingarea .signal_leave_notify_event() .connect(
|
|
|
|
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_leave_notify) ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
this ->add( drawingarea ) ;
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
color_used .set( "#F8F8BA" ); this ->get_colormap() ->alloc_color( color_used ) ;
|
|
|
|
color_unused .set( "white" ); this ->get_colormap() ->alloc_color( color_unused ) ;
|
|
|
|
color_arrow .set( "black" ); this ->get_colormap() ->alloc_color( color_arrow ) ;
|
|
|
|
color_background .set( "darkgrey" ); this ->get_colormap() ->alloc_color( color_background ) ;
|
|
|
|
color_arrow_rectangle .set( "lightgrey" ); this ->get_colormap() ->alloc_color( color_arrow_rectangle ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2004-10-01 15:09:19 -06:00
|
|
|
cursor_resize = new Gdk::Cursor( Gdk::SB_H_DOUBLE_ARROW ) ;
|
|
|
|
cursor_move = new Gdk::Cursor( Gdk::FLEUR ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2004-10-01 15:09:19 -06:00
|
|
|
GRIP_MOVE = GRIP_LEFT = GRIP_RIGHT = false;
|
|
|
|
X_END = 0;
|
2004-12-12 07:57:04 -07:00
|
|
|
set_size_limits( 0, 500 ) ;
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
Gdk::Point p;
|
2004-12-12 07:57:04 -07:00
|
|
|
p .set_y( 15 ); arrow_points .push_back( p ) ;
|
|
|
|
p .set_y( 25 ); arrow_points .push_back( p ) ;
|
|
|
|
p .set_y( 35 ); arrow_points .push_back( p ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->show_all_children();
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Frame_Resizer_Base::set_rgb_partition_color( const Gdk::Color & color )
|
|
|
|
{
|
2013-10-11 03:16:49 -06:00
|
|
|
this ->get_colormap() ->free_color( color_partition ) ;
|
2004-10-08 13:53:35 -06:00
|
|
|
this ->color_partition = color ;
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->get_colormap() ->alloc_color( color_partition ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Frame_Resizer_Base::override_default_rgb_unused_color( const Gdk::Color & color )
|
|
|
|
{
|
2013-10-11 03:16:49 -06:00
|
|
|
this ->get_colormap() ->free_color( color_unused ) ;
|
2004-10-08 13:53:35 -06:00
|
|
|
this ->color_unused = color ;
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->get_colormap() ->alloc_color( color_unused ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2005-01-25 07:26:54 -07:00
|
|
|
void Frame_Resizer_Base::set_x_start( int x_start )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->X_START = x_start + GRIPPER ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2010-05-25 16:25:21 -06:00
|
|
|
void Frame_Resizer_Base::set_x_min_space_before( int x_min_space_before )
|
|
|
|
{
|
|
|
|
this ->X_MIN_SPACE_BEFORE = x_min_space_before ;
|
|
|
|
}
|
|
|
|
|
2004-09-19 14:24:53 -06:00
|
|
|
void Frame_Resizer_Base::set_x_end( int x_end )
|
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->X_END = x_end + GRIPPER + BORDER * 2 ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2005-01-25 07:26:54 -07:00
|
|
|
void Frame_Resizer_Base::set_used( int used )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->USED = used ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Frame_Resizer_Base::set_fixed_start( bool fixed_start )
|
|
|
|
{
|
|
|
|
this ->fixed_start = fixed_start ;
|
|
|
|
}
|
|
|
|
|
2004-12-12 07:57:04 -07:00
|
|
|
void Frame_Resizer_Base::set_size_limits( int min_size, int max_size )
|
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
this ->MIN_SIZE = min_size + BORDER * 2 ;
|
|
|
|
this ->MAX_SIZE = max_size + BORDER * 2 ;
|
2004-12-12 07:57:04 -07:00
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
int Frame_Resizer_Base::get_used()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
|
|
|
return USED ;
|
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
int Frame_Resizer_Base::get_x_start()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
return X_START - GRIPPER ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
int Frame_Resizer_Base::get_x_end()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
return X_END - GRIPPER - BORDER * 2 ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
void Frame_Resizer_Base::drawingarea_on_realize()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
gc_drawingarea = Gdk::GC::create( drawingarea .get_window() );
|
|
|
|
pixmap = Gdk::Pixmap::create( drawingarea .get_window(),
|
|
|
|
drawingarea .get_allocation() .get_width(),
|
|
|
|
drawingarea .get_allocation() .get_height() );
|
2005-01-25 07:26:54 -07:00
|
|
|
gc_pixmap = Gdk::GC::create( pixmap );
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2005-01-19 13:01:39 -07:00
|
|
|
drawingarea .add_events( Gdk::POINTER_MOTION_MASK );
|
|
|
|
drawingarea .add_events( Gdk::BUTTON_PRESS_MASK );
|
|
|
|
drawingarea .add_events( Gdk::BUTTON_RELEASE_MASK );
|
|
|
|
drawingarea .add_events( Gdk::LEAVE_NOTIFY_MASK );
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2005-01-19 13:01:39 -07:00
|
|
|
bool Frame_Resizer_Base::drawingarea_on_expose( GdkEventExpose * ev )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
Draw_Partition() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion * ev )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2005-01-19 13:01:39 -07:00
|
|
|
if ( GRIP_LEFT || GRIP_RIGHT || GRIP_MOVE )
|
2006-03-01 12:16:13 -07:00
|
|
|
{
|
|
|
|
if ( GRIP_LEFT )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2010-05-25 16:25:21 -06:00
|
|
|
if ( ev ->x > (GRIPPER + X_MIN_SPACE_BEFORE) &&
|
2006-03-01 12:16:13 -07:00
|
|
|
(X_END - ev ->x) < MAX_SIZE &&
|
|
|
|
(X_END - ev ->x) > MIN_SIZE )
|
|
|
|
{
|
|
|
|
X_START = static_cast<int>( ev ->x ) ;
|
|
|
|
|
|
|
|
signal_resize .emit( X_START - GRIPPER, X_END - GRIPPER - 2 * BORDER, ARROW_LEFT ) ;
|
|
|
|
}
|
|
|
|
else if ( X_END - ev ->x >= MAX_SIZE )
|
|
|
|
{
|
|
|
|
if ( X_END - X_START < MAX_SIZE )
|
|
|
|
{
|
|
|
|
X_START = X_END - MAX_SIZE ;
|
|
|
|
|
2010-05-25 16:25:21 -06:00
|
|
|
if ( X_START < (GRIPPER + X_MIN_SPACE_BEFORE) )
|
|
|
|
X_START = GRIPPER + X_MIN_SPACE_BEFORE ;
|
2006-03-01 12:16:13 -07:00
|
|
|
|
|
|
|
//-1 to force the spinbutton to its max.
|
|
|
|
signal_resize .emit( X_START - GRIPPER -1,
|
|
|
|
X_END - GRIPPER - BORDER * 2,
|
|
|
|
ARROW_LEFT ) ;
|
|
|
|
}
|
|
|
|
}
|
2010-05-25 16:25:21 -06:00
|
|
|
else if ( ev ->x <= (GRIPPER + X_MIN_SPACE_BEFORE) )
|
2006-03-01 12:16:13 -07:00
|
|
|
{
|
2010-05-25 16:25:21 -06:00
|
|
|
if ( X_START > (GRIPPER + X_MIN_SPACE_BEFORE) && X_END - X_START < MAX_SIZE )
|
2006-03-01 12:16:13 -07:00
|
|
|
{
|
2010-05-25 16:25:21 -06:00
|
|
|
X_START = GRIPPER + X_MIN_SPACE_BEFORE ;
|
2006-03-01 12:16:13 -07:00
|
|
|
|
|
|
|
signal_resize .emit( X_START - GRIPPER,
|
|
|
|
X_END - GRIPPER - BORDER * 2,
|
|
|
|
ARROW_LEFT ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( X_END - ev ->x <= MIN_SIZE )
|
|
|
|
{
|
|
|
|
if ( X_END - X_START > MIN_SIZE )
|
|
|
|
{
|
|
|
|
X_START = X_END - MIN_SIZE ;
|
|
|
|
|
|
|
|
//+1 to force the spinbutton to its min.
|
|
|
|
signal_resize .emit( X_START - GRIPPER +1,
|
|
|
|
X_END - GRIPPER - BORDER * 2,
|
|
|
|
ARROW_LEFT ) ;
|
|
|
|
}
|
|
|
|
}
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
2006-03-01 12:16:13 -07:00
|
|
|
|
|
|
|
else if ( GRIP_RIGHT )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
if ( ev ->x < 500 + GRIPPER + BORDER * 2 &&
|
|
|
|
(ev ->x - X_START) < MAX_SIZE &&
|
|
|
|
(ev ->x - X_START) > MIN_SIZE )
|
|
|
|
{
|
|
|
|
X_END = static_cast<int>( ev ->x ) ;
|
|
|
|
|
|
|
|
signal_resize .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2, ARROW_RIGHT ) ;
|
|
|
|
}
|
|
|
|
else if ( ev ->x - X_START >= MAX_SIZE )
|
|
|
|
{
|
|
|
|
if ( X_END - X_START < MAX_SIZE )
|
|
|
|
{
|
|
|
|
X_END = X_START + MAX_SIZE ;
|
|
|
|
|
|
|
|
if ( X_END > 500 + GRIPPER + BORDER * 2 )
|
|
|
|
X_END = 500 + GRIPPER + BORDER * 2 ;
|
|
|
|
|
|
|
|
//+1 to force the spinbutton to its min.
|
|
|
|
signal_resize .emit( X_START - GRIPPER,
|
|
|
|
X_END - GRIPPER - BORDER * 2 +1,
|
|
|
|
ARROW_RIGHT ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( ev ->x >= 500 + GRIPPER + BORDER * 2 )
|
|
|
|
{
|
|
|
|
if ( X_END < 500 + GRIPPER + BORDER * 2 && X_END - X_START < MAX_SIZE )
|
|
|
|
{
|
|
|
|
X_END = 500 + GRIPPER + BORDER * 2 ;
|
|
|
|
|
|
|
|
signal_resize .emit( X_START -GRIPPER,
|
|
|
|
X_END - GRIPPER - BORDER * 2,
|
|
|
|
ARROW_RIGHT ) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( ev ->x - X_START <= MIN_SIZE )
|
|
|
|
{
|
|
|
|
if ( X_END - X_START > MIN_SIZE )
|
|
|
|
{
|
|
|
|
X_END = X_START + MIN_SIZE ;
|
|
|
|
|
|
|
|
//-1 to force the spinbutton to its min.
|
|
|
|
signal_resize .emit( X_START - GRIPPER,
|
|
|
|
X_END - GRIPPER - BORDER * 2 -1,
|
|
|
|
ARROW_RIGHT ) ;
|
|
|
|
}
|
|
|
|
}
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
else if ( GRIP_MOVE )
|
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
temp_x = X_START + static_cast<int>( ev ->x - X_START_MOVE );
|
|
|
|
temp_y = X_END - X_START ;
|
2010-05-25 16:25:21 -06:00
|
|
|
|
|
|
|
if ( temp_x > (GRIPPER + X_MIN_SPACE_BEFORE) && temp_x + temp_y < 500 + GRIPPER + BORDER * 2 )
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
|
|
|
X_START = temp_x ;
|
2006-03-01 12:16:13 -07:00
|
|
|
X_END = X_START + temp_y ;
|
|
|
|
}
|
2010-05-25 16:25:21 -06:00
|
|
|
else if ( temp_x <= (GRIPPER + X_MIN_SPACE_BEFORE) )
|
2006-03-01 12:16:13 -07:00
|
|
|
{
|
2010-05-25 16:25:21 -06:00
|
|
|
if ( X_START > (GRIPPER + X_MIN_SPACE_BEFORE) )
|
2006-03-01 12:16:13 -07:00
|
|
|
{
|
2010-05-25 16:25:21 -06:00
|
|
|
X_START = GRIPPER + X_MIN_SPACE_BEFORE;
|
2006-03-01 12:16:13 -07:00
|
|
|
X_END = X_START + temp_y ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( temp_x + temp_y >= 500 + GRIPPER + BORDER * 2 )
|
|
|
|
{
|
|
|
|
if ( X_END < 500 + GRIPPER + BORDER * 2 )
|
|
|
|
{
|
|
|
|
X_END = 500 + GRIPPER + BORDER * 2 ;
|
|
|
|
X_START = X_END - temp_y ;
|
|
|
|
}
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
2010-05-25 16:25:21 -06:00
|
|
|
|
|
|
|
X_START_MOVE = static_cast<int>( ev ->x ) ;
|
2006-03-01 12:16:13 -07:00
|
|
|
signal_move .emit( X_START - GRIPPER, X_END - GRIPPER - BORDER * 2 ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
Draw_Partition() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
2005-01-25 07:45:15 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
//check if pointer is over a gripper
|
2006-03-01 12:16:13 -07:00
|
|
|
//left grip
|
|
|
|
if ( ! fixed_start &&
|
|
|
|
ev ->x >= X_START - GRIPPER &&
|
|
|
|
ev ->x <= X_START &&
|
|
|
|
ev ->y >= 5 &&
|
|
|
|
ev ->y <= 45 )
|
|
|
|
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
|
|
|
//right grip
|
|
|
|
else if ( ev ->x >= X_END &&
|
|
|
|
ev ->x <= X_END + GRIPPER &&
|
|
|
|
ev ->y >= 5 &&
|
|
|
|
ev ->y <= 45 )
|
|
|
|
drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
|
|
|
|
//move grip
|
|
|
|
else if ( ! fixed_start &&
|
|
|
|
ev ->x >= X_START &&
|
|
|
|
ev ->x <= X_END )
|
|
|
|
drawingarea .get_parent_window() ->set_cursor( *cursor_move ) ;
|
|
|
|
//normal pointer
|
|
|
|
else
|
2006-09-09 01:09:13 -06:00
|
|
|
drawingarea .get_parent_window() ->set_cursor() ;
|
2005-01-25 07:45:15 -07:00
|
|
|
}
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Frame_Resizer_Base::drawingarea_on_button_press_event( GdkEventButton *ev )
|
|
|
|
{
|
2006-03-01 12:16:13 -07:00
|
|
|
GRIP_LEFT = GRIP_RIGHT = GRIP_MOVE = false;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
//left grip
|
|
|
|
if ( ! fixed_start &&
|
|
|
|
ev ->x >= X_START - GRIPPER &&
|
|
|
|
ev ->x <= X_START &&
|
|
|
|
ev ->y >= 5 &&
|
|
|
|
ev ->y <= 45 )
|
2004-09-19 14:24:53 -06:00
|
|
|
GRIP_LEFT = true ;
|
2006-03-01 12:16:13 -07:00
|
|
|
//right grip
|
|
|
|
else if ( ev ->x >= X_END &&
|
|
|
|
ev ->x <= X_END + GRIPPER &&
|
|
|
|
ev ->y >= 5 &&
|
|
|
|
ev ->y <= 45 )
|
2004-09-19 14:24:53 -06:00
|
|
|
GRIP_RIGHT = true ;
|
2006-03-01 12:16:13 -07:00
|
|
|
//move grip
|
|
|
|
else if ( ! fixed_start &&
|
|
|
|
ev ->x >= X_START &&
|
|
|
|
ev ->x <= X_END )
|
|
|
|
{
|
|
|
|
GRIP_MOVE = true ;
|
|
|
|
X_START_MOVE = static_cast<int>( ev ->x );
|
|
|
|
}
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Frame_Resizer_Base::drawingarea_on_button_release_event( GdkEventButton *ev )
|
|
|
|
{
|
2005-01-25 07:26:54 -07:00
|
|
|
GRIP_LEFT = GRIP_RIGHT = GRIP_MOVE = false;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Frame_Resizer_Base::drawingarea_on_leave_notify( GdkEventCrossing *ev )
|
|
|
|
{
|
2004-11-07 06:13:11 -07:00
|
|
|
if ( ev ->mode != GDK_CROSSING_GRAB && ! GRIP_LEFT && ! GRIP_RIGHT && ! GRIP_MOVE )
|
2006-09-09 01:09:13 -06:00
|
|
|
drawingarea .get_parent_window() ->set_cursor() ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
void Frame_Resizer_Base::Draw_Partition()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
|
|
|
UNUSED = X_END - X_START - BORDER * 2 - USED ;
|
|
|
|
if ( UNUSED < 0 )
|
|
|
|
UNUSED = 0 ;
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
if ( drawingarea .get_window() )
|
2004-12-01 14:31:59 -07:00
|
|
|
{
|
2005-01-25 07:26:54 -07:00
|
|
|
//i couldn't find a clear() for a pixmap, that's why ;)
|
|
|
|
gc_pixmap ->set_foreground( color_background );
|
|
|
|
pixmap ->draw_rectangle( gc_pixmap, true, 0, 0, 536, 50 );
|
2004-12-01 14:31:59 -07:00
|
|
|
|
|
|
|
//the two rectangles on each side of the partition
|
2005-01-25 07:26:54 -07:00
|
|
|
gc_pixmap ->set_foreground( color_arrow_rectangle );
|
|
|
|
pixmap ->draw_rectangle( gc_pixmap, true, 0, 0, 10, 50 );
|
|
|
|
pixmap ->draw_rectangle( gc_pixmap, true, 526, 0, 10, 50 );
|
2004-12-01 14:31:59 -07:00
|
|
|
|
|
|
|
//partition
|
2005-01-25 07:26:54 -07:00
|
|
|
gc_pixmap ->set_foreground( color_partition );
|
|
|
|
pixmap ->draw_rectangle( gc_pixmap, true, X_START, 0, X_END - X_START, 50 );
|
2004-12-01 14:31:59 -07:00
|
|
|
|
|
|
|
//used
|
2005-01-25 07:26:54 -07:00
|
|
|
gc_pixmap ->set_foreground( color_used );
|
|
|
|
pixmap ->draw_rectangle( gc_pixmap, true, X_START +BORDER, BORDER, USED, 34 );
|
2004-12-01 14:31:59 -07:00
|
|
|
|
|
|
|
//unused
|
2005-01-25 07:26:54 -07:00
|
|
|
gc_pixmap ->set_foreground( color_unused );
|
|
|
|
pixmap ->draw_rectangle( gc_pixmap, true, X_START +BORDER +USED, BORDER, UNUSED, 34 );
|
2004-12-01 14:31:59 -07:00
|
|
|
|
|
|
|
//resize grips
|
|
|
|
if ( ! fixed_start )
|
|
|
|
Draw_Resize_Grip( ARROW_LEFT ) ;
|
|
|
|
|
|
|
|
Draw_Resize_Grip( ARROW_RIGHT ) ;
|
2005-01-25 07:26:54 -07:00
|
|
|
|
|
|
|
//and draw everything to "real" screen..
|
2006-03-01 12:16:13 -07:00
|
|
|
drawingarea .get_window() ->draw_drawable( gc_drawingarea, pixmap, 0, 0, 0, 0 ) ;
|
2004-12-01 14:31:59 -07:00
|
|
|
}
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void Frame_Resizer_Base::Draw_Resize_Grip( ArrowType arrow_type )
|
|
|
|
{
|
|
|
|
if ( arrow_type == ARROW_LEFT )
|
|
|
|
{
|
2005-01-25 07:26:54 -07:00
|
|
|
arrow_points[ 0 ] .set_x( X_START ) ;
|
2006-03-01 12:16:13 -07:00
|
|
|
arrow_points[ 1 ] .set_x( X_START - GRIPPER ) ;
|
2005-01-25 07:26:54 -07:00
|
|
|
arrow_points[ 2 ] .set_x( X_START ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-01-25 07:26:54 -07:00
|
|
|
arrow_points[ 0 ] .set_x( X_END ) ;
|
2006-03-01 12:16:13 -07:00
|
|
|
arrow_points[ 1 ] .set_x( X_END + GRIPPER ) ;
|
2005-01-25 07:26:54 -07:00
|
|
|
arrow_points[ 2 ] .set_x( X_END ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//attach resize arrows to the partition
|
2005-01-25 07:26:54 -07:00
|
|
|
gc_pixmap ->set_foreground( color_arrow_rectangle );
|
2006-03-01 12:16:13 -07:00
|
|
|
pixmap ->draw_rectangle( gc_pixmap,
|
|
|
|
false,
|
|
|
|
arrow_type == ARROW_LEFT ? X_START - GRIPPER : X_END +1,
|
|
|
|
5,
|
|
|
|
9,
|
|
|
|
40 ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2005-01-25 07:26:54 -07:00
|
|
|
gc_pixmap ->set_foreground( color_arrow );
|
|
|
|
pixmap ->draw_polygon( gc_pixmap, true, arrow_points );
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|
|
|
|
|
2006-03-01 12:16:13 -07:00
|
|
|
Frame_Resizer_Base::~Frame_Resizer_Base()
|
2004-09-19 14:24:53 -06:00
|
|
|
{
|
2013-10-11 03:16:49 -06:00
|
|
|
this ->get_colormap() ->free_color( color_used ) ;
|
|
|
|
this ->get_colormap() ->free_color( color_unused ) ;
|
|
|
|
this ->get_colormap() ->free_color( color_arrow ) ;
|
|
|
|
this ->get_colormap() ->free_color( color_background ) ;
|
|
|
|
this ->get_colormap() ->free_color( color_partition ) ;
|
|
|
|
this ->get_colormap() ->free_color( color_arrow_rectangle ) ;
|
2004-09-19 14:24:53 -06:00
|
|
|
|
2010-06-24 09:36:20 -06:00
|
|
|
delete cursor_resize;
|
|
|
|
delete cursor_move;
|
2004-09-19 14:24:53 -06:00
|
|
|
}
|