#FEATURE by sr
add feature to native file dialog
class: WinWorkstation
added:
#nativeFileDialogWithTitle:defaultFilename:owningTopView:filter:filterIndex:trueForSave:trueForPromptOverwrite:
#primNativeFileDialogWithTitle:defaultBaseName:defaultDirectory:owningViewId:filterString:filterIndex:trueForSave:trueForMultiSelect:trueForPromptOverwrite:
removed:
#nativeFileDialogWithTitle:defaultFilename:owningTopView:filter:filterIndex:doSave:
#primNativeFileDialogWithTitle:defaultBaseName:defaultDirectory:owningViewId:filterString:filterIndex:doSave:allowMultiSelect:
--- a/WinWorkstation.st Wed Oct 24 10:50:04 2018 +0200
+++ b/WinWorkstation.st Wed Oct 24 13:24:06 2018 +0200
@@ -14,43 +14,43 @@
"{ NameSpace: Smalltalk }"
DeviceWorkstation subclass:#WinWorkstation
- instanceVariableNames:'blackpixel whitepixel listOfFonts rootWin rootDC buttonsPressed
- eventTrace eventBuffer lastClipboardSequenceNumber'
- classVariableNames:'BeepDuration NativeDialogs NativeFileDialogs NativeWidgets
- NativeWidgetClassTable StandardColorValues IgnoreSysColorChanges
- IgnoreFontChanges SystemColorValues CanEndSession
- VerboseNativeDialogs'
- poolDictionaries:''
- category:'Interface-Graphics'
+ instanceVariableNames:'blackpixel whitepixel listOfFonts rootWin rootDC buttonsPressed
+ eventTrace eventBuffer lastClipboardSequenceNumber'
+ classVariableNames:'BeepDuration NativeDialogs NativeFileDialogs NativeWidgets
+ NativeWidgetClassTable StandardColorValues IgnoreSysColorChanges
+ IgnoreFontChanges SystemColorValues CanEndSession
+ VerboseNativeDialogs'
+ poolDictionaries:''
+ category:'Interface-Graphics'
!
Object subclass:#AlphaBlendParameters
- instanceVariableNames:'sourceAlpha padding redMask greenMask blueMask'
- classVariableNames:''
- poolDictionaries:''
- privateIn:WinWorkstation
+ instanceVariableNames:'sourceAlpha padding redMask greenMask blueMask'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:WinWorkstation
!
ByteArray variableByteSubclass:#CopyDataStructStructure
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- privateIn:WinWorkstation
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:WinWorkstation
!
Object subclass:#MonitorInfo
- instanceVariableNames:'screenX screenY screenW screenH workX workY workW workH isPrimary
- name'
- classVariableNames:''
- poolDictionaries:''
- privateIn:WinWorkstation
+ instanceVariableNames:'screenX screenY screenW screenH workX workY workW workH isPrimary
+ name'
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:WinWorkstation
!
DeviceHandle subclass:#PrinterDeviceContextHandle
- instanceVariableNames:''
- classVariableNames:''
- poolDictionaries:''
- privateIn:WinWorkstation
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:WinWorkstation
!
!WinWorkstation primitiveDefinitions!
@@ -952,17 +952,18 @@
int filterIndex;
BOOL trueForSave;
BOOL trueForMultiSelect;
-
- DWORD fileDialogThreadId;
+ BOOL trueForPromptOverwrite;
+
+ DWORD fileDialogThreadId;
BOOL fileDialogDidReturn;
} fileDialogData;
DWORD WINAPI OpenFileDialog(void *arg) {
BOOL hasResult;
OPENFILENAMEW ofn;
- fileDialogData *pFdd = (fileDialogData*)arg;
-
- pFdd->fileDialogThreadId = GetCurrentThreadId();
+ fileDialogData *pFdd = (fileDialogData*)arg;
+
+ pFdd->fileDialogThreadId = GetCurrentThreadId();
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(OPENFILENAMEW);
@@ -975,20 +976,22 @@
ofn.hwndOwner = pFdd->owningWindow;
if (pFdd->trueForSave) {
- ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
- hasResult = GetSaveFileNameW(&ofn);
- } else {
- if (pFdd->trueForMultiSelect) {
- ofn.Flags = OFN_EXPLORER | OFN_ALLOWMULTISELECT;
- } else {
- ofn.Flags = OFN_FILEMUSTEXIST;
- }
-
- hasResult = GetOpenFileNameW(&ofn);
+ ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
+ hasResult = GetSaveFileNameW(&ofn);
+ } else {
+ if (pFdd->trueForMultiSelect) {
+ ofn.Flags = OFN_EXPLORER | OFN_ALLOWMULTISELECT;
+ } else {
+ if (pFdd->trueForPromptOverwrite) {
+ ofn.Flags = OFN_FILEMUSTEXIST;
+ }
+ }
+
+ hasResult = GetOpenFileNameW(&ofn);
}
if (!hasResult) {
- ZeroMemory(&pFdd->filename, sizeof(pFdd->filename));
+ ZeroMemory(&pFdd->filename, sizeof(pFdd->filename));
}
pFdd->fileDialogDidReturn = TRUE;
@@ -999,7 +1002,7 @@
HANDLE openFileDialogInNewThread(fileDialogData *pFdd) {
HANDLE fileDialogThread = CreateThread(NULL, 0, OpenFileDialog, pFdd, 0, NULL);
if (fileDialogThread == INVALID_HANDLE_VALUE) {
- printf("error: could not create thread for native file dialog: %d\n", GetLastError());
+ printf("error: could not create thread for native file dialog: %d\n", GetLastError());
}
return fileDialogThread;
@@ -16583,7 +16586,8 @@
owningTopView:owningTopView
filter:filterStringOrArrayOfPairs
filterIndex:filterIndexArg
- doSave:doSave
+ trueForSave:trueForSave
+ trueForPromptOverwrite:trueForPromptOverwrite
"opens a native windows file dialog,
supports unicode 16 strings (like windows does it for filenames)
@@ -16642,8 +16646,9 @@
owningViewId:owningViewId
filterString:filterString
filterIndex:filterIndexArg ? 1
- doSave:doSave
- allowMultiSelect:false. "/ not yet implemented
+ trueForSave:trueForSave
+ trueForMultiSelect:false "/ not yet implemented
+ trueForPromptOverwrite:trueForPromptOverwrite ? true.
dataAddress := dataAddressAndThreadAddress first.
@@ -16765,8 +16770,7 @@
p terminate.
"
- "Created: / 23-10-2018 / 09:58:25 / sr"
- "Modified: / 24-10-2018 / 10:48:21 / sr"
+ "Created: / 24-10-2018 / 13:15:17 / sr"
!
primCloseNativeFileDialogByDataAddress:dataAddress
@@ -16873,8 +16877,9 @@
owningViewId:owningViewId
filterString:filterString
filterIndex:filterIndexArg
- doSave:doSave
- allowMultiSelect:allowMultiSelectArg
+ trueForSave:trueForSaveArg
+ trueForMultiSelect:trueForMultiSelectArg
+ trueForPromptOverwrite:trueForPromptOverwriteArg
"do not call this directly, use #nativeFileDialogWithTitle:..."
@@ -16915,8 +16920,10 @@
if (__isInteger(filterIndexArg)) {
pFdd->filterIndex = __intVal(filterIndexArg);
}
- pFdd->trueForSave = doSave == true;
- pFdd->trueForMultiSelect = allowMultiSelectArg == true;
+ pFdd->trueForSave = trueForSaveArg == true;
+ pFdd->trueForMultiSelect = trueForMultiSelectArg == true;
+ pFdd->trueForPromptOverwrite = trueForPromptOverwriteArg == true;
+
pFdd->fileDialogDidReturn = FALSE;
fileDialogDataAddress = __MKEXTERNALADDRESS(pFdd);