mirror of https://github.com/fltk/fltk
Small indent / whitespace fixups, Manolo's doc modification for
Fl_Native_File_Chooser::options. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7015 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
7221382917
commit
97ac940d91
|
@ -62,7 +62,7 @@ Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
|
||||||
_directory = NULL;
|
_directory = NULL;
|
||||||
_errmsg = NULL;
|
_errmsg = NULL;
|
||||||
_file_chooser = new Fl_File_Chooser(NULL, NULL, 0, NULL);
|
_file_chooser = new Fl_File_Chooser(NULL, NULL, 0, NULL);
|
||||||
type(val); // do this after _file_chooser created
|
type(val); // do this after _file_chooser created
|
||||||
_nfilters = 0;
|
_nfilters = 0;
|
||||||
|
|
||||||
// Added by MG
|
// Added by MG
|
||||||
|
@ -142,7 +142,7 @@ int Fl_Native_File_Chooser::type() const {
|
||||||
-------------- ----------------------------------------------- ------- ------- -------
|
-------------- ----------------------------------------------- ------- ------- -------
|
||||||
NEW_FOLDER Shows the 'New Folder' button. Ignored Used Used
|
NEW_FOLDER Shows the 'New Folder' button. Ignored Used Used
|
||||||
PREVIEW Enables the 'Preview' mode by default. Ignored Ignored Used
|
PREVIEW Enables the 'Preview' mode by default. Ignored Ignored Used
|
||||||
SAVEAS_CONFIRM Confirm dialog if BROWSE_SAVE_FILE file exists. Ignored Used Ignored
|
SAVEAS_CONFIRM Confirm dialog if BROWSE_SAVE_FILE file exists. Ignored Used Used
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
void Fl_Native_File_Chooser::options(int val) {
|
void Fl_Native_File_Chooser::options(int val) {
|
||||||
|
@ -258,10 +258,10 @@ const char* Fl_Native_File_Chooser::filename() const {
|
||||||
\b Example:
|
\b Example:
|
||||||
\code
|
\code
|
||||||
if ( fnfc->show() == 0 ) {
|
if ( fnfc->show() == 0 ) {
|
||||||
// Print all filenames user selected
|
// Print all filenames user selected
|
||||||
for (int n=0; n<fnfc->count(); n++ ) {
|
for (int n=0; n<fnfc->count(); n++ ) {
|
||||||
printf("%d) '%s'\n", n, fnfc->filename(n));
|
printf("%d) '%s'\n", n, fnfc->filename(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
|
@ -352,10 +352,10 @@ int Fl_Native_File_Chooser::filter_value() const {
|
||||||
\b Example:
|
\b Example:
|
||||||
\code
|
\code
|
||||||
if ( fnfc->show() == 0 ) {
|
if ( fnfc->show() == 0 ) {
|
||||||
// Print all filenames user selected
|
// Print all filenames user selected
|
||||||
for (int n=0; n<fnfc->count(); n++ ) {
|
for (int n=0; n<fnfc->count(); n++ ) {
|
||||||
printf("%d) '%s'\n", n, fnfc->filename(n));
|
printf("%d) '%s'\n", n, fnfc->filename(n));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\endcode
|
\endcode
|
||||||
*/
|
*/
|
||||||
|
@ -412,33 +412,33 @@ void Fl_Native_File_Chooser::parse_filter() {
|
||||||
switch (*in) {
|
switch (*in) {
|
||||||
// FINISHED PARSING NAME?
|
// FINISHED PARSING NAME?
|
||||||
case '\t':
|
case '\t':
|
||||||
if ( mode != 'n' ) goto regchar;
|
if ( mode != 'n' ) goto regchar;
|
||||||
mode = 'w';
|
mode = 'w';
|
||||||
break;
|
break;
|
||||||
// ESCAPE NEXT CHAR
|
// ESCAPE NEXT CHAR
|
||||||
case '\\':
|
case '\\':
|
||||||
++in;
|
++in;
|
||||||
goto regchar;
|
goto regchar;
|
||||||
// FINISHED PARSING ONE OF POSSIBLY SEVERAL FILTERS?
|
// FINISHED PARSING ONE OF POSSIBLY SEVERAL FILTERS?
|
||||||
case '\r':
|
case '\r':
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\0':
|
case '\0':
|
||||||
// APPEND NEW FILTER TO LIST
|
// APPEND NEW FILTER TO LIST
|
||||||
if ( wildcard[0] ) {
|
if ( wildcard[0] ) {
|
||||||
// OUT: "name(wild)\tname(wild)"
|
// OUT: "name(wild)\tname(wild)"
|
||||||
char comp[2048];
|
char comp[2048];
|
||||||
sprintf(comp, "%s%.511s(%.511s)", ((_parsedfilt)?"\t":""),
|
sprintf(comp, "%s%.511s(%.511s)", ((_parsedfilt)?"\t":""),
|
||||||
name, wildcard);
|
name, wildcard);
|
||||||
_parsedfilt = strapp(_parsedfilt, comp);
|
_parsedfilt = strapp(_parsedfilt, comp);
|
||||||
_nfilters++;
|
_nfilters++;
|
||||||
//DEBUG printf("DEBUG: PARSED FILT NOW <%s>\n", _parsedfilt);
|
//DEBUG printf("DEBUG: PARSED FILT NOW <%s>\n", _parsedfilt);
|
||||||
}
|
}
|
||||||
// RESET
|
// RESET
|
||||||
wildcard[0] = name[0] = '\0';
|
wildcard[0] = name[0] = '\0';
|
||||||
mode = strchr(in, '\t') ? 'n' : 'w';
|
mode = strchr(in, '\t') ? 'n' : 'w';
|
||||||
// DONE?
|
// DONE?
|
||||||
if ( *in == '\0' ) return; // done
|
if ( *in == '\0' ) return; // done
|
||||||
else continue; // not done yet, more filters
|
else continue; // not done yet, more filters
|
||||||
|
|
||||||
// Parse all other chars
|
// Parse all other chars
|
||||||
default: // handle all non-special chars
|
default: // handle all non-special chars
|
||||||
|
|
|
@ -292,9 +292,9 @@ void Fl_Native_File_Chooser::event_handler(NavEventCallbackMessage callBackSelec
|
||||||
}
|
}
|
||||||
if ( nfb->_btype == BROWSE_SAVE_FILE && nfb->preset_file() ) {
|
if ( nfb->_btype == BROWSE_SAVE_FILE && nfb->preset_file() ) {
|
||||||
const char *p, *q;
|
const char *p, *q;
|
||||||
p = nfb->preset_file();//don't use the path part of preset_file
|
p = nfb->preset_file(); // don't use the path part of preset_file
|
||||||
q = strrchr(p, '/');
|
q = strrchr(p, '/');
|
||||||
if(q == NULL) q = p; else q++;
|
if (q == NULL) q = p; else q++;
|
||||||
CFStringRef namestr = CFStringCreateWithCString(NULL,
|
CFStringRef namestr = CFStringCreateWithCString(NULL,
|
||||||
q,
|
q,
|
||||||
kCFStringEncodingUTF8);
|
kCFStringEncodingUTF8);
|
||||||
|
@ -314,7 +314,7 @@ void Fl_Native_File_Chooser::event_handler(NavEventCallbackMessage callBackSelec
|
||||||
nfb->_tempitem.version = kNavMenuItemSpecVersion;
|
nfb->_tempitem.version = kNavMenuItemSpecVersion;
|
||||||
nfb->_tempitem.menuCreator = 'extn';
|
nfb->_tempitem.menuCreator = 'extn';
|
||||||
nfb->_tempitem.menuType = nfb->_filt_value;
|
nfb->_tempitem.menuType = nfb->_filt_value;
|
||||||
*nfb->_tempitem.menuItemName = '\0'; // needed on 10.3+
|
*nfb->_tempitem.menuItemName = '\0'; // needed on 10.3+
|
||||||
NavCustomControl(cbparm->context,
|
NavCustomControl(cbparm->context,
|
||||||
kNavCtlSelectCustomType,
|
kNavCtlSelectCustomType,
|
||||||
&(nfb->_tempitem));
|
&(nfb->_tempitem));
|
||||||
|
@ -408,11 +408,11 @@ Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
|
||||||
|
|
||||||
// DESTRUCTOR
|
// DESTRUCTOR
|
||||||
Fl_Native_File_Chooser::~Fl_Native_File_Chooser() {
|
Fl_Native_File_Chooser::~Fl_Native_File_Chooser() {
|
||||||
// _opts // nothing to manage
|
// _opts // nothing to manage
|
||||||
#ifndef __APPLE_COCOA__
|
#ifndef __APPLE_COCOA__
|
||||||
if (_ref) { NavDialogDispose(_ref); _ref = NULL; }
|
if (_ref) { NavDialogDispose(_ref); _ref = NULL; }
|
||||||
#endif
|
#endif
|
||||||
// _options // nothing to manage
|
// _options // nothing to manage
|
||||||
// _keepstate // nothing to manage
|
// _keepstate // nothing to manage
|
||||||
// _tempitem // nothing to manage
|
// _tempitem // nothing to manage
|
||||||
clear_pathnames();
|
clear_pathnames();
|
||||||
|
@ -421,7 +421,7 @@ Fl_Native_File_Chooser::~Fl_Native_File_Chooser() {
|
||||||
_preset_file = strfree(_preset_file);
|
_preset_file = strfree(_preset_file);
|
||||||
_filter = strfree(_filter);
|
_filter = strfree(_filter);
|
||||||
//_filt_names // managed by clear_filters()
|
//_filt_names // managed by clear_filters()
|
||||||
//_filt_patt[i] // managed by clear_filters()
|
//_filt_patt[i] // managed by clear_filters()
|
||||||
//_filt_total // managed by clear_filters()
|
//_filt_total // managed by clear_filters()
|
||||||
clear_filters();
|
clear_filters();
|
||||||
//_filt_value // nothing to manage
|
//_filt_value // nothing to manage
|
||||||
|
@ -566,7 +566,7 @@ int Fl_Native_File_Chooser::post() {
|
||||||
// Prompt user for filename to 'save as'
|
// Prompt user for filename to 'save as'
|
||||||
if ((err = NavCreatePutFileDialog(&_opts, // options
|
if ((err = NavCreatePutFileDialog(&_opts, // options
|
||||||
0, // file types
|
0, // file types
|
||||||
kNavGenericSignature, //file creator
|
kNavGenericSignature, // file creator
|
||||||
event_handler, // event handler
|
event_handler, // event handler
|
||||||
(void*)this, // callback data
|
(void*)this, // callback data
|
||||||
&_ref)) != noErr ) { // dialog ref
|
&_ref)) != noErr ) { // dialog ref
|
||||||
|
@ -800,13 +800,13 @@ void Fl_Native_File_Chooser::parse_filter(const char *in) {
|
||||||
#ifndef __APPLE_COCOA__
|
#ifndef __APPLE_COCOA__
|
||||||
// STATIC: FILTER CALLBACK
|
// STATIC: FILTER CALLBACK
|
||||||
Boolean Fl_Native_File_Chooser::filter_proc_cb(AEDesc *theItem,
|
Boolean Fl_Native_File_Chooser::filter_proc_cb(AEDesc *theItem,
|
||||||
void *info,
|
void *info,
|
||||||
void *callBackUD,
|
void *callBackUD,
|
||||||
NavFilterModes filterMode) {
|
NavFilterModes filterMode) {
|
||||||
return((Fl_Native_File_Chooser*)callBackUD)->filter_proc_cb2(theItem,
|
return((Fl_Native_File_Chooser*)callBackUD)->filter_proc_cb2(theItem,
|
||||||
info,
|
info,
|
||||||
callBackUD,
|
callBackUD,
|
||||||
filterMode);
|
filterMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FILTER CALLBACK
|
// FILTER CALLBACK
|
||||||
|
@ -814,9 +814,9 @@ Boolean Fl_Native_File_Chooser::filter_proc_cb(AEDesc *theItem,
|
||||||
// false if no match.
|
// false if no match.
|
||||||
//
|
//
|
||||||
Boolean Fl_Native_File_Chooser::filter_proc_cb2(AEDesc *theItem,
|
Boolean Fl_Native_File_Chooser::filter_proc_cb2(AEDesc *theItem,
|
||||||
void *info,
|
void *info,
|
||||||
void *callBackUD,
|
void *callBackUD,
|
||||||
NavFilterModes filterMode) {
|
NavFilterModes filterMode) {
|
||||||
// All files chosen or no filters
|
// All files chosen or no filters
|
||||||
if ( _filt_value == _filt_total ) return(true);
|
if ( _filt_value == _filt_total ) return(true);
|
||||||
|
|
||||||
|
@ -860,11 +860,11 @@ const char* Fl_Native_File_Chooser::preset_file() {
|
||||||
int Fl_Native_File_Chooser::get_saveas_basename(void) {
|
int Fl_Native_File_Chooser::get_saveas_basename(void) {
|
||||||
char *q = strdup( [[(NSSavePanel*)_panel filename] fileSystemRepresentation] );
|
char *q = strdup( [[(NSSavePanel*)_panel filename] fileSystemRepresentation] );
|
||||||
id delegate = [(NSSavePanel*)_panel delegate];
|
id delegate = [(NSSavePanel*)_panel delegate];
|
||||||
if(delegate != nil) {
|
if (delegate != nil) {
|
||||||
const char *d = [[(NSSavePanel*)_panel directory] fileSystemRepresentation];
|
const char *d = [[(NSSavePanel*)_panel directory] fileSystemRepresentation];
|
||||||
int l = strlen(d) + 1;
|
int l = strlen(d) + 1;
|
||||||
int lu = strlen(UNLIKELYPREFIX);
|
int lu = strlen(UNLIKELYPREFIX);
|
||||||
//remove UNLIKELYPREFIX between directory and filename parts
|
// Remove UNLIKELYPREFIX between directory and filename parts
|
||||||
memmove(q + l, q + l + lu, strlen(q + l + lu) + 1);
|
memmove(q + l, q + l + lu, strlen(q + l + lu) + 1);
|
||||||
}
|
}
|
||||||
set_single_pathname( q );
|
set_single_pathname( q );
|
||||||
|
@ -909,7 +909,7 @@ void Fl_Native_File_Chooser::type(int val) {
|
||||||
}
|
}
|
||||||
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
|
- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename
|
||||||
{
|
{
|
||||||
if( [nspopup indexOfSelectedItem] == [nspopup numberOfItems] - 1) return YES;
|
if ( [nspopup indexOfSelectedItem] == [nspopup numberOfItems] - 1) return YES;
|
||||||
const char *pathname = [filename fileSystemRepresentation];
|
const char *pathname = [filename fileSystemRepresentation];
|
||||||
if ( fl_filename_isdir(pathname) ) return YES;
|
if ( fl_filename_isdir(pathname) ) return YES;
|
||||||
if ( fl_filename_match(pathname, filter_pattern[ [nspopup indexOfSelectedItem] ]) ) return YES;
|
if ( fl_filename_match(pathname, filter_pattern[ [nspopup indexOfSelectedItem] ]) ) return YES;
|
||||||
|
@ -928,7 +928,7 @@ void Fl_Native_File_Chooser::type(int val) {
|
||||||
@implementation FLsaveDelegate
|
@implementation FLsaveDelegate
|
||||||
- (NSString *)panel:(id)sender userEnteredFilename:(NSString *)filename confirmed:(BOOL)okFlag
|
- (NSString *)panel:(id)sender userEnteredFilename:(NSString *)filename confirmed:(BOOL)okFlag
|
||||||
{
|
{
|
||||||
if(! okFlag) return filename;
|
if (! okFlag) return filename;
|
||||||
// User has clicked save, and no overwrite confirmation should occur.
|
// User has clicked save, and no overwrite confirmation should occur.
|
||||||
// To get the latter, we need to change the name we return (hence the prefix):
|
// To get the latter, we need to change the name we return (hence the prefix):
|
||||||
return [@ UNLIKELYPREFIX stringByAppendingString:filename];
|
return [@ UNLIKELYPREFIX stringByAppendingString:filename];
|
||||||
|
@ -961,7 +961,7 @@ static NSPopUpButton *createPopupAccessory(NSSavePanel *panel, const char *filte
|
||||||
CFRelease(tab);
|
CFRelease(tab);
|
||||||
[popup addItemsWithTitles:(NSArray*)array];
|
[popup addItemsWithTitles:(NSArray*)array];
|
||||||
NSMenuItem *item = [popup itemWithTitle:@""];
|
NSMenuItem *item = [popup itemWithTitle:@""];
|
||||||
if(item) [popup removeItemWithTitle:@""];
|
if (item) [popup removeItemWithTitle:@""];
|
||||||
CFRelease(array);
|
CFRelease(array);
|
||||||
[popup selectItemAtIndex:rank];
|
[popup selectItemAtIndex:rank];
|
||||||
[panel setAccessoryView:view];
|
[panel setAccessoryView:view];
|
||||||
|
@ -1002,18 +1002,18 @@ int Fl_Native_File_Chooser::post() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHOW THE DIALOG
|
// SHOW THE DIALOG
|
||||||
if( [(NSSavePanel*)_panel isKindOfClass:[NSOpenPanel class]] ) {
|
if ( [(NSSavePanel*)_panel isKindOfClass:[NSOpenPanel class]] ) {
|
||||||
NSPopUpButton *popup = nil;
|
NSPopUpButton *popup = nil;
|
||||||
if(_filt_total) {
|
if (_filt_total) {
|
||||||
char *p; p = _filter;
|
char *p; p = _filter;
|
||||||
char *q; q = new char[strlen(p) + 1];
|
char *q; q = new char[strlen(p) + 1];
|
||||||
char *r, *s, *t;
|
char *r, *s, *t;
|
||||||
t = q;
|
t = q;
|
||||||
do { //copy to t what is in _filter removing what is between \t and \n, if any
|
do { // copy to t what is in _filter removing what is between \t and \n, if any
|
||||||
r = strchr(p, '\n');
|
r = strchr(p, '\n');
|
||||||
if(!r) r = p + strlen(p) - 1;
|
if (!r) r = p + strlen(p) - 1;
|
||||||
s = strchr(p, '\t');
|
s = strchr(p, '\t');
|
||||||
if(s && s < r) { memcpy(q, p, s - p); q += s - p; *(q++) = '\n'; }
|
if (s && s < r) { memcpy(q, p, s - p); q += s - p; *(q++) = '\n'; }
|
||||||
else { memcpy(q, p, r - p + 1); q += r - p + 1; }
|
else { memcpy(q, p, r - p + 1); q += r - p + 1; }
|
||||||
*q = 0;
|
*q = 0;
|
||||||
p = r + 1;
|
p = r + 1;
|
||||||
|
@ -1025,7 +1025,7 @@ int Fl_Native_File_Chooser::post() {
|
||||||
[popup setAction:@selector(validateVisibleColumns)];
|
[popup setAction:@selector(validateVisibleColumns)];
|
||||||
[popup setTarget:(NSObject*)_panel];
|
[popup setTarget:(NSObject*)_panel];
|
||||||
static FLopenDelegate *openDelegate = nil;
|
static FLopenDelegate *openDelegate = nil;
|
||||||
if(openDelegate == nil) {
|
if (openDelegate == nil) {
|
||||||
// not to be ever freed
|
// not to be ever freed
|
||||||
openDelegate = [[FLopenDelegate alloc] init];
|
openDelegate = [[FLopenDelegate alloc] init];
|
||||||
}
|
}
|
||||||
|
@ -1035,17 +1035,17 @@ int Fl_Native_File_Chooser::post() {
|
||||||
NSString *dir = nil;
|
NSString *dir = nil;
|
||||||
NSString *fname = nil;
|
NSString *fname = nil;
|
||||||
NSString *preset = nil;
|
NSString *preset = nil;
|
||||||
if(_preset_file) {
|
if (_preset_file) {
|
||||||
preset = [[NSString alloc] initWithUTF8String:_preset_file];
|
preset = [[NSString alloc] initWithUTF8String:_preset_file];
|
||||||
if(strchr(_preset_file, '/') != NULL)
|
if (strchr(_preset_file, '/') != NULL)
|
||||||
dir = [[NSString alloc] initWithString:[preset stringByDeletingLastPathComponent]];
|
dir = [[NSString alloc] initWithString:[preset stringByDeletingLastPathComponent]];
|
||||||
fname = [preset lastPathComponent];
|
fname = [preset lastPathComponent];
|
||||||
}
|
}
|
||||||
if(_directory && !dir) dir = [[NSString alloc] initWithUTF8String:_directory];
|
if (_directory && !dir) dir = [[NSString alloc] initWithUTF8String:_directory];
|
||||||
retval = [(NSOpenPanel*)_panel runModalForDirectory:dir file:fname types:nil];
|
retval = [(NSOpenPanel*)_panel runModalForDirectory:dir file:fname types:nil];
|
||||||
[dir release];
|
[dir release];
|
||||||
[preset release];
|
[preset release];
|
||||||
if(_filt_total) {
|
if (_filt_total) {
|
||||||
_filt_value = [popup indexOfSelectedItem];
|
_filt_value = [popup indexOfSelectedItem];
|
||||||
}
|
}
|
||||||
if ( retval == NSOKButton ) {
|
if ( retval == NSOKButton ) {
|
||||||
|
@ -1063,24 +1063,24 @@ int Fl_Native_File_Chooser::post() {
|
||||||
NSString *fname = nil;
|
NSString *fname = nil;
|
||||||
NSString *preset = nil;
|
NSString *preset = nil;
|
||||||
NSPopUpButton *popup = nil;
|
NSPopUpButton *popup = nil;
|
||||||
if( !(_options & SAVEAS_CONFIRM) ) {
|
if ( !(_options & SAVEAS_CONFIRM) ) {
|
||||||
static FLsaveDelegate *saveDelegate = nil;
|
static FLsaveDelegate *saveDelegate = nil;
|
||||||
if(saveDelegate == nil)saveDelegate = [[FLsaveDelegate alloc] init];//not to be ever freed
|
if (saveDelegate == nil)saveDelegate = [[FLsaveDelegate alloc] init]; // not to be ever freed
|
||||||
[(NSSavePanel*)_panel setDelegate:saveDelegate];
|
[(NSSavePanel*)_panel setDelegate:saveDelegate];
|
||||||
}
|
}
|
||||||
if(_preset_file) {
|
if (_preset_file) {
|
||||||
preset = [[NSString alloc] initWithUTF8String:_preset_file];
|
preset = [[NSString alloc] initWithUTF8String:_preset_file];
|
||||||
if(strchr(_preset_file, '/') != NULL) {
|
if (strchr(_preset_file, '/') != NULL) {
|
||||||
dir = [[NSString alloc] initWithString:[preset stringByDeletingLastPathComponent]];
|
dir = [[NSString alloc] initWithString:[preset stringByDeletingLastPathComponent]];
|
||||||
}
|
}
|
||||||
fname = [preset lastPathComponent];
|
fname = [preset lastPathComponent];
|
||||||
}
|
}
|
||||||
if(_directory && !dir) dir = [[NSString alloc] initWithUTF8String:_directory];
|
if (_directory && !dir) dir = [[NSString alloc] initWithUTF8String:_directory];
|
||||||
if(_filt_total) {
|
if (_filt_total) {
|
||||||
popup = createPopupAccessory((NSSavePanel*)_panel, _filter, "Format:", _filt_value);
|
popup = createPopupAccessory((NSSavePanel*)_panel, _filter, "Format:", _filt_value);
|
||||||
}
|
}
|
||||||
retval = [(NSSavePanel*)_panel runModalForDirectory:dir file:fname];
|
retval = [(NSSavePanel*)_panel runModalForDirectory:dir file:fname];
|
||||||
if(_filt_total) {
|
if (_filt_total) {
|
||||||
_filt_value = [popup indexOfSelectedItem];
|
_filt_value = [popup indexOfSelectedItem];
|
||||||
}
|
}
|
||||||
[dir release];
|
[dir release];
|
||||||
|
|
|
@ -108,11 +108,12 @@ static void dnullcat(char*&wp, const char *string, int n = -1 ) {
|
||||||
//
|
//
|
||||||
char *wp2 = wp;
|
char *wp2 = wp;
|
||||||
if ( *(wp2+0) != '\0' && *(wp2+1) != '\0' ) {
|
if ( *(wp2+0) != '\0' && *(wp2+1) != '\0' ) {
|
||||||
for ( ; 1; wp2++ )
|
for ( ; 1; wp2++ ) {
|
||||||
if ( *(wp2+0) == '\0' && *(wp2+1) == '\0' ) {
|
if ( *(wp2+0) == '\0' && *(wp2+1) == '\0' ) {
|
||||||
wp2++;
|
wp2++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( n == -1 ) n = strlen(string);
|
if ( n == -1 ) n = strlen(string);
|
||||||
|
@ -278,7 +279,7 @@ int Fl_Native_File_Chooser::showfile() {
|
||||||
ClearOFN();
|
ClearOFN();
|
||||||
clear_pathnames();
|
clear_pathnames();
|
||||||
size_t fsize = MAX_PATH;
|
size_t fsize = MAX_PATH;
|
||||||
_ofn.Flags |= OFN_NOVALIDATE; // prevent disabling of front slashes
|
_ofn.Flags |= OFN_NOVALIDATE; // prevent disabling of front slashes
|
||||||
_ofn.Flags |= OFN_HIDEREADONLY; // hide goofy readonly flag
|
_ofn.Flags |= OFN_HIDEREADONLY; // hide goofy readonly flag
|
||||||
// USE NEW BROWSER
|
// USE NEW BROWSER
|
||||||
_ofn.Flags |= OFN_EXPLORER; // use newer explorer windows
|
_ofn.Flags |= OFN_EXPLORER; // use newer explorer windows
|
||||||
|
@ -394,41 +395,41 @@ int Fl_Native_File_Chooser::showfile() {
|
||||||
switch ( _btype ) {
|
switch ( _btype ) {
|
||||||
case BROWSE_FILE:
|
case BROWSE_FILE:
|
||||||
case BROWSE_SAVE_FILE:
|
case BROWSE_SAVE_FILE:
|
||||||
set_single_pathname(wchartoutf8(_ofn.lpstrFile));
|
set_single_pathname(wchartoutf8(_ofn.lpstrFile));
|
||||||
// Win2Unix(_pathnames[_tpathnames-1]);
|
// Win2Unix(_pathnames[_tpathnames-1]);
|
||||||
break;
|
break;
|
||||||
case BROWSE_MULTI_FILE: {
|
case BROWSE_MULTI_FILE: {
|
||||||
// EXTRACT MULTIPLE FILENAMES
|
// EXTRACT MULTIPLE FILENAMES
|
||||||
const WCHAR *dirname = _ofn.lpstrFile;
|
const WCHAR *dirname = _ofn.lpstrFile;
|
||||||
int dirlen = wcslen(dirname);
|
int dirlen = wcslen(dirname);
|
||||||
if ( dirlen > 0 ) {
|
if ( dirlen > 0 ) {
|
||||||
// WALK STRING SEARCHING FOR 'DOUBLE-NULL'
|
// WALK STRING SEARCHING FOR 'DOUBLE-NULL'
|
||||||
// eg. "/dir/name\0foo1\0foo2\0foo3\0\0"
|
// eg. "/dir/name\0foo1\0foo2\0foo3\0\0"
|
||||||
//
|
|
||||||
char pathname[MAX_PATH];
|
|
||||||
for ( const WCHAR *s = dirname + dirlen + 1;
|
|
||||||
*s; s+= (wcslen(s)+1)) {
|
|
||||||
strcpy(pathname, wchartoutf8(dirname));
|
|
||||||
strcat(pathname, "\\");
|
|
||||||
strcat(pathname, wchartoutf8(s));
|
|
||||||
add_pathname(pathname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// XXX
|
|
||||||
// Work around problem where pasted forward-slash pathname
|
|
||||||
// into the file browser causes new "Explorer" interface
|
|
||||||
// not to grok forward slashes, passing back as a 'filename'..!
|
|
||||||
//
|
//
|
||||||
if ( _tpathnames == 0 ) {
|
char pathname[MAX_PATH];
|
||||||
add_pathname(wchartoutf8(dirname));
|
for ( const WCHAR *s = dirname + dirlen + 1;
|
||||||
// Win2Unix(_pathnames[_tpathnames-1]);
|
*s; s+= (wcslen(s)+1)) {
|
||||||
|
strcpy(pathname, wchartoutf8(dirname));
|
||||||
|
strcat(pathname, "\\");
|
||||||
|
strcat(pathname, wchartoutf8(s));
|
||||||
|
add_pathname(pathname);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case BROWSE_DIRECTORY:
|
// XXX
|
||||||
case BROWSE_MULTI_DIRECTORY:
|
// Work around problem where pasted forward-slash pathname
|
||||||
case BROWSE_SAVE_DIRECTORY:
|
// into the file browser causes new "Explorer" interface
|
||||||
abort(); // never happens: handled by showdir()
|
// not to grok forward slashes, passing back as a 'filename'..!
|
||||||
|
//
|
||||||
|
if ( _tpathnames == 0 ) {
|
||||||
|
add_pathname(wchartoutf8(dirname));
|
||||||
|
// Win2Unix(_pathnames[_tpathnames-1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BROWSE_DIRECTORY:
|
||||||
|
case BROWSE_MULTI_DIRECTORY:
|
||||||
|
case BROWSE_SAVE_DIRECTORY:
|
||||||
|
abort(); // never happens: handled by showdir()
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -447,7 +448,7 @@ int CALLBACK Fl_Native_File_Chooser::Dir_CB(HWND win, UINT msg, LPARAM param, LP
|
||||||
if ( SHGetPathFromIDList((ITEMIDLIST*)param, path) ) {
|
if ( SHGetPathFromIDList((ITEMIDLIST*)param, path) ) {
|
||||||
::SendMessage(win, BFFM_ENABLEOK, 0, 1);
|
::SendMessage(win, BFFM_ENABLEOK, 0, 1);
|
||||||
} else {
|
} else {
|
||||||
//disable ok button if not a path
|
// disable ok button if not a path
|
||||||
::SendMessage(win, BFFM_ENABLEOK, 0, 0);
|
::SendMessage(win, BFFM_ENABLEOK, 0, 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -625,7 +626,7 @@ void Fl_Native_File_Chooser::clear_filters() {
|
||||||
|
|
||||||
// ADD A FILTER
|
// ADD A FILTER
|
||||||
void Fl_Native_File_Chooser::add_filter(const char *name_in, // name of filter (optional: can be null)
|
void Fl_Native_File_Chooser::add_filter(const char *name_in, // name of filter (optional: can be null)
|
||||||
const char *winfilter) { // windows style filter (eg. "*.cxx;*.h")
|
const char *winfilter) { // windows style filter (eg. "*.cxx;*.h")
|
||||||
// No name? Make one..
|
// No name? Make one..
|
||||||
char name[1024];
|
char name[1024];
|
||||||
if ( !name_in || name_in[0] == '\0' ) {
|
if ( !name_in || name_in[0] == '\0' ) {
|
||||||
|
|
Loading…
Reference in New Issue