previewholder.cpp revision e8d5b4140940ede3d1b30c1784171b1331f84b02
/*
* A simple interface for previewing representations.
*
* Authors:
* Jon A. Cruz
*
* Copyright (C) 2005 Jon A. Cruz
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "previewholder.h"
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/sizegroup.h>
#include <gtkmm/scrollbar.h>
#define COLUMNS_FOR_SMALL 16
#define COLUMNS_FOR_LARGE 8
//#define COLUMNS_FOR_SMALL 48
//#define COLUMNS_FOR_LARGE 32
namespace Inkscape {
namespace UI {
VBox(),
_scroller(0),
_insides(0),
_prefCols(0),
_updatesFrozen(false),
{
// Add a container with the scroller and a spacer
}
{
}
void PreviewHolder::clear()
{
_prefCols = 0;
rebuildUI();
}
{
if ( !_updatesFrozen )
{
if ( _view == VIEW_TYPE_LIST ) {
} else {
Gtk::Widget* thing = manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_GRID, _baseSize));
int width = 1;
int height = 1;
// g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount );
for ( int j = oldWidth; j < childCount; j++ ) {
_insides->attach( *target, col2, col2+1, row2, row2+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND );
}
} else if ( col == 0 ) {
// we just started a new row
}
}
_scroller->queue_draw();
}
}
void PreviewHolder::freezeUpdates()
{
_updatesFrozen = true;
}
void PreviewHolder::thawUpdates()
{
_updatesFrozen = false;
rebuildUI();
}
{
rebuildUI();
}
}
{
{
switch ( _anchor )
{
case Gtk::ANCHOR_NORTH:
case Gtk::ANCHOR_SOUTH:
{
dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_ALWAYS, Gtk::POLICY_AUTOMATIC );
}
break;
case Gtk::ANCHOR_EAST:
case Gtk::ANCHOR_WEST:
{
dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC );
}
break;
default:
{
dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC );
}
}
rebuildUI();
}
}
{
}
{
// g_message( "on_size_allocate(%d, %d) (%d, %d)", allocation.get_x(), allocation.get_y(), allocation.get_width(), allocation.get_height() );
// g_message(" anchor:%d", _anchor);
}
{
// g_message( "on_size_request(%d, %d)", requisition->width, requisition->height );
// g_message( " super (%d, %d)", requisition->width, requisition->height );
// g_message(" anchor:%d", _anchor);
// g_message(" items:%d", (int)items.size());
}
void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int& width, int& height )
{
height = 1;
}
if ( hs ) {
// the +8 is a temporary hack
}
}
} else {
if ( _prefCols > 0 ) {
}
if ( height < 1 ) {
height = 1;
}
}
}
void PreviewHolder::rebuildUI()
{
_insides = 0; // remove() call should have deleted the Gtk::Table.
if ( _view == VIEW_TYPE_LIST ) {
//label->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
}
} else {
int col = 0;
int row = 0;
int width = 2;
int height = 1;
if ( !_insides ) {
}
col = 0;
row++;
}
}
if ( !_insides ) {
}
}
_scroller->queue_draw();
}
} //namespace UI
} //namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :