index 8a0c70f7cb5109bdb5eac88e5325351d6fb5e400..ca3a995616d6cdba73480d79e0f16899569fc76b 100644 (file)
/* Authors:
* Joel Holdsworth
* The Inkscape Organization
+ * Abhishek Sharma
*
* Copyright (C) 2004-2008 The Inkscape Organization
*
namespace Dialog
{
-const int PreviewWidening = 150;
+const int PREVIEW_WIDENING = 150;
+const int WINDOW_WIDTH_MINIMUM = 32;
+const int WINDOW_WIDTH_FALLBACK = 450;
+const int WINDOW_HEIGHT_MINIMUM = 32;
+const int WINDOW_HEIGHT_FALLBACK = 360;
const char PreviewWindowClassName[] = "PreviewWnd";
const unsigned long MaxPreviewFileSize = 10240; // kB
return result;
}
+namespace {
+
+int sanitizeWindowSizeParam( int size, int delta, int minimum, int fallback )
+{
+ int result = size;
+ if ( size < minimum ) {
+ g_warning( "Window size %d is less than cutoff.", size );
+ result = fallback - delta;
+ }
+ result += delta;
+ return result;
+}
+
+} // namespace
+
/*#########################################################################
### F I L E D I A L O G B A S E C L A S S
#########################################################################*/
RECT rcRect;
GetWindowRect(hParentWnd, &rcRect);
MoveWindow(hParentWnd, rcRect.left, rcRect.top,
- rcRect.right - rcRect.left + PreviewWidening,
- rcRect.bottom - rcRect.top,
- FALSE);
+ rcRect.right - rcRect.left + PREVIEW_WIDENING,
+ rcRect.bottom - rcRect.top,
+ FALSE);
// Set the pointer to the object
OPENFILENAMEW *ofn = (OPENFILENAMEW*)lParam;
gchar *utf8string = g_utf16_to_utf8((const gunichar2*)_path_string,
_MAX_PATH, NULL, NULL, NULL);
- SPDocument *svgDoc = SPDocument::createDoc (utf8string, true);
+ SPDocument *svgDoc = SPDocument::createNewDoc (utf8string, true);
g_free(utf8string);
// Check the document loaded properly
}
// Get the size of the document
- const double svgWidth = sp_document_width(svgDoc);
- const double svgHeight = sp_document_height(svgDoc);
+ const double svgWidth = svgDoc->getWidth();
+ const double svgHeight = svgDoc->getHeight();
// Find the minimum scale to fit the image inside the preview area
const double scaleFactorX = PreviewSize / svgWidth;
// write object bbox to area
Geom::OptRect maybeArea(area);
- sp_document_ensure_up_to_date (svgDoc);
- static_cast<(SPItem *)>(svgDoc->root)->invoke_bbox( maybeArea,
- static_cast<(SPItem *)>(svgDoc->root)->i2d_affine(), TRUE);
+ svgDoc->ensureUpToDate();
+ static_cast<SPItem *>(svgDoc->root)->invoke_bbox( maybeArea,
+ static_cast<SPItem *>(svgDoc->root)->i2d_affine(), TRUE);
NRArena *const arena = NRArena::create();
- unsigned const key = sp_item_display_key_new(1);
+ unsigned const key = SPItem::display_key_new(1);
- NRArenaItem *root = sp_item_invoke_show((SPItem*)(svgDoc->root),
+ NRArenaItem *root = static_cast<SPItem*>(svgDoc->root)->invoke_show(
arena, key, SP_ITEM_SHOW_DISPLAY);
NRGC gc(NULL);
// Tidy up
svgDoc->doUnref();
- sp_item_invoke_hide((SPItem*)(svgDoc->root), key);
+ static_cast<SPItem*>(svgDoc->root)->invoke_hide(key);
nr_object_unref((NRObject *) arena);
// Create the GDK pixbuf
GetWindowRect(GetDlgItem(hParentWnd, stc2), &rST);
GetWindowRect(hdlg, &rROOT);
int ydelta = rCB1.top - rEDT1.top;
+ if ( ydelta < 0 ) {
+ g_warning("Negative dialog ydelta");
+ ydelta = 0;
+ }
// Make the window a bit longer
+ // Note: we have a width delta of 1 because there is a suspicion that MoveWindow() to the same size causes zero-width results.
RECT rcRect;
GetWindowRect(hParentWnd, &rcRect);
- MoveWindow(hParentWnd, rcRect.left, rcRect.top, rcRect.right - rcRect.left,
- rcRect.bottom - rcRect.top + ydelta, FALSE);
+ MoveWindow(hParentWnd, rcRect.left, rcRect.top,
+ sanitizeWindowSizeParam( rcRect.right - rcRect.left, 1, WINDOW_WIDTH_MINIMUM, WINDOW_WIDTH_FALLBACK ),
+ sanitizeWindowSizeParam( rcRect.bottom - rcRect.top, ydelta, WINDOW_HEIGHT_MINIMUM, WINDOW_HEIGHT_FALLBACK ),
+ FALSE);
// It is not necessary to delete stock objects by calling DeleteObject
HGDIOBJ dlgFont = GetStockObject(DEFAULT_GUI_FONT);
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :