dslinux/user/pixil/include/FL FBase.H Fl_Editor.H Fl_Node.H Fl_Tree.H Flv_Table_Child.H

amadeus dslinux_amadeus at user.in-berlin.de
Tue Oct 3 13:24:48 CEST 2006

Update of /cvsroot/dslinux/dslinux/user/pixil/include/FL
In directory antilope:/tmp/cvs-serv11916/include/FL

Added Files:
	FBase.H Fl_Editor.H Fl_Node.H Fl_Tree.H Flv_Table_Child.H 
Log Message:
adding pristine copy of pixil to HEAD so I can branch from it

--- NEW FILE: Fl_Node.H ---
#ifndef Fl_Node_H
#define Fl_Node_H

class Fl_Node {

  friend class Fl_Tree;


  Fl_Node() {
    prev_ = 0;
    next_ = 0;
    sub_ = 0;
    vsub_ = 0;
    up_ = 0;
    opened_ = 0;


  Fl_Node* prev_;
  Fl_Node* next_;
  Fl_Node* sub_;
  Fl_Node* vsub_;
  Fl_Node* up_;

  int opened_;



--- NEW FILE: FBase.H ---
/* -*-C++-*- 

   "$Id: FBase.H,v 1.1 2006-10-03 11:24:46 dslinux_amadeus Exp $"
   Copyright 1999-2000 by the Flek development team.
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   Library General Public License for more details.
   You should have received a copy of the GNU Library General Public
   License along with this library; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   Please report all bugs and problems to "flek-devel at sourceforge.net".

#ifndef _FBASE_H_
#define _FBASE_H_

/** @package libflek_core
 * FBase is the Abstract base class for all f classes.  The FBase
 * class can be used to build container classes which use object 
 * pointers.  The same container class can then be used with any
 * derived classes without the need of any additional code or templates.
 * FBase has no member data.  It only has protected constructors (to 
 * prevent instantiation), virtual destructors and an assignment operator.
class FBase

  typedef FBase* Ptr;

   * Assignment operator.  This operator must be overriden to be useful,
   * it's default behavior is to do nothing.
   * @param src
  FBase& operator = (const FBase& src) {
    return *this;

   * Destructor.
  virtual ~FBase () {}

   * Derived class should give a meaningful implementation
   * for the following functions.
   * Classes such as List which use FBase pointers
   * will use these functions, for memory management
   * Make a copy of the FBase and return a pointer to the new one.
  virtual Ptr copy () const = 0;

   * The default constructor is protected to prevent instantiation,
  FBase () {}

   * The copy constructor is protected to prevent instantiation.
   * @param src The class to take initial data from.
  FBase (const FBase& src) {}

#endif // #ifndef FBASE_H_

--- NEW FILE: Flv_Table_Child.H ---

#include <Flek/Flv_Table.H>

#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Pixmap.H>

#include <stdio.h>
#include <string.h>

struct node_data {
  int row;
  void * data;

struct node_image {
  int id;
  int R;
  int C;
  Fl_Pixmap * image_data;
  node_image * next;

struct col_data {

  char * _data;


struct table_row {
  col_data * col;

//	Demonstrate Simplest Fl_List_Child
class Flv_Table_Child : public Flv_Table

  int numRows;
  int numCols;
  int lastNumRecs;
  node_data * node;
  node_image * images;
  table_row * val;
  int col0, col1, col2, col3;
  Fl_Color hilight_dark;
  int save_h;
  bool move;

  Flv_Table_Child( int X, int Y, int W, int H, const char *l=0, int _col0=25, 
		   int _col1=75, int _col2=0, int _col3=0 );
  virtual ~Flv_Table_Child();
  void movable(bool flag) { move = flag; }

  virtual void resize(int x, int y, int w, int h) { 
    int new_h;
    if ( h == save_h )
      new_h = save_h;
    else {
      new_h = h - (this->y() - y) - 5;

    //printf("*********** h(%d),save_h(%d),new_h(%d)\n", h, save_h,new_h);

    if ( move ) 
      Fl_Widget::resize(x, y, w, new_h); 
      Fl_Widget::resize(this->x(), this->y(), w, new_h); 

  // Image Managegment

  // Methods
  void _set_image(Fl_Pixmap * image, int R, int C, int id);
  void set_image(Fl_Pixmap * image, int R, int C, int id);
  Fl_Pixmap * get_image(int id);
  int find_image(int R, int C);
  char * get_value(int R, int C, int &image);
  void set_value(int R, int C, char * data);
  void Init(int _rows);
  void Add(int row, void * data);
	void *data(int row);
  void * selected();

  virtual void draw_cell( int Offset, int &X, int &Y, int &W, int &H, int R, int C );
  void get_style( Flv_Style &s, int R, int C );
  int text_width();
	virtual int col_width( int C );
	virtual int col_width( int w, int C ){return Flv_Table::col_width(w,C);}
  void SetCols(int _cols) { numCols = _cols; cols(numCols); }



--- NEW FILE: Fl_Tree.H ---
#ifndef Fl_Tree_H
#define Fl_Tree_H

#include "Fl_Node.H"
#include <FL/fl_draw.H>
#include "nxscroll.h"

#define FL_DAMAGE_TREE 0x40

enum tree_sort_order {

class Fl_Tree : public Fl_Widget {


  Fl_Tree(int x, int y, int w, int h);

  Fl_Node* first(void) {
    return first_;

  int height_(Fl_Node* node) {
    return height(node) | 1;
    // height must be |1 , so Fl_ToggleTree can do color-swapping
    // with &1 on y coordinate

  Fl_Node* find(int fy, int& depth, int& ry);

  void traverse_start(Fl_Node * a);
  Fl_Node * traverse_start();
  void traverse_up (void);
  Fl_Node * traverse_forward(int visible, int &depth);
  Fl_Node * traverse_forward();
  Fl_Node * traverse_backward();

  void add_next (Fl_Node* node);
  void add_last (Fl_Node *node);
  void add_sub (Fl_Node* node);
  int remove (Fl_Node * a);
  int clear();

  virtual void draw(void);
  void update_height(void);

  int open(Fl_Node* node);
  int close(Fl_Node* node);

  Fl_Node* top() {
    return top_;

  Fl_Node* first_;
  Fl_Node* top_;
  Fl_Node* t_current_;
  Fl_Node* current_;

  int top_depth_;
  int top_yoffset_;

  Fl_Node* damaged_;

  virtual int height(Fl_Node* node);
  int total_height(Fl_Node* node);
  void update_top(void);
  virtual void draw_node(int depth, int cy, Fl_Node* node);
  virtual int handle(int) { return 1; }

  Fl_Node* sort_( Fl_Node* start,
                  int (*compar)(Fl_Node *, Fl_Node *),
                  int down, tree_sort_order order = TREE_NORMAL_SORT);

  static int s_compare_(void* a, void *b);
  static int s_compare_reverse_(void* a, void *b);

  Fl_Node* sort(Fl_Node* start, int (*compar)(Fl_Node *, Fl_Node *),
                tree_sort_order order = TREE_NORMAL_SORT);
  Fl_Node* sort_tree(Fl_Node* start, int (*compar)(Fl_Node *, Fl_Node *),
                     tree_sort_order order = TREE_NORMAL_SORT);

  void sort(int (*compar)(Fl_Node *, Fl_Node *),
            tree_sort_order order = TREE_NORMAL_SORT);
  void sort_tree(int (*compar)(Fl_Node *, Fl_Node *),
                 tree_sort_order order = TREE_NORMAL_SORT);


--- NEW FILE: Fl_Editor.H ---
#ifndef FL_EDITOR_H
#define FL_EDITOR_H 1

#include "nxscrollbar.h"
#include <FL/Fl.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Tile.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Font.H>

#include "editengine.h"

#ifdef NANOX
#include <FL/n_x.h>
#include <FL/x.H>

class Fl_CursorBox : public Fl_Box
  bool AllowResize;
  bool AlwaysHide;
  Fl_CursorBox(int nx, int ny, int nw, int nh, const char *nc=""): Fl_Box(nx, ny, nw, nh, nc) {  AllowResize = AlwaysHide = false; };
  void hide()		{ set_flag(FL_INVISIBLE); };	// DON'T redraw the parent!
  void show()	   { if(!AlwaysHide) {clear_flag(FL_INVISIBLE); redraw(); } };	// DON'T redraw the parent!
  void hide()		{ set_flag(INVISIBLE); };	// DON'T redraw the parent!
  void show()	   { if(!AlwaysHide) { clear_flag(INVISIBLE); redraw(); } };	// DON'T redraw the parent!
  void resize(int newx, int newy, int neww, int newh)	{ 
      Fl_Box::resize(newx, newy, neww, newh);
  void setsize(int nx, int ny, int nw, int nh)	{ AllowResize = true; resize(nx, ny, nw, nh); AllowResize = false;  redraw(); };
  void hideall(bool hideit)	{ AlwaysHide = hideit; if(hideit && visible()) hide(); else if(!hideit && !visible()) show(); };
  bool hideall()	{ return AlwaysHide; };

class Fl_EditorEngine : public EditorEngine
	friend class Fl_Editor;
	Fl_Font textfont_;
	int textsize_;
	uchar textfont_;
	uchar textsize_;
	FL_API short MeasureTextWidth(const char *t);
	FL_API short MeasureTextHeight(const char *t);
	Fl_EditorEngine(short p, Fl_Font tf=0, int ts=12) : EditorEngine(p) { textfont(tf); textsize(ts); };
        void textfont(Fl_Font s) { textfont_ = s; }
	Fl_EditorEngine(short p, uchar tf=8, uchar ts=12) : EditorEngine(p) { textfont(tf); textsize(ts); };
        void textfont(uchar s) { textfont_ = s; }
	Fl_Font textfont() const { return(Fl_Font)textfont_; }
	uchar textsize() const { return textsize_; }
	void textsize(uchar s) { textsize_ = s; }

enum CursorStyles

struct fleditor_DrawState
	struct fleditor_DrawState *next;	// to implement a simple stack
	EditPosition EffectivePos;				// where to begin this drawing state
	EditPosition EffectiveUntil;	         // where to end this drawing state
	Fl_Color fg;
	Fl_Color bg;
	Fl_Color sel;
	long attrib;		// for things like bold, italic, underline, etc.  Not used yet
	Fl_Font font;
	int size;
	fleditor_DrawState(Fl_Color nfg = (Fl_Color)-1, Fl_Color nbg = (Fl_Color)-1, Fl_Color nsel = (Fl_Color)-1, Fl_Font nf = 0, int ns = 0, long atr = 0):
			fg(nfg), bg(nbg), sel(nsel), attrib(atr), font(nf), size(ns) { next = NULL; };
	uchar font;
	uchar size;
	fleditor_DrawState(Fl_Color nfg = (Fl_Color)-1, Fl_Color nbg = (Fl_Color)-1, Fl_Color nsel = (Fl_Color)-1, uchar nf = 0, uchar ns = 0, long atr = 0):
			fg(nfg), bg(nbg), sel(nsel), attrib(atr), font(nf), size(ns) { next = NULL; };
	fleditor_DrawState& operator=(const fleditor_DrawState& ds)  
		{	fg = ds.fg;  bg = ds.bg; sel = ds.sel; font = ds.font; size = ds.size; attrib = ds.attrib; EffectivePos = ds.EffectivePos;  return *this; };

// LEFTMARGIN = pixels between outer edge of widget and text on either side
// TOPMARGIN = pixels between outer edge of widget and text on top and bottom.
// SCROLLERWIDTH is the width of the scroll bar.
// PANELHEIGHT is the height of the indicator panel beneath the editor.

#define LEFTMARGIN 10 
#define TOPMARGIN 2
#define PANELHEIGHT 21

#define DAMAGE_EDITOR	0x10
#define DAMAGE_LINE	0x20
#define DAMAGE_CHAR	0x40
#define DAMAGE_PARTIAL 0x60
#define DAMAGE_CURSOR	0x70

class Fl_Editor : public Fl_Group
	FL_API void setfont() const;
	Fl_EditorEngine *engine;
	Fl_Box *editbox;
	NxScrollbar *scroller;
	int _scrollspeed;
	int EditWidth;
	Fl_Font textfont_;
	unsigned textsize_;
	uchar textcolor_;
	uchar textfont_;
	uchar textsize_;
	uchar textcolor_;
	short VisibleLines;	// how many lines presently visible in the widget?
	long StartLine;		// first line that is visible in widget
	int overstrike;		// boolean flag for overstrike (else insert) mode
	int marking;		// boolean flag for marking text
	EditPosition Mark;	// start of marked block (marks from there to present cursor position)
	EditPosition DrawFrom;	
	bool selectlines;	// flag for selecting line-at-a-time after triple-click
	bool Readonly;
	bool Browsemode;	// Modifies cursor arrow behaviour. Up/down scroll up/down, left/right are ignored
	bool TimerEnable;	// scroll timer
	bool myHideCursor;	// for hiding in focus/unfocus, prevents overriding user HideCursor() calls.
        bool keeptabs;        // whether editor uses tabs, or leaves them to FLTK.
	fleditor_DrawState *DrawState;
  	Fl_CursorBox * __Cursor;
	virtual FL_API int HandleKey(int keyevent, const char *keytext, int textlen, int state);
	virtual FL_API int HandleCursorKey(int key, const char *text, int len, int state);
	FL_API void ShowCursor(CursorStyles show);
	FL_API void CopySelection(bool clearmarks);
	FL_API void draw();
	virtual FL_API void DrawLine(long editorlineno, int left, int top, wString& line, fleditor_DrawState& state);
	FL_API void PushState(const fleditor_DrawState& state);
	FL_API void PopState();
  bool move;
  int save_h;
	FL_API Fl_Editor(int x, int y, int w, int h, const char *cap="") ;
	virtual FL_API ~Fl_Editor();
	FL_API int handle(int event);
	FL_API short CursorX();
	FL_API short CursorY();
	FL_API long FindColumn(short screenX);	
	FL_API long FindRow(short screenY);
	FL_API void HandleScroll();
	FL_API void Cut();
  FL_API void movable(bool flag) { move = flag; }        
	FL_API void resize(int x, int y, int w, int h);
	static FL_API void Fl_Editor::draw_clip(void *v, int X, int Y, int W, int H);
	FL_API Fl_Font textfont() const { return  (Fl_Font) textfont_; };
	virtual FL_API void textfont(Fl_Font s);
	FL_API unsigned textsize() const { return textsize_; };
	FL_API Fl_Font textfont() const { return (Fl_Font) textfont_; };
	virtual FL_API void textfont(uchar s);
	FL_API uchar textsize() const { return textsize_; };
	virtual FL_API void textsize(uchar s);
	virtual FL_API void SyncDisplay();	
	FL_API void browse(bool setit);
	// everything below this is inline.
	void FindCursor(short screenX, short screenY)	{ if(FindRow(screenY) < 0) engine->Command(MOVE_BOF); else FindColumn(screenX); }
	void Copy() { CopySelection(true);  damage(FL_DAMAGE_ALL); };
	void Paste() { Fl::paste(*this);     damage(FL_DAMAGE_ALL); };
	Fl_Color textcolor() const { return(Fl_Color)textcolor_; }
	void textcolor(uchar n) { textcolor_ = n; }
  void MoveTo(long row, long col) {engine->MoveTo(row, col);}
	void LoadFrom(FILE *file) { engine->LoadFrom(file); ShowCursor(CURSOR_UNHIDE); SyncDisplay(); }
	void SaveTo(FILE *file) { engine->SaveTo(file); }
	void LoadFrom(const char *buffer) { engine->LoadFrom(buffer); ShowCursor(CURSOR_UNHIDE); SyncDisplay(); }
	void SaveTo(char *buffer) { engine->SaveTo(buffer); }
	long CharacterCount() { return engine->GetCharacterCount(); }
	void Clear() { engine->Clear(); redraw(); }
	bool changed() const { return engine->Changed(); }
	bool readonly() const { return Readonly; }
	void readonly(bool state) { Readonly = state; }
	// WARNING: Turning wrap off doesn't presently work!  
	// The draw routines for it are not in place yet!  Read the docs!
	bool Wrap() { return !(engine->GetFlags() & EF_NOWRAP); }
	void Wrap(bool wrapit) { engine->SetFlags(wrapit ? engine->GetFlags() & ~EF_NOWRAP : engine->GetFlags() | EF_NOWRAP); }
	void scrollspeed(int linespersec)	{ _scrollspeed = linespersec; };
	int scrollspeed() const	{ return _scrollspeed; }	
	NxScrollbar *GetScroller() {return scroller;}
	bool TimerEnabled()	const { return TimerEnable; }	
	Fl_EditorEngine *Engine()  	{ return engine; };
	void HideCursor(bool hideit)	{ __Cursor->hideall(hideit); };
	bool HideCursor() {return 0;  return __Cursor->hideall(); };
	bool browse()		{ return Browsemode; };
        bool WantTabs()   { return keeptabs; };
        void WantTabs(bool setting)     { keeptabs = setting; };

#ifndef FL_TAB
        #define FL_TAB FL_Tab

#endif //FL_EDIT_H

More information about the dslinux-commit mailing list