mirror of
https://github.com/fltk/fltk.git
synced 2026-05-25 17:42:14 +08:00
Added a function to copy an entire Fl_Preferences database into an Fl_Tree view. This will break IDEs that do not have Fl_Tree and Fl_Table added yet!
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6992 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+4
-1
@@ -146,6 +146,8 @@ public:
|
||||
|
||||
// char export( const char *filename, Type fileFormat );
|
||||
// char import( const char *filename );
|
||||
|
||||
char copyTo(class Fl_Tree*);
|
||||
|
||||
/**
|
||||
'Name' provides a simple method to create numerical or more complex
|
||||
@@ -206,12 +208,14 @@ private:
|
||||
public:
|
||||
Node( const char *path );
|
||||
~Node();
|
||||
char copyTo(class Fl_Tree*, class Fl_Tree_Item*);
|
||||
// node methods
|
||||
int write( FILE *f );
|
||||
const char *name();
|
||||
const char *path() { return path_; }
|
||||
Node *find( const char *path );
|
||||
Node *search( const char *path, int offset=0 );
|
||||
Node *childNode( int ix );
|
||||
Node *addChild( const char *path );
|
||||
void setParent( Node *parent );
|
||||
Node *parent() { return top_?0L:parent_; }
|
||||
@@ -222,7 +226,6 @@ private:
|
||||
// entry methods
|
||||
int nChildren();
|
||||
const char *child( int ix );
|
||||
Node *childNode( int ix );
|
||||
void set( const char *name, const char *value );
|
||||
void set( const char *line );
|
||||
void add( const char *line );
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@
|
||||
/// Fl_Tree_Item::closeicon(),
|
||||
/// Fl_Tree_Item::usericon().
|
||||
///
|
||||
/// Various default preferences can be manipulated vi Fl_Tree_Prefs, including
|
||||
/// Various default preferences can be manipulated via Fl_Tree_Prefs, including
|
||||
/// colors, margins, connection lines.
|
||||
///
|
||||
/// \image html tree-elements.png
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Preferences.H>
|
||||
#include <FL/Fl_Tree.H>
|
||||
#include <FL/filename.H>
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -333,6 +334,15 @@ Fl_Preferences::~Fl_Preferences()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Copy the databse hierarchy to an Fl_Tree browser from this node down.
|
||||
*/
|
||||
char Fl_Preferences::copyTo(Fl_Tree *tree)
|
||||
{
|
||||
return node->copyTo(tree, tree->root());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the number of groups that are contained within a group.
|
||||
|
||||
@@ -1601,6 +1611,25 @@ char Fl_Preferences::Node::remove()
|
||||
return ( nd != 0 );
|
||||
}
|
||||
|
||||
char Fl_Preferences::Node::copyTo(Fl_Tree *tree, Fl_Tree_Item *ti)
|
||||
{
|
||||
ti->label(name());
|
||||
ti->user_data(this);
|
||||
Node *nd = child_;
|
||||
for ( ; nd; nd = nd->next_) {
|
||||
Fl_Tree_Item *tic = tree->insert(ti, 0, 0);
|
||||
nd->copyTo(tree, tic);
|
||||
tic->close();
|
||||
}
|
||||
int i, n = nEntry;
|
||||
for (i=0; i<n; i++) {
|
||||
char buf[80];
|
||||
const char *name = entry[i].name;
|
||||
const char *value = entry[i].value;
|
||||
fl_snprintf(buf, 80, "%s: %s", name, value);
|
||||
Fl_Tree_Item *tic = tree->add(ti, buf);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
|
||||
Reference in New Issue
Block a user