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
@ -142,7 +142,7 @@ int Fl_Native_File_Chooser::type() const {
|
||||
-------------- ----------------------------------------------- ------- ------- -------
|
||||
NEW_FOLDER Shows the 'New Folder' button. Ignored Used 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
|
||||
*/
|
||||
void Fl_Native_File_Chooser::options(int val) {
|
||||
|
@ -292,9 +292,9 @@ void Fl_Native_File_Chooser::event_handler(NavEventCallbackMessage callBackSelec
|
||||
}
|
||||
if ( nfb->_btype == BROWSE_SAVE_FILE && nfb->preset_file() ) {
|
||||
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, '/');
|
||||
if(q == NULL) q = p; else q++;
|
||||
if (q == NULL) q = p; else q++;
|
||||
CFStringRef namestr = CFStringCreateWithCString(NULL,
|
||||
q,
|
||||
kCFStringEncodingUTF8);
|
||||
@ -566,7 +566,7 @@ int Fl_Native_File_Chooser::post() {
|
||||
// Prompt user for filename to 'save as'
|
||||
if ((err = NavCreatePutFileDialog(&_opts, // options
|
||||
0, // file types
|
||||
kNavGenericSignature, //file creator
|
||||
kNavGenericSignature, // file creator
|
||||
event_handler, // event handler
|
||||
(void*)this, // callback data
|
||||
&_ref)) != noErr ) { // dialog ref
|
||||
@ -860,11 +860,11 @@ const char* Fl_Native_File_Chooser::preset_file() {
|
||||
int Fl_Native_File_Chooser::get_saveas_basename(void) {
|
||||
char *q = strdup( [[(NSSavePanel*)_panel filename] fileSystemRepresentation] );
|
||||
id delegate = [(NSSavePanel*)_panel delegate];
|
||||
if(delegate != nil) {
|
||||
if (delegate != nil) {
|
||||
const char *d = [[(NSSavePanel*)_panel directory] fileSystemRepresentation];
|
||||
int l = strlen(d) + 1;
|
||||
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);
|
||||
}
|
||||
set_single_pathname( q );
|
||||
@ -909,7 +909,7 @@ void Fl_Native_File_Chooser::type(int val) {
|
||||
}
|
||||
- (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];
|
||||
if ( fl_filename_isdir(pathname) ) 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
|
||||
- (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.
|
||||
// To get the latter, we need to change the name we return (hence the prefix):
|
||||
return [@ UNLIKELYPREFIX stringByAppendingString:filename];
|
||||
@ -961,7 +961,7 @@ static NSPopUpButton *createPopupAccessory(NSSavePanel *panel, const char *filte
|
||||
CFRelease(tab);
|
||||
[popup addItemsWithTitles:(NSArray*)array];
|
||||
NSMenuItem *item = [popup itemWithTitle:@""];
|
||||
if(item) [popup removeItemWithTitle:@""];
|
||||
if (item) [popup removeItemWithTitle:@""];
|
||||
CFRelease(array);
|
||||
[popup selectItemAtIndex:rank];
|
||||
[panel setAccessoryView:view];
|
||||
@ -1002,18 +1002,18 @@ int Fl_Native_File_Chooser::post() {
|
||||
}
|
||||
|
||||
// SHOW THE DIALOG
|
||||
if( [(NSSavePanel*)_panel isKindOfClass:[NSOpenPanel class]] ) {
|
||||
if ( [(NSSavePanel*)_panel isKindOfClass:[NSOpenPanel class]] ) {
|
||||
NSPopUpButton *popup = nil;
|
||||
if(_filt_total) {
|
||||
if (_filt_total) {
|
||||
char *p; p = _filter;
|
||||
char *q; q = new char[strlen(p) + 1];
|
||||
char *r, *s, *t;
|
||||
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');
|
||||
if(!r) r = p + strlen(p) - 1;
|
||||
if (!r) r = p + strlen(p) - 1;
|
||||
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; }
|
||||
*q = 0;
|
||||
p = r + 1;
|
||||
@ -1025,7 +1025,7 @@ int Fl_Native_File_Chooser::post() {
|
||||
[popup setAction:@selector(validateVisibleColumns)];
|
||||
[popup setTarget:(NSObject*)_panel];
|
||||
static FLopenDelegate *openDelegate = nil;
|
||||
if(openDelegate == nil) {
|
||||
if (openDelegate == nil) {
|
||||
// not to be ever freed
|
||||
openDelegate = [[FLopenDelegate alloc] init];
|
||||
}
|
||||
@ -1035,17 +1035,17 @@ int Fl_Native_File_Chooser::post() {
|
||||
NSString *dir = nil;
|
||||
NSString *fname = nil;
|
||||
NSString *preset = nil;
|
||||
if(_preset_file) {
|
||||
if (_preset_file) {
|
||||
preset = [[NSString alloc] initWithUTF8String:_preset_file];
|
||||
if(strchr(_preset_file, '/') != NULL)
|
||||
if (strchr(_preset_file, '/') != NULL)
|
||||
dir = [[NSString alloc] initWithString:[preset stringByDeletingLastPathComponent]];
|
||||
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];
|
||||
[dir release];
|
||||
[preset release];
|
||||
if(_filt_total) {
|
||||
if (_filt_total) {
|
||||
_filt_value = [popup indexOfSelectedItem];
|
||||
}
|
||||
if ( retval == NSOKButton ) {
|
||||
@ -1063,24 +1063,24 @@ int Fl_Native_File_Chooser::post() {
|
||||
NSString *fname = nil;
|
||||
NSString *preset = nil;
|
||||
NSPopUpButton *popup = nil;
|
||||
if( !(_options & SAVEAS_CONFIRM) ) {
|
||||
if ( !(_options & SAVEAS_CONFIRM) ) {
|
||||
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];
|
||||
}
|
||||
if(_preset_file) {
|
||||
if (_preset_file) {
|
||||
preset = [[NSString alloc] initWithUTF8String:_preset_file];
|
||||
if(strchr(_preset_file, '/') != NULL) {
|
||||
if (strchr(_preset_file, '/') != NULL) {
|
||||
dir = [[NSString alloc] initWithString:[preset stringByDeletingLastPathComponent]];
|
||||
}
|
||||
fname = [preset lastPathComponent];
|
||||
}
|
||||
if(_directory && !dir) dir = [[NSString alloc] initWithUTF8String:_directory];
|
||||
if(_filt_total) {
|
||||
if (_directory && !dir) dir = [[NSString alloc] initWithUTF8String:_directory];
|
||||
if (_filt_total) {
|
||||
popup = createPopupAccessory((NSSavePanel*)_panel, _filter, "Format:", _filt_value);
|
||||
}
|
||||
retval = [(NSSavePanel*)_panel runModalForDirectory:dir file:fname];
|
||||
if(_filt_total) {
|
||||
if (_filt_total) {
|
||||
_filt_value = [popup indexOfSelectedItem];
|
||||
}
|
||||
[dir release];
|
||||
|
@ -108,12 +108,13 @@ static void dnullcat(char*&wp, const char *string, int n = -1 ) {
|
||||
//
|
||||
char *wp2 = wp;
|
||||
if ( *(wp2+0) != '\0' && *(wp2+1) != '\0' ) {
|
||||
for ( ; 1; wp2++ )
|
||||
for ( ; 1; wp2++ ) {
|
||||
if ( *(wp2+0) == '\0' && *(wp2+1) == '\0' ) {
|
||||
wp2++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( n == -1 ) n = strlen(string);
|
||||
strncpy(wp2, string, n);
|
||||
@ -447,7 +448,7 @@ int CALLBACK Fl_Native_File_Chooser::Dir_CB(HWND win, UINT msg, LPARAM param, LP
|
||||
if ( SHGetPathFromIDList((ITEMIDLIST*)param, path) ) {
|
||||
::SendMessage(win, BFFM_ENABLEOK, 0, 1);
|
||||
} else {
|
||||
//disable ok button if not a path
|
||||
// disable ok button if not a path
|
||||
::SendMessage(win, BFFM_ENABLEOK, 0, 0);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user