themes: Workaround for bug where a background color of RGB 0,0,0 in Black color schem...
[ntk.git] / src / Fl_Native_File_Chooser_common.cxx
blobf5d45f194c1f6b1297c186bdfa4b573d266529c1
1 // "$Id: Fl_Native_File_Chooser_common.cxx 7977 2010-12-08 13:16:27Z AlbrechtS $"
2 //
3 // FLTK native OS file chooser widget
4 //
5 // Copyright 1998-2010 by Bill Spitzak and others.
6 // Copyright 2004 Greg Ercolano.
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 // USA.
23 // Please report all bugs and problems to:
25 // http://www.fltk.org/str.php
28 #include <string.h>
29 #include <FL/Enumerations.H>
31 // COPY A STRING WITH 'new'
32 // Value can be NULL
34 static char *strnew(const char *val) {
35 if ( val == NULL ) return(NULL);
36 char *s = new char[strlen(val)+1];
37 strcpy(s, val);
38 return(s);
41 // FREE STRING CREATED WITH strnew(), NULLS OUT STRING
42 // Value can be NULL
44 static char *strfree(char *val) {
45 if ( val ) delete [] val;
46 return(NULL);
49 // 'DYNAMICALLY' APPEND ONE STRING TO ANOTHER
50 // Returns newly allocated string, or NULL
51 // if s && val == NULL.
52 // 's' can be NULL; returns a strnew(val).
53 // 'val' can be NULL; s is returned unmodified.
55 // Usage:
56 // char *s = strnew("foo"); // s = "foo"
57 // s = strapp(s, "bar"); // s = "foobar"
59 #if !defined(WIN32)
60 static char *strapp(char *s, const char *val) {
61 if ( ! val ) {
62 return(s); // Nothing to append? return s
64 if ( ! s ) {
65 return(strnew(val)); // New string? return copy of val
67 char *news = new char[strlen(s)+strlen(val)+1];
68 strcpy(news, s);
69 strcat(news, val);
70 delete [] s; // delete old string
71 return(news); // return new copy
73 #endif
75 // APPEND A CHARACTER TO A STRING
76 // This does NOT allocate space for the new character.
78 static void chrcat(char *s, char c) {
79 char tmp[2] = { c, '\0' };
80 strcat(s, tmp);
84 // End of "$Id: Fl_Native_File_Chooser_common.cxx 7977 2010-12-08 13:16:27Z AlbrechtS $".