FLTK 1.3.3

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

Fl_Tree.H
Go to the documentation of this file.
1 //
2 // "$Id: Fl_Tree.H 10275 2014-09-05 12:04:28Z cand $"
3 //
4
5 #ifndef FL_TREE_H
6 #define FL_TREE_H
7
8 #include <FL/Fl.H>
9 #include <FL/Fl_Group.H>
10 #include <FL/Fl_Scrollbar.H>
11 #include <FL/fl_draw.H>
12
13 #include <FL/Fl_Tree_Item.H>
14 #include <FL/Fl_Tree_Prefs.H>
15
17 // FL/Fl_Tree.H
19 //
20 // Fl_Tree -- This file is part of the Fl_Tree widget for FLTK
21 // Copyright (C) 2009-2010 by Greg Ercolano.
22 //
23 // This library is free software. Distribution and use rights are outlined in
24 // the file "COPYING" which should have been included with this file. If this
25 // file is missing or damaged, see the license at:
26 //
27 // http://www.fltk.org/COPYING.php
28 //
29 // Please report all bugs and problems on the following page:
30 //
31 // http://www.fltk.org/str.php
32 //
33
38
308
312 enum Fl_Tree_Reason {
313 FL_TREE_REASON_NONE=0,
314 FL_TREE_REASON_SELECTED,
315 FL_TREE_REASON_DESELECTED,
316 #if FLTK_ABI_VERSION >= 10301
317 FL_TREE_REASON_RESELECTED,
318 #endif /*FLTK_ABI_VERSION*/
319 FL_TREE_REASON_OPENED,
320 FL_TREE_REASON_CLOSED,
321 FL_TREE_REASON_DRAGGED
322 };
323
324 class FL_EXPORT Fl_Tree : public Fl_Group {
325 friend class Fl_Tree_Item;
326 Fl_Tree_Item *_root; // can be null!
327 Fl_Tree_Item *_item_focus; // item that has focus box
328 Fl_Tree_Item *_callback_item; // item invoked during callback (can be NULL)
329 Fl_Tree_Reason _callback_reason; // reason for the callback
330 Fl_Tree_Prefs _prefs; // all the tree's settings
331 int _scrollbar_size; // size of scrollbar trough
332 #if FLTK_ABI_VERSION >= 10301
333 // NEW:
334 Fl_Tree_Item *_lastselect;
335 #else /*FLTK_ABI_VERSION*/
336 // OLD: static data inside handle() method
337 #endif /*FLTK_ABI_VERSION*/
338 void fix_scrollbar_order();
339
340 protected:
341 Fl_Scrollbar *_vscroll;
342 #if FLTK_ABI_VERSION >= 10303
343 Fl_Scrollbar *_hscroll;
344 int _tox,_toy,_tow,_toh;
345 int _tix,_tiy,_tiw,_tih;
346
348 int _tree_w;
350 int _tree_h;
351 #endif
352 void item_clicked(Fl_Tree_Item* val);
353 void do_callback_for_item(Fl_Tree_Item* item, Fl_Tree_Reason reason);
354 #if FLTK_ABI_VERSION >= 10303
355 // next_visible_item() and extend_selection() moved to 'public' in ABI 1.3.3
356 // undocmented draw_tree() dropped -- draw() does all the work now
357 #else
358 Fl_Tree_Item *next_visible_item(Fl_Tree_Item *start, int dir);
359 void extend_selection(Fl_Tree_Item *from, Fl_Tree_Item *to);
360 int draw_tree();
361 #endif
362
363 public:
364 Fl_Tree(int X, int Y, int W, int H, const char *L=0);
365 ~Fl_Tree();
366 int handle(int e);
367 void draw();
368 void show_self();
369 void resize(int,int,int,int);
370
372 // root methods
374 void root_label(const char *new_label);
375 Fl_Tree_Item* root();
376 void root(Fl_Tree_Item *newitem);
377 const Fl_Tree_Prefs& prefs() const { return _prefs; }
378
380 // Item creation/removal methods
382 #if FLTK_ABI_VERSION >= 10303
383 Fl_Tree_Item *add(const char *path, Fl_Tree_Item *newitem=0);
384 #else
385 Fl_Tree_Item *add(const char *path);
386 Fl_Tree_Item *add(const char *path, Fl_Tree_Item *newitem);
387 #endif
388 Fl_Tree_Item* add(Fl_Tree_Item *parent_item, const char *name);
389 Fl_Tree_Item *insert_above(Fl_Tree_Item *above, const char *name);
390 Fl_Tree_Item* insert(Fl_Tree_Item *item, const char *name, int pos);
391 int remove(Fl_Tree_Item *item);
392 void clear();
393 void clear_children(Fl_Tree_Item *item);
394
396 // Item lookup methods
398 Fl_Tree_Item *find_item(const char *path);
399 const Fl_Tree_Item *find_item(const char *path) const;
400 int item_pathname(char *pathname, int pathnamelen, const Fl_Tree_Item *item) const;
401 #if FLTK_ABI_VERSION >= 10303
402 const Fl_Tree_Item* find_clicked(int yonly=0) const;
403 Fl_Tree_Item* find_clicked(int yonly=0);
404 #else
405 const Fl_Tree_Item *find_clicked() const;
406 Fl_Tree_Item *find_clicked();
407 #endif
408 Fl_Tree_Item *item_clicked();
409 Fl_Tree_Item *first();
410 Fl_Tree_Item *first_visible(); // deprecated in ABI 10303
411 Fl_Tree_Item *first_visible_item();
412 Fl_Tree_Item *next(Fl_Tree_Item *item=0);
413 Fl_Tree_Item *prev(Fl_Tree_Item *item=0);
414 Fl_Tree_Item *last();
415 Fl_Tree_Item *last_visible(); // deprecated in ABI 10303
416 Fl_Tree_Item *last_visible_item();
417 #if FLTK_ABI_VERSION >= 10303
418 Fl_Tree_Item *next_visible_item(Fl_Tree_Item *start, int dir); // made public in 1.3.3 ABI
419 #endif
420 Fl_Tree_Item *first_selected_item();
421 Fl_Tree_Item *last_selected_item();
422 Fl_Tree_Item *next_item(Fl_Tree_Item *item, int dir=FL_Down, bool visible=false);
423 #if FLTK_ABI_VERSION >= 10303
424 Fl_Tree_Item *next_selected_item(Fl_Tree_Item *item=0, int dir=FL_Down);
425 int get_selected_items(Fl_Tree_Item_Array &items);
426 #else
427 Fl_Tree_Item *next_selected_item(Fl_Tree_Item *item=0);
428 Fl_Tree_Item *next_selected_item(Fl_Tree_Item *item, int dir);
429 #endif
430
432 // Item open/close methods
434 int open(Fl_Tree_Item *item, int docallback=1);
435 int open(const char *path, int docallback=1);
436 void open_toggle(Fl_Tree_Item *item, int docallback=1);
437 int close(Fl_Tree_Item *item, int docallback=1);
438 int close(const char *path, int docallback=1);
439 int is_open(Fl_Tree_Item *item) const;
440 int is_open(const char *path) const;
441 int is_close(Fl_Tree_Item *item) const;
442 int is_close(const char *path) const;
443
445 // Item selection methods
447 int select(Fl_Tree_Item *item, int docallback=1);
448 int select(const char *path, int docallback=1);
449 void select_toggle(Fl_Tree_Item *item, int docallback=1);
450 int deselect(Fl_Tree_Item *item, int docallback=1);
451 int deselect(const char *path, int docallback=1);
452 int deselect_all(Fl_Tree_Item *item=0, int docallback=1);
453 int select_only(Fl_Tree_Item *selitem, int docallback=1);
454 int select_all(Fl_Tree_Item *item=0, int docallback=1);
455 int extend_selection_dir(Fl_Tree_Item *from,
456 Fl_Tree_Item *to,
457 int dir,
458 int val,
459 bool visible);
460 #if FLTK_ABI_VERSION >= 10303
461 int extend_selection(Fl_Tree_Item *from,
462 Fl_Tree_Item *to,
463 int val=1,
464 bool visible=false);
465 #else
466 private:
467 // Adding overload if not at least one overload breaks ABI, so avoid
468 // by keeping private until we can break ABI. ref: http://www.ros.org/reps/rep-0009.html
469 int extend_selection__(Fl_Tree_Item *from,
470 Fl_Tree_Item *to,
471 int val,
472 bool visible);
473 public:
474 #endif
475 void set_item_focus(Fl_Tree_Item *item);
476 Fl_Tree_Item *get_item_focus() const;
477 int is_selected(Fl_Tree_Item *item) const;
478 int is_selected(const char *path);
479
481 // Item attribute related methods
483 Fl_Font item_labelfont() const;
484 void item_labelfont(Fl_Font val);
485 Fl_Fontsize item_labelsize() const;
486 void item_labelsize(Fl_Fontsize val);
487 Fl_Color item_labelfgcolor(void) const;
488 void item_labelfgcolor(Fl_Color val);
489 Fl_Color item_labelbgcolor(void) const;
490 void item_labelbgcolor(Fl_Color val);
491 Fl_Color connectorcolor() const;
492 void connectorcolor(Fl_Color val);
493 int marginleft() const;
494 void marginleft(int val);
495 int margintop() const;
496 void margintop(int val);
497 #if FLTK_ABI_VERSION >= 10301
498 int marginbottom() const;
499 void marginbottom(int val);
500 #endif /*FLTK_ABI_VERSION*/
501 int linespacing() const;
502 void linespacing(int val);
503 int openchild_marginbottom() const;
504 void openchild_marginbottom(int val);
505 int usericonmarginleft() const;
506 void usericonmarginleft(int val);
507 int labelmarginleft() const;
508 void labelmarginleft(int val);
509 #if FLTK_ABI_VERSION >= 10301
510 int widgetmarginleft() const;
511 void widgetmarginleft(int val);
512 #endif /*FLTK_ABI_VERSION*/
513 int connectorwidth() const;
514 void connectorwidth(int val);
515 Fl_Image* usericon() const;
516 void usericon(Fl_Image *val);
517 Fl_Image* openicon() const;
518 void openicon(Fl_Image *val);
519 Fl_Image* closeicon() const;
520 void closeicon(Fl_Image *val);
521 int showcollapse() const;
522 void showcollapse(int val);
523 int showroot() const;
524 void showroot(int val);
525 Fl_Tree_Connector connectorstyle() const;
526 void connectorstyle(Fl_Tree_Connector val);
527 Fl_Tree_Sort sortorder() const;
528 void sortorder(Fl_Tree_Sort val);
529 Fl_Boxtype selectbox() const;
530 void selectbox(Fl_Boxtype val);
531 Fl_Tree_Select selectmode() const;
532 void selectmode(Fl_Tree_Select val);
533 #if FLTK_ABI_VERSION >= 10301
534 Fl_Tree_Item_Reselect_Mode item_reselect_mode() const;
535 void item_reselect_mode(Fl_Tree_Item_Reselect_Mode mode);
536 Fl_Tree_Item_Draw_Mode item_draw_mode() const;
537 void item_draw_mode(Fl_Tree_Item_Draw_Mode mode);
538 void item_draw_mode(int mode);
539 #endif
540 #if FLTK_ABI_VERSION >= 10303
541 void calc_dimensions();
542 void calc_tree();
543 #endif
544 void recalc_tree();
545 int displayed(Fl_Tree_Item *item);
546 void show_item(Fl_Tree_Item *item, int yoff);
547 void show_item(Fl_Tree_Item *item);
548 void show_item_top(Fl_Tree_Item *item);
549 void show_item_middle(Fl_Tree_Item *item);
550 void show_item_bottom(Fl_Tree_Item *item);
551 void display(Fl_Tree_Item *item);
552 int vposition() const;
553 void vposition(int pos);
554 int hposition() const;
555 void hposition(int pos);
556
557 int is_scrollbar(Fl_Widget *w);
558 int scrollbar_size() const;
559 void scrollbar_size(int size);
560 int is_vscroll_visible() const;
561 int is_hscroll_visible() const;
562
564 // callback related
566 void callback_item(Fl_Tree_Item* item);
567 Fl_Tree_Item* callback_item();
568 void callback_reason(Fl_Tree_Reason reason);
569 Fl_Tree_Reason callback_reason() const;
570
572 void load(class Fl_Preferences&);
573 };
574
575 #endif /*FL_TREE_H*/
576
577 //
578 // End of "$Id: Fl_Tree.H 10275 2014-09-05 12:04:28Z cand $".
579 //
Fl_Widget
Fl_Widget is the base class for all widgets in FLTK.
Definition: Fl_Widget.H:100
Fl_Tree_Item::next
Fl_Tree_Item * next()
Return the next item in the tree.
Definition: Fl_Tree_Item.cxx:1536
FL_TREE_REASON_OPENED
an item was opened
Definition: Fl_Tree.H:319
Fl_Tree_Item::select
void select(int val=1)
Change the item's selection state to the optionally specified 'val'.
Definition: Fl_Tree_Item.H:333
Fl_Tree_Sort
Fl_Tree_Sort
Sort order options for items added to the tree.
Definition: Fl_Tree_Prefs.H:49
Fl_Tree_Select
Fl_Tree_Select
Tree selection style.
Definition: Fl_Tree_Prefs.H:67
Fl_Tree_Item::visible
int visible() const
See if the item is visible. Alias for is_visible().
Definition: Fl_Tree_Item.H:416
Fl_Tree
Tree widget.
Definition: Fl_Tree.H:324
Fl_Tree_Item::deselect_all
int deselect_all()
Deselect item and all its children.
Definition: Fl_Tree_Item.H:367
Fl.H
Fl static class.
FL_TREE_REASON_SELECTED
an item was selected
Definition: Fl_Tree.H:314
Fl_Tree_Item::open
void open()
Open this item and all its children.
Definition: Fl_Tree_Item.cxx:1494
Fl_Tree_Item::deselect
void deselect()
Disable the item's selection state.
Definition: Fl_Tree_Item.H:360
Fl_Image
Fl_Image is the base class used for caching and drawing all kinds of images in FLTK.
Definition: Fl_Image.H:52
Fl_Tree_Item::select_all
int select_all()
Select item and all its children.
Definition: Fl_Tree_Item.H:348
Fl_Tree_Item::close
void close()
Close this item and all its children.
Definition: Fl_Tree_Item.cxx:1504
Fl_Group::draw
void draw()
Draws the widget.
Definition: Fl_Group.cxx:738
Fl_Boxtype
Fl_Boxtype
Definition: Enumerations.H:473
Fl_Group::clear
void clear()
Deletes all child widgets from memory recursively.
Definition: Fl_Group.cxx:383
Fl_Tree_Reason
Fl_Tree_Reason
The reason the callback was invoked.
Definition: Fl_Tree.H:312
Fl_Tree::_vscroll
Fl_Scrollbar * _vscroll
Vertical scrollbar.
Definition: Fl_Tree.H:341
Fl_Group::insert
void insert(Fl_Widget &, int i)
The widget is removed from its current group (if any) and then inserted into this group...
Definition: Fl_Group.cxx:458
Fl_Group
The Fl_Group class is the FLTK container widget.
Definition: Fl_Group.H:41
FL_TREE_REASON_CLOSED
an item was closed
Definition: Fl_Tree.H:320
Fl_Tree_Item::select_toggle
void select_toggle()
Toggle the item's selection state.
Definition: Fl_Tree_Item.H:337
Fl_Group::add
void add(Fl_Widget &)
The widget is removed from its current group (if any) and then added to the end of this group...
Definition: Fl_Group.cxx:491
Fl_Group::handle
int handle(int)
Handles the specified event.
Definition: Fl_Group.cxx:147
Fl_Tree_Item::insert_above
Fl_Tree_Item * insert_above(const Fl_Tree_Prefs &prefs, const char *new_label)
Insert a new item named 'new_label' above this item.
Definition: Fl_Tree_Item.cxx:443
Fl_Tree_Item::clear_children
void clear_children()
Clear all the children for this item.
Definition: Fl_Tree_Item.cxx:202
Fl_Tree_Item::w
int w() const
The entire item's width to right edge of Fl_Tree's inner width within scrollbars. ...
Definition: Fl_Tree_Item.H:139
Fl_Tree_Item::prev
Fl_Tree_Item * prev()
Return the previous item in the tree.
Definition: Fl_Tree_Item.cxx:1568
Fl_Preferences
Fl_Preferences provides methods to store user settings between application starts.
Definition: Fl_Preferences.H:60
FL_Down
#define FL_Down
The down arrow key.
Definition: Enumerations.H:353
Fl_Tree_Connector
Fl_Tree_Connector
Defines the style of connection lines between items.
Definition: Fl_Tree_Prefs.H:58
Fl_Tree_Item::is_close
int is_close() const
See if the item is 'closed'.
Definition: Fl_Tree_Item.H:323
Fl_Tree_Item::usericon
Fl_Image * usericon() const
Get the item's user icon as an Fl_Image. Returns '0' if disabled.
Definition: Fl_Tree_Item.H:431
Fl_Tree_Item::open_toggle
void open_toggle()
Toggle the item's open/closed state.
Definition: Fl_Tree_Item.H:327
Fl_Tree_Item::find_item
const Fl_Tree_Item * find_item(char **arr) const
Find item by descending array of 'names'.
Definition: Fl_Tree_Item.cxx:280
Fl_Fontsize
int Fl_Fontsize
Size of a font in pixels.
Definition: Enumerations.H:768
Fl_Group::resize
void resize(int, int, int, int)
Resizes the Fl_Group widget and all of its children.
Definition: Fl_Group.cxx:634
FL_TREE_REASON_DESELECTED
an item was de-selected
Definition: Fl_Tree.H:315
Fl_Tree_Item::recalc_tree
void recalc_tree()
Call this when our geometry is changed.
Definition: Fl_Tree_Item.cxx:1770
fl_draw.H
utility header to pull drawing functions together
Fl_Color
unsigned int Fl_Color
An FLTK color value; see also Colors.
Definition: Enumerations.H:796
Fl_Tree_Item
Tree widget item.
Definition: Fl_Tree_Item.H:67
Fl_Font
int Fl_Font
A font number is an index into the internal font table.
Definition: Enumerations.H:739
Fl_Tree_Prefs.H
This file contains the definitions for Fl_Tree's preferences.
Fl_Tree_Item_Array
Manages an array of Fl_Tree_Item pointers.
Definition: Fl_Tree_Item_Array.H:47
FL_TREE_REASON_DRAGGED
an item was dragged into a new place
Definition: Fl_Tree.H:321
Fl_Tree_Prefs
Tree widget's preferences.
Definition: Fl_Tree_Prefs.H:111
Fl_Tree_Item::find_clicked
const Fl_Tree_Item * find_clicked(const Fl_Tree_Prefs &prefs) const
Find the item that the last event was over.
Definition: Fl_Tree_Item.cxx:823
Fl_Tree_Item.H
This file contains the definitions for Fl_Tree_Item.
Fl_Tree_Item::is_selected
char is_selected() const
See if the item is selected.
Definition: Fl_Tree_Item.H:379
Fl_Tree_Item::show_self
void show_self(const char *indent="") const
Print the tree as 'ascii art' to stdout.
Definition: Fl_Tree_Item.cxx:160
Fl_Scrollbar
The Fl_Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
Definition: Fl_Scrollbar.H:43
FL_TREE_REASON_NONE
unknown reason
Definition: Fl_Tree.H:313
Fl_Tree_Item::is_open
int is_open() const
See if the item is 'open'.
Definition: Fl_Tree_Item.H:319
- © 1998-2014 by Bill Spitzak and others.