Moved Fl_Preferences documentation to the correct places.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6490 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
13267ea186
commit
2ecabfa676
1
CHANGES
1
CHANGES
@ -1,5 +1,6 @@
|
|||||||
CHANGES IN FLTK 1.3.0
|
CHANGES IN FLTK 1.3.0
|
||||||
|
|
||||||
|
- Fixed menu positon non screen border (STR #2057)
|
||||||
- Improved stability of fl_read_image (STR #2021)
|
- Improved stability of fl_read_image (STR #2021)
|
||||||
- Fixed adding an idle handler during
|
- Fixed adding an idle handler during
|
||||||
a draw() call (STR #1950)
|
a draw() call (STR #1950)
|
||||||
|
@ -100,232 +100,26 @@ public:
|
|||||||
char entryExists( const char *key );
|
char entryExists( const char *key );
|
||||||
char deleteEntry( const char *entry );
|
char deleteEntry( const char *entry );
|
||||||
|
|
||||||
/**
|
|
||||||
Sets an entry (name/value pair). The return value indicates if there
|
|
||||||
was a problem storing the data in memory. However it does not
|
|
||||||
reflect if the value was actually stored in the preferences
|
|
||||||
file.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[in] value set this entry to \a value
|
|
||||||
\return 0 if setting the value failed
|
|
||||||
*/
|
|
||||||
char set( const char *entry, int value );
|
char set( const char *entry, int value );
|
||||||
|
|
||||||
/**
|
|
||||||
Sets an entry (name/value pair). The return value indicates if there
|
|
||||||
was a problem storing the data in memory. However it does not
|
|
||||||
reflect if the value was actually stored in the preferences
|
|
||||||
file.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[in] value set this entry to \a value
|
|
||||||
\return 0 if setting the value failed
|
|
||||||
*/
|
|
||||||
char set( const char *entry, float value );
|
char set( const char *entry, float value );
|
||||||
|
|
||||||
/**
|
|
||||||
Sets an entry (name/value pair). The return value indicates if there
|
|
||||||
was a problem storing the data in memory. However it does not
|
|
||||||
reflect if the value was actually stored in the preferences
|
|
||||||
file.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[in] value set this entry to \a value
|
|
||||||
\param[in] precision number of decimal digits to represent value
|
|
||||||
\return 0 if setting the value failed
|
|
||||||
*/
|
|
||||||
char set( const char *entry, float value, int precision );
|
char set( const char *entry, float value, int precision );
|
||||||
|
|
||||||
/**
|
|
||||||
Sets an entry (name/value pair). The return value indicates if there
|
|
||||||
was a problem storing the data in memory. However it does not
|
|
||||||
reflect if the value was actually stored in the preferences
|
|
||||||
file.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[in] value set this entry to \a value
|
|
||||||
\return 0 if setting the value failed
|
|
||||||
*/
|
|
||||||
char set( const char *entry, double value );
|
char set( const char *entry, double value );
|
||||||
|
|
||||||
/**
|
|
||||||
Sets an entry (name/value pair). The return value indicates if there
|
|
||||||
was a problem storing the data in memory. However it does not
|
|
||||||
reflect if the value was actually stored in the preferences
|
|
||||||
file.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[in] value set this entry to \a value
|
|
||||||
\param[in] precision number of decimal digits to represent value
|
|
||||||
\return 0 if setting the value failed
|
|
||||||
*/
|
|
||||||
char set( const char *entry, double value, int precision );
|
char set( const char *entry, double value, int precision );
|
||||||
|
|
||||||
/**
|
|
||||||
Sets an entry (name/value pair). The return value indicates if there
|
|
||||||
was a problem storing the data in memory. However it does not
|
|
||||||
reflect if the value was actually stored in the preferences
|
|
||||||
file.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[in] value set this entry to \a value
|
|
||||||
\return 0 if setting the value failed
|
|
||||||
*/
|
|
||||||
char set( const char *entry, const char *value );
|
char set( const char *entry, const char *value );
|
||||||
|
|
||||||
/**
|
|
||||||
Sets an entry (name/value pair). The return value indicates if there
|
|
||||||
was a problem storing the data in memory. However it does not
|
|
||||||
reflect if the value was actually stored in the preferences
|
|
||||||
file.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[in] value set this entry to \a value
|
|
||||||
\param[in] size of data array
|
|
||||||
\return 0 if setting the value failed
|
|
||||||
*/
|
|
||||||
char set( const char *entry, const void *value, int size );
|
char set( const char *entry, const void *value, int size );
|
||||||
|
|
||||||
|
char get( const char *entry, int &value, int defaultValue );
|
||||||
/**
|
|
||||||
Reads an entry from the group. A default value must be
|
|
||||||
supplied. The return value indicates if the value was available
|
|
||||||
(non-zero) or the default was used (0).
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[out] value returned from preferences or default value if none was set
|
|
||||||
\param[in] defaultValue default value to be used if no preference was set
|
|
||||||
\return 0 if the default value was used
|
|
||||||
*/
|
|
||||||
char get( const char *entry, int &value, int defaultValue );
|
|
||||||
|
|
||||||
/**
|
|
||||||
Reads an entry from the group. A default value must be
|
|
||||||
supplied. The return value indicates if the value was available
|
|
||||||
(non-zero) or the default was used (0).
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[out] value returned from preferences or default value if none was set
|
|
||||||
\param[in] defaultValue default value to be used if no preference was set
|
|
||||||
\return 0 if the default value was used
|
|
||||||
*/
|
|
||||||
char get( const char *entry, float &value, float defaultValue );
|
char get( const char *entry, float &value, float defaultValue );
|
||||||
|
|
||||||
/**
|
|
||||||
Reads an entry from the group. A default value must be
|
|
||||||
supplied. The return value indicates if the value was available
|
|
||||||
(non-zero) or the default was used (0).
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[out] value returned from preferences or default value if none was set
|
|
||||||
\param[in] defaultValue default value to be used if no preference was set
|
|
||||||
\return 0 if the default value was used
|
|
||||||
*/
|
|
||||||
char get( const char *entry, double &value, double defaultValue );
|
char get( const char *entry, double &value, double defaultValue );
|
||||||
|
|
||||||
/**
|
|
||||||
Reads an entry from the group. A default value must be
|
|
||||||
supplied. The return value indicates if the value was available
|
|
||||||
(non-zero) or the default was used (0). get() allocates memory of
|
|
||||||
sufficient size to hold the value. The buffer must be free'd by
|
|
||||||
the developer using 'free(value)'.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[out] value returned from preferences or default value if none was set
|
|
||||||
\param[in] defaultValue default value to be used if no preference was set
|
|
||||||
\return 0 if the default value was used
|
|
||||||
*/
|
|
||||||
char get( const char *entry, char *&value, const char *defaultValue );
|
char get( const char *entry, char *&value, const char *defaultValue );
|
||||||
|
|
||||||
/**
|
|
||||||
Reads an entry from the group. A default value must be
|
|
||||||
supplied. The return value indicates if the value was available
|
|
||||||
(non-zero) or the default was used (0).
|
|
||||||
'maxSize' is the maximum length of text that will be read.
|
|
||||||
The text buffer must allow for one additional byte for a trailling zero.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[out] value returned from preferences or default value if none was set
|
|
||||||
\param[in] defaultValue default value to be used if no preference was set
|
|
||||||
\param[in] maxSize maximum length of value plus one byte for a trailing zero
|
|
||||||
\return 0 if the default value was used
|
|
||||||
*/
|
|
||||||
char get( const char *entry, char *value, const char *defaultValue, int maxSize );
|
char get( const char *entry, char *value, const char *defaultValue, int maxSize );
|
||||||
|
|
||||||
/**
|
|
||||||
Reads an entry from the group. A default value must be
|
|
||||||
supplied. The return value indicates if the value was available
|
|
||||||
(non-zero) or the default was used (0). get() allocates memory of
|
|
||||||
sufficient size to hold the value. The buffer must be free'd by
|
|
||||||
the developer using 'free(value)'.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[out] value returned from preferences or default value if none was set
|
|
||||||
\param[in] defaultValue default value to be used if no preference was set
|
|
||||||
\param[in] defaultSize size of default value array
|
|
||||||
\return 0 if the default value was used
|
|
||||||
*/
|
|
||||||
char get( const char *entry, void *&value, const void *defaultValue, int defaultSize );
|
char get( const char *entry, void *&value, const void *defaultValue, int defaultSize );
|
||||||
|
|
||||||
/**
|
|
||||||
Reads an entry from the group. A default value must be
|
|
||||||
supplied. The return value indicates if the value was available
|
|
||||||
(non-zero) or the default was used (0).
|
|
||||||
'maxSize' is the maximum length of text that will be read.
|
|
||||||
|
|
||||||
\param[in] entry name of entry
|
|
||||||
\param[out] value returned from preferences or default value if none was set
|
|
||||||
\param[in] defaultValue default value to be used if no preference was set
|
|
||||||
\param[in] defaultSize size of default value array
|
|
||||||
\param[in] maxSize maximum length of value
|
|
||||||
\return 0 if the default value was used
|
|
||||||
|
|
||||||
\todo maxSize should receive the number of bytes that were read.
|
|
||||||
*/
|
|
||||||
char get( const char *entry, void *value, const void *defaultValue, int defaultSize, int maxSize );
|
char get( const char *entry, void *value, const void *defaultValue, int defaultSize, int maxSize );
|
||||||
|
|
||||||
/**
|
|
||||||
Returns the size of the value part of an entry.
|
|
||||||
|
|
||||||
\return size of value
|
|
||||||
*/
|
|
||||||
int size( const char *entry );
|
int size( const char *entry );
|
||||||
|
|
||||||
/**
|
|
||||||
\brief Creates a path that is related to the preferences file and
|
|
||||||
that is usable for additional application data.
|
|
||||||
|
|
||||||
This function creates a directory that is named after the preferences
|
|
||||||
database without the \c .prefs extension and located in the same directory.
|
|
||||||
It then fills the given buffer with the complete path name.
|
|
||||||
|
|
||||||
Exmaple:
|
|
||||||
\code
|
|
||||||
Fl_Preferences prefs( USER, "matthiasm.com", "test" );
|
|
||||||
char path[FL_PATH_MAX];
|
|
||||||
prefs.getUserdataPath( path );
|
|
||||||
\endcode
|
|
||||||
creates the preferences database in (MS Windows):
|
|
||||||
\code
|
|
||||||
c:/Documents and Settings/matt/Application Data/matthiasm.com/test.prefs
|
|
||||||
\endcode
|
|
||||||
and returns the userdata path:
|
|
||||||
\code
|
|
||||||
c:/Documents and Settings/matt/Application Data/matthiasm.com/test/
|
|
||||||
\endcode
|
|
||||||
|
|
||||||
\param[out] path buffer for user data path
|
|
||||||
\param[in] pathlen size of path buffer (should be at least \c FL_PATH_MAX)
|
|
||||||
\return 0 if path was not created or pathname can't fit into buffer
|
|
||||||
*/
|
|
||||||
char getUserdataPath( char *path, int pathlen );
|
char getUserdataPath( char *path, int pathlen );
|
||||||
|
|
||||||
/**
|
|
||||||
Write all preferences to disk. This function works only with
|
|
||||||
the base preference group. This function is rarely used as
|
|
||||||
deleting the base preferences flushes automatically.
|
|
||||||
*/
|
|
||||||
void flush();
|
void flush();
|
||||||
|
|
||||||
// char export( const char *filename, Type fileFormat );
|
// char export( const char *filename, Type fileFormat );
|
||||||
@ -348,18 +142,11 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
|
||||||
Create a numerical name.
|
|
||||||
*/
|
|
||||||
Name( unsigned int n );
|
Name( unsigned int n );
|
||||||
|
|
||||||
/**
|
|
||||||
Create a name using 'printf' style formatting.
|
|
||||||
*/
|
|
||||||
Name( const char *format, ... );
|
Name( const char *format, ... );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the Name as a c-string.
|
Return the Name as a "C" string.
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
operator const char *() { return data_; }
|
operator const char *() { return data_; }
|
||||||
|
@ -336,7 +336,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
|
|||||||
if (Wp > W) W = Wp;
|
if (Wp > W) W = Wp;
|
||||||
if (Wtitle > W) W = Wtitle;
|
if (Wtitle > W) W = Wtitle;
|
||||||
|
|
||||||
if (X < scr_x) X = scr_x; if (X > scr_x+scr_w-W) X= scr_x+scr_w-W;
|
if (X < scr_x) X = scr_x; if (X > scr_x+scr_w-W) X = right_edge-W; //X= scr_x+scr_w-W;
|
||||||
x(X); w(W);
|
x(X); w(W);
|
||||||
h((numitems ? itemheight*numitems-LEADING : 0)+2*BW+3);
|
h((numitems ? itemheight*numitems-LEADING : 0)+2*BW+3);
|
||||||
if (selected >= 0)
|
if (selected >= 0)
|
||||||
|
@ -259,7 +259,16 @@ char Fl_Preferences::deleteEntry( const char *key )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads an entry from the group. A default value must be
|
||||||
|
supplied. The return value indicates if the value was available
|
||||||
|
(non-zero) or the default was used (0).
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[out] value returned from preferences or default value if none was set
|
||||||
|
\param[in] defaultValue default value to be used if no preference was set
|
||||||
|
\return 0 if the default value was used
|
||||||
|
*/
|
||||||
char Fl_Preferences::get( const char *key, int &value, int defaultValue )
|
char Fl_Preferences::get( const char *key, int &value, int defaultValue )
|
||||||
{
|
{
|
||||||
const char *v = node->get( key );
|
const char *v = node->get( key );
|
||||||
@ -268,7 +277,16 @@ char Fl_Preferences::get( const char *key, int &value, int defaultValue )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets an entry (name/value pair). The return value indicates if there
|
||||||
|
was a problem storing the data in memory. However it does not
|
||||||
|
reflect if the value was actually stored in the preferences
|
||||||
|
file.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[in] value set this entry to \a value
|
||||||
|
\return 0 if setting the value failed
|
||||||
|
*/
|
||||||
char Fl_Preferences::set( const char *key, int value )
|
char Fl_Preferences::set( const char *key, int value )
|
||||||
{
|
{
|
||||||
sprintf( nameBuffer, "%d", value );
|
sprintf( nameBuffer, "%d", value );
|
||||||
@ -277,7 +295,16 @@ char Fl_Preferences::set( const char *key, int value )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads an entry from the group. A default value must be
|
||||||
|
supplied. The return value indicates if the value was available
|
||||||
|
(non-zero) or the default was used (0).
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[out] value returned from preferences or default value if none was set
|
||||||
|
\param[in] defaultValue default value to be used if no preference was set
|
||||||
|
\return 0 if the default value was used
|
||||||
|
*/
|
||||||
char Fl_Preferences::get( const char *key, float &value, float defaultValue )
|
char Fl_Preferences::get( const char *key, float &value, float defaultValue )
|
||||||
{
|
{
|
||||||
const char *v = node->get( key );
|
const char *v = node->get( key );
|
||||||
@ -286,7 +313,16 @@ char Fl_Preferences::get( const char *key, float &value, float defaultValue )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets an entry (name/value pair). The return value indicates if there
|
||||||
|
was a problem storing the data in memory. However it does not
|
||||||
|
reflect if the value was actually stored in the preferences
|
||||||
|
file.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[in] value set this entry to \a value
|
||||||
|
\return 0 if setting the value failed
|
||||||
|
*/
|
||||||
char Fl_Preferences::set( const char *key, float value )
|
char Fl_Preferences::set( const char *key, float value )
|
||||||
{
|
{
|
||||||
sprintf( nameBuffer, "%g", value );
|
sprintf( nameBuffer, "%g", value );
|
||||||
@ -295,7 +331,17 @@ char Fl_Preferences::set( const char *key, float value )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets an entry (name/value pair). The return value indicates if there
|
||||||
|
was a problem storing the data in memory. However it does not
|
||||||
|
reflect if the value was actually stored in the preferences
|
||||||
|
file.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[in] value set this entry to \a value
|
||||||
|
\param[in] precision number of decimal digits to represent value
|
||||||
|
\return 0 if setting the value failed
|
||||||
|
*/
|
||||||
char Fl_Preferences::set( const char *key, float value, int precision )
|
char Fl_Preferences::set( const char *key, float value, int precision )
|
||||||
{
|
{
|
||||||
sprintf( nameBuffer, "%.*g", precision, value );
|
sprintf( nameBuffer, "%.*g", precision, value );
|
||||||
@ -304,7 +350,16 @@ char Fl_Preferences::set( const char *key, float value, int precision )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads an entry from the group. A default value must be
|
||||||
|
supplied. The return value indicates if the value was available
|
||||||
|
(non-zero) or the default was used (0).
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[out] value returned from preferences or default value if none was set
|
||||||
|
\param[in] defaultValue default value to be used if no preference was set
|
||||||
|
\return 0 if the default value was used
|
||||||
|
*/
|
||||||
char Fl_Preferences::get( const char *key, double &value, double defaultValue )
|
char Fl_Preferences::get( const char *key, double &value, double defaultValue )
|
||||||
{
|
{
|
||||||
const char *v = node->get( key );
|
const char *v = node->get( key );
|
||||||
@ -313,7 +368,16 @@ char Fl_Preferences::get( const char *key, double &value, double defaultValue )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets an entry (name/value pair). The return value indicates if there
|
||||||
|
was a problem storing the data in memory. However it does not
|
||||||
|
reflect if the value was actually stored in the preferences
|
||||||
|
file.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[in] value set this entry to \a value
|
||||||
|
\return 0 if setting the value failed
|
||||||
|
*/
|
||||||
char Fl_Preferences::set( const char *key, double value )
|
char Fl_Preferences::set( const char *key, double value )
|
||||||
{
|
{
|
||||||
sprintf( nameBuffer, "%g", value );
|
sprintf( nameBuffer, "%g", value );
|
||||||
@ -322,7 +386,17 @@ char Fl_Preferences::set( const char *key, double value )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets an entry (name/value pair). The return value indicates if there
|
||||||
|
was a problem storing the data in memory. However it does not
|
||||||
|
reflect if the value was actually stored in the preferences
|
||||||
|
file.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[in] value set this entry to \a value
|
||||||
|
\param[in] precision number of decimal digits to represent value
|
||||||
|
\return 0 if setting the value failed
|
||||||
|
*/
|
||||||
char Fl_Preferences::set( const char *key, double value, int precision )
|
char Fl_Preferences::set( const char *key, double value, int precision )
|
||||||
{
|
{
|
||||||
sprintf( nameBuffer, "%.*g", precision, value );
|
sprintf( nameBuffer, "%.*g", precision, value );
|
||||||
@ -362,9 +436,17 @@ static char *decodeText( const char *src )
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read a text entry from the group
|
Reads an entry from the group. A default value must be
|
||||||
* the text will be moved into the given text buffer
|
supplied. The return value indicates if the value was available
|
||||||
* text will be clipped to the buffer size
|
(non-zero) or the default was used (0).
|
||||||
|
'maxSize' is the maximum length of text that will be read.
|
||||||
|
The text buffer must allow for one additional byte for a trailling zero.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[out] text returned from preferences or default value if none was set
|
||||||
|
\param[in] defaultValue default value to be used if no preference was set
|
||||||
|
\param[in] maxSize maximum length of value plus one byte for a trailing zero
|
||||||
|
\return 0 if the default value was used
|
||||||
*/
|
*/
|
||||||
char Fl_Preferences::get( const char *key, char *text, const char *defaultValue, int maxSize )
|
char Fl_Preferences::get( const char *key, char *text, const char *defaultValue, int maxSize )
|
||||||
{
|
{
|
||||||
@ -383,9 +465,16 @@ char Fl_Preferences::get( const char *key, char *text, const char *defaultValue,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read a text entry from the group
|
Reads an entry from the group. A default value must be
|
||||||
* 'text' will be changed to point to a new text buffer
|
supplied. The return value indicates if the value was available
|
||||||
* the text buffer must be deleted with 'free(text)' by the user.
|
(non-zero) or the default was used (0). get() allocates memory of
|
||||||
|
sufficient size to hold the value. The buffer must be free'd by
|
||||||
|
the developer using 'free(value)'.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[out] text returned from preferences or default value if none was set
|
||||||
|
\param[in] defaultValue default value to be used if no preference was set
|
||||||
|
\return 0 if the default value was used
|
||||||
*/
|
*/
|
||||||
char Fl_Preferences::get( const char *key, char *&text, const char *defaultValue )
|
char Fl_Preferences::get( const char *key, char *&text, const char *defaultValue )
|
||||||
{
|
{
|
||||||
@ -405,6 +494,16 @@ char Fl_Preferences::get( const char *key, char *&text, const char *defaultValue
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets an entry (name/value pair). The return value indicates if there
|
||||||
|
was a problem storing the data in memory. However it does not
|
||||||
|
reflect if the value was actually stored in the preferences
|
||||||
|
file.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[in] text set this entry to \a value
|
||||||
|
\return 0 if setting the value failed
|
||||||
|
*/
|
||||||
char Fl_Preferences::set( const char *key, const char *text )
|
char Fl_Preferences::set( const char *key, const char *text )
|
||||||
{
|
{
|
||||||
const char *s = text ? text : "";
|
const char *s = text ? text : "";
|
||||||
@ -457,9 +556,19 @@ static void *decodeHex( const char *src, int &size )
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read a binary entry from the group
|
Reads an entry from the group. A default value must be
|
||||||
* the data will be moved into the given destination buffer
|
supplied. The return value indicates if the value was available
|
||||||
* data will be clipped to the buffer size
|
(non-zero) or the default was used (0).
|
||||||
|
'maxSize' is the maximum length of text that will be read.
|
||||||
|
|
||||||
|
\param[in] entry name of entry
|
||||||
|
\param[out] value returned from preferences or default value if none was set
|
||||||
|
\param[in] defaultValue default value to be used if no preference was set
|
||||||
|
\param[in] defaultSize size of default value array
|
||||||
|
\param[in] maxSize maximum length of value
|
||||||
|
\return 0 if the default value was used
|
||||||
|
|
||||||
|
\todo maxSize should receive the number of bytes that were read.
|
||||||
*/
|
*/
|
||||||
char Fl_Preferences::get( const char *key, void *data, const void *defaultValue, int defaultSize, int maxSize )
|
char Fl_Preferences::get( const char *key, void *data, const void *defaultValue, int defaultSize, int maxSize )
|
||||||
{
|
{
|
||||||
@ -479,9 +588,17 @@ char Fl_Preferences::get( const char *key, void *data, const void *defaultValue,
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read a binary entry from the group
|
Reads an entry from the group. A default value must be
|
||||||
* 'data' will be changed to point to a new data buffer
|
supplied. The return value indicates if the value was available
|
||||||
* the data buffer must be deleted with 'free(data)' by the user.
|
(non-zero) or the default was used (0). get() allocates memory of
|
||||||
|
sufficient size to hold the value. The buffer must be free'd by
|
||||||
|
the developer using 'free(value)'.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[out] data returned from preferences or default value if none was set
|
||||||
|
\param[in] defaultValue default value to be used if no preference was set
|
||||||
|
\param[in] defaultSize size of default value array
|
||||||
|
\return 0 if the default value was used
|
||||||
*/
|
*/
|
||||||
char Fl_Preferences::get( const char *key, void *&data, const void *defaultValue, int defaultSize )
|
char Fl_Preferences::get( const char *key, void *&data, const void *defaultValue, int defaultSize )
|
||||||
{
|
{
|
||||||
@ -503,7 +620,17 @@ char Fl_Preferences::get( const char *key, void *&data, const void *defaultValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sets an entry (name/value pair). The return value indicates if there
|
||||||
|
was a problem storing the data in memory. However it does not
|
||||||
|
reflect if the value was actually stored in the preferences
|
||||||
|
file.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\param[in] data set this entry to \a value
|
||||||
|
\param[in] size of data array
|
||||||
|
\return 0 if setting the value failed
|
||||||
|
*/
|
||||||
char Fl_Preferences::set( const char *key, const void *data, int dsize )
|
char Fl_Preferences::set( const char *key, const void *data, int dsize )
|
||||||
{
|
{
|
||||||
char *buffer = (char*)malloc( dsize*2+1 ), *d = buffer;;
|
char *buffer = (char*)malloc( dsize*2+1 ), *d = buffer;;
|
||||||
@ -523,7 +650,10 @@ char Fl_Preferences::set( const char *key, const void *data, int dsize )
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the size of the value part of an entry
|
Returns the size of the value part of an entry.
|
||||||
|
|
||||||
|
\param[in] key name of entry
|
||||||
|
\return size of value
|
||||||
*/
|
*/
|
||||||
int Fl_Preferences::size( const char *key )
|
int Fl_Preferences::size( const char *key )
|
||||||
{
|
{
|
||||||
@ -531,6 +661,34 @@ int Fl_Preferences::size( const char *key )
|
|||||||
return v ? strlen( v ) : 0 ;
|
return v ? strlen( v ) : 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Creates a path that is related to the preferences file and
|
||||||
|
that is usable for additional application data.
|
||||||
|
|
||||||
|
This function creates a directory that is named after the preferences
|
||||||
|
database without the \c .prefs extension and located in the same directory.
|
||||||
|
It then fills the given buffer with the complete path name.
|
||||||
|
|
||||||
|
Exmaple:
|
||||||
|
\code
|
||||||
|
Fl_Preferences prefs( USER, "matthiasm.com", "test" );
|
||||||
|
char path[FL_PATH_MAX];
|
||||||
|
prefs.getUserdataPath( path );
|
||||||
|
\endcode
|
||||||
|
creates the preferences database in (MS Windows):
|
||||||
|
\code
|
||||||
|
c:/Documents and Settings/matt/Application Data/matthiasm.com/test.prefs
|
||||||
|
\endcode
|
||||||
|
and returns the userdata path:
|
||||||
|
\code
|
||||||
|
c:/Documents and Settings/matt/Application Data/matthiasm.com/test/
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
\param[out] path buffer for user data path
|
||||||
|
\param[in] pathlen size of path buffer (should be at least \c FL_PATH_MAX)
|
||||||
|
\return 0 if path was not created or pathname can't fit into buffer
|
||||||
|
*/
|
||||||
char Fl_Preferences::getUserdataPath( char *path, int pathlen )
|
char Fl_Preferences::getUserdataPath( char *path, int pathlen )
|
||||||
{
|
{
|
||||||
if ( rootNode )
|
if ( rootNode )
|
||||||
@ -539,9 +697,9 @@ char Fl_Preferences::getUserdataPath( char *path, int pathlen )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* write all preferences to disk
|
Write all preferences to disk. This function works only with
|
||||||
* - this function works only with the base preference group
|
the base preference group. This function is rarely used as
|
||||||
* - this function is rarely used as deleting the base preferences flushes automatically
|
deleting the base preferences flushes automatically.
|
||||||
*/
|
*/
|
||||||
void Fl_Preferences::flush()
|
void Fl_Preferences::flush()
|
||||||
{
|
{
|
||||||
@ -554,14 +712,17 @@ void Fl_Preferences::flush()
|
|||||||
//
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a group name or entry name on the fly
|
* Create a group name or entry name on the fly.
|
||||||
* - this version creates a simple unsigned integer as an entry name
|
*
|
||||||
* example:
|
* This version creates a simple unsigned integer as an entry name.
|
||||||
|
*
|
||||||
|
* \code
|
||||||
* int n, i;
|
* int n, i;
|
||||||
* Fl_Preferences prev( appPrefs, "PreviousFiles" );
|
* Fl_Preferences prev( appPrefs, "PreviousFiles" );
|
||||||
* prev.get( "n", 0 );
|
* prev.get( "n", 0 );
|
||||||
* for ( i=0; i<n; i++ )
|
* for ( i=0; i<n; i++ )
|
||||||
* prev.get( Fl_Preferences::Name(i), prevFile[i], "" );
|
* prev.get( Fl_Preferences::Name(i), prevFile[i], "" );
|
||||||
|
* \endcode
|
||||||
*/
|
*/
|
||||||
Fl_Preferences::Name::Name( unsigned int n )
|
Fl_Preferences::Name::Name( unsigned int n )
|
||||||
{
|
{
|
||||||
@ -570,14 +731,17 @@ Fl_Preferences::Name::Name( unsigned int n )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a group name or entry name on the fly
|
* Create a group name or entry name on the fly.
|
||||||
* - this version creates entry names as in 'printf'
|
*
|
||||||
* example:
|
* This version creates entry names as in 'printf'.
|
||||||
|
*
|
||||||
|
* \code
|
||||||
* int n, i;
|
* int n, i;
|
||||||
* Fl_Preferences prefs( USER, "matthiasm.com", "test" );
|
* Fl_Preferences prefs( USER, "matthiasm.com", "test" );
|
||||||
* prev.get( "nFiles", 0 );
|
* prev.get( "nFiles", 0 );
|
||||||
* for ( i=0; i<n; i++ )
|
* for ( i=0; i<n; i++ )
|
||||||
* prev.get( Fl_Preferences::Name( "File%d", i ), prevFile[i], "" );
|
* prev.get( Fl_Preferences::Name( "File%d", i ), prevFile[i], "" );
|
||||||
|
* \endcode
|
||||||
*/
|
*/
|
||||||
Fl_Preferences::Name::Name( const char *format, ... )
|
Fl_Preferences::Name::Name( const char *format, ... )
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
// 'Fl_Progress::draw()' - Draw the check button.
|
// 'Fl_Progress::draw()' - Draw the check button.
|
||||||
//
|
//
|
||||||
|
|
||||||
/** Draws the check button. */
|
/** Draws the progress bar. */
|
||||||
void Fl_Progress::draw()
|
void Fl_Progress::draw()
|
||||||
{
|
{
|
||||||
int progress; // Size of progress bar...
|
int progress; // Size of progress bar...
|
||||||
|
Loading…
Reference in New Issue
Block a user