summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d6436fa)
raw | patch | inline | side by side (parent: d6436fa)
author | Jon A. Cruz <jon@joncruz.org> | |
Wed, 11 Aug 2010 08:31:03 +0000 (01:31 -0700) | ||
committer | Jon A. Cruz <jon@joncruz.org> | |
Wed, 11 Aug 2010 08:31:03 +0000 (01:31 -0700) |
src/ui/dialog/filedialogimpl-win32.cpp | patch | blob | history |
index 0f3672f25a678614eccf7ff3483dae791ad139ff..11624af70a4dd1d2feec2a6d594acd98e928a7e3 100644 (file)
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 < lower ) {
+ 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;
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);