summaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/filedialogimpl-win32.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2010-11-25 20:51:17 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2010-11-25 20:51:17 +0000
commit0bd9f7e209d522dbcebe0449a91397fdd9e38977 (patch)
tree834c7d02456658b57625ab68cc28f7854a5a85dc /src/ui/dialog/filedialogimpl-win32.cpp
parentFix handling of x and y attributes of patterns (diff)
parentFix ruler redraw issue on GTK 2.22 (diff)
downloadinkscape-0bd9f7e209d522dbcebe0449a91397fdd9e38977.tar.gz
inkscape-0bd9f7e209d522dbcebe0449a91397fdd9e38977.zip
Merge from trunk
(bzr r9508.1.70)
Diffstat (limited to 'src/ui/dialog/filedialogimpl-win32.cpp')
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp40
1 files changed, 33 insertions, 7 deletions
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index cd9db2fac..b4379e071 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -57,7 +57,11 @@ namespace UI
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
@@ -89,6 +93,21 @@ ustring utf16_to_ustring(const wchar_t *utf16string, int utf16length = -1)
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
#########################################################################*/
@@ -441,9 +460,9 @@ UINT_PTR CALLBACK FileOpenDialogImplWin32::GetOpenFileName_hookproc(
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;
@@ -1689,12 +1708,19 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc(
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);
@@ -1763,4 +1789,4 @@ UINT_PTR CALLBACK FileSaveDialogImplWin32::GetSaveFileName_hookproc(
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 :