diff options
| author | No Author <No Author> | 2001-08-01 21:24:49 +0000 |
|---|---|---|
| committer | No Author <No Author> | 2001-08-01 21:24:49 +0000 |
| commit | 3cb5ebe0e811f3db008085d985b7761725589a74 (patch) | |
| tree | 0a7184a5f02fffe927af911758f3a9a4a2f4a37e /FL | |
| parent | 4477e166400f197bed50b09e01e695221cde96b6 (diff) | |
This commit was manufactured by cvs2svn to create branch 'branch-1.1'.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1513 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'FL')
| -rw-r--r-- | FL/Fl_Export.H | 37 | ||||
| -rw-r--r-- | FL/Fl_FileBrowser.H | 80 | ||||
| -rw-r--r-- | FL/Fl_FileChooser.H | 80 | ||||
| -rw-r--r-- | FL/Fl_FileIcon.H | 107 | ||||
| -rw-r--r-- | FL/Fl_Shared_Image.H | 203 | ||||
| -rw-r--r-- | FL/Fl_Text_Buffer.H | 241 | ||||
| -rw-r--r-- | FL/Fl_Text_Display.H | 217 | ||||
| -rw-r--r-- | FL/Fl_Text_Editor.H | 105 | ||||
| -rw-r--r-- | FL/Fl_Tooltip.H | 72 |
9 files changed, 1142 insertions, 0 deletions
diff --git a/FL/Fl_Export.H b/FL/Fl_Export.H new file mode 100644 index 000000000..c4f6b2e95 --- /dev/null +++ b/FL/Fl_Export.H @@ -0,0 +1,37 @@ +/* + The following is only used when building DLLs under WIN32 +*/ + +#if defined(WIN32) && defined(FL_SHARED) +# ifdef FL_LIBRARY +# define FL_API __declspec(dllexport) +# else +# define FL_API __declspec(dllimport) +# endif +# ifdef FL_IMAGES_LIBRARY +# define FL_IMAGES_API __declspec(dllexport) +# else +# define FL_IMAGES_API __declspec(dllimport) +# endif +# ifdef FL_GLUT_LIBRARY +# define FL_GLUT_API __declspec(dllexport) +# else +# define FL_GLUT_API __declspec(dllimport) +# endif +# ifdef FL_FORMS_LIBRARY +# define FL_FORMS_API __declspec(dllexport) +# else +# define FL_FORMS_API __declspec(dllimport) +# endif +# ifdef FL_GL_LIBRARY +# define FL_GL_API __declspec(dllexport) +# else +# define FL_GL_API __declspec(dllimport) +# endif +#else +# define FL_API +# define FL_IMAGES_API +# define FL_GLUT_API +# define FL_FORMS_API +# define FL_GL_API +#endif diff --git a/FL/Fl_FileBrowser.H b/FL/Fl_FileBrowser.H new file mode 100644 index 000000000..4b3f2bd11 --- /dev/null +++ b/FL/Fl_FileBrowser.H @@ -0,0 +1,80 @@ +// +// "$Id: Fl_FileBrowser.H,v 1.4 2000/01/16 07:44:20 robertk Exp $" +// +// Fl_FileBrowser definitions for the Fast Light Tool Kit (FLTK). +// +// Copyright 1997-1999 by Easy Software Products. +// +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@easysw.com". +// + +// +// Include necessary header files... +// + +#ifndef _FL_FILEBROWSER_H_ +# define _FL_FILEBROWSER_H_ + +# include <FL/Fl_Browser.H> +# include <FL/Fl_FileIcon.H> + + +// +// Fl_FileBrowser class... +// + +class FL_API Fl_FileBrowser : public Fl_Browser +{ + const char *directory_; + uchar iconsize_; + const char *pattern_; + + int item_height(void *) const; + int item_width(void *) const; + void item_draw(void *, int, int, int, int) const; + int incr_height() const { return (item_height(0)); } + +public: + Fl_FileBrowser(int, int, int, int, const char * = 0); + + uchar iconsize() const { return (iconsize_); }; + void iconsize(uchar s) { iconsize_ = s; redraw(); }; + + void directory(const char *directory) { load(directory); } + const char *directory(void) const { return (directory_); } + + void filter(const char *pattern); + const char *filter() const { return (pattern_); }; + + int load(const char *directory); + +#ifdef FLTK_2 + unsigned textsize() const { return (Fl_Browser::text_size()); }; + void textsize(unsigned s) { Fl_Browser::text_size(s); }; +#else + uchar textsize() const { return (Fl_Browser::textsize()); }; + void textsize(uchar s) { Fl_Browser::textsize(s); }; +#endif + +}; + +#endif // !_FL_FILEBROWSER_H_ + +// +// End of "$Id: Fl_FileBrowser.H,v 1.4 2000/01/16 07:44:20 robertk Exp $". +// diff --git a/FL/Fl_FileChooser.H b/FL/Fl_FileChooser.H new file mode 100644 index 000000000..81790510b --- /dev/null +++ b/FL/Fl_FileChooser.H @@ -0,0 +1,80 @@ +// generated by Fast Light User Interface Designer (fluid) version 2.0000 + +#ifndef Fl_FileChooser_h +#define Fl_FileChooser_h +#include <FL/Fl.H> +#include <FL/Fl_Window.H> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <FL/Fl_Choice.H> +#include <FL/Fl_Button.H> +#include "filename.H" +#include <FL/Fl_FileBrowser.H> +#include <FL/Fl_FileInput.H> +#include <FL/Fl_Return_Button.H> + +class FL_API Fl_FileChooser { +public: + enum { SINGLE, MULTI, CREATE }; + Fl_FileChooser(const char *d, const char *p, int t, const char *title); + Fl_Window *window; +private: + inline void cb_window_i(Fl_Window*, void*); + static void cb_window(Fl_Window*, void*); + Fl_Choice *dirMenu; + inline void cb_dirMenu_i(Fl_Choice*, void*); + static void cb_dirMenu(Fl_Choice*, void*); + Fl_Button *upButton; + inline void cb_upButton_i(Fl_Button*, void*); + static void cb_upButton(Fl_Button*, void*); + Fl_Button *newButton; + inline void cb_newButton_i(Fl_Button*, void*); + static void cb_newButton(Fl_Button*, void*); + inline void cb__i(Fl_Button*, void*); + static void cb_(Fl_Button*, void*); + Fl_FileBrowser *fileList; + inline void cb_fileList_i(Fl_FileBrowser*, void*); + static void cb_fileList(Fl_FileBrowser*, void*); + Fl_FileInput *fileName; + inline void cb_fileName_i(Fl_FileInput*, void*); + static void cb_fileName(Fl_FileInput*, void*); + Fl_Return_Button *okButton; + inline void cb_okButton_i(Fl_Return_Button*, void*); + static void cb_okButton(Fl_Return_Button*, void*); + inline void cb_Cancel_i(Fl_Button*, void*); + static void cb_Cancel(Fl_Button*, void*); + char directory_[1024]; + int type_; + void fileListCB(); + void fileNameCB(); + void newdir(); + void up(); +public: + void color(Fl_Color c); + Fl_Color color(); + int count(); + void directory(const char *d); + char * directory(); + void exec(); + void filter(const char *p); + const char * filter(); + void hide(); + void iconsize(uchar s); + uchar iconsize(); + void label(const char *l); + const char * label(); + void rescan(); + void textcolor(Fl_Color c); + Fl_Color textcolor(); + void textfont(Fl_Font f); + Fl_Font textfont(); + void textsize(uchar s); + uchar textsize(); + void type(int t); + int type(); + const char *value(int f = 1); + void value(const char *filename); + int visible(); +}; +#endif diff --git a/FL/Fl_FileIcon.H b/FL/Fl_FileIcon.H new file mode 100644 index 000000000..6df0f7d54 --- /dev/null +++ b/FL/Fl_FileIcon.H @@ -0,0 +1,107 @@ +// +// "$Id: Fl_FileIcon.H,v 1.1 2000/01/08 22:14:13 vincent Exp $" +// +// Fl_FileIcon definitions for the Fast Light Tool Kit (FLTK). +// +// Copyright 1997-1999 by Easy Software Products. +// +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@easysw.com". +// + +// +// Include necessary header files... +// + +#ifndef _FL_FILEICON_H_ +# define _FL_FILEICON_H_ + +# include <FL/Fl.H> + + +// +// Fl_FileIcon class... +// + +class FL_API Fl_FileIcon //// Icon data +{ + static Fl_FileIcon *first_; // Pointer to first icon/filetype + Fl_FileIcon *next_; // Pointer to next icon/filetype + const char *pattern_; // Pattern string + int type_; // Match only if directory or file? + int num_data_; // Number of data elements + int alloc_data_; // Number of allocated elements + short *data_; // Icon data + + public: + + enum // File types + { + ANY, // Any kind of file + PLAIN, // Only plain files + FIFO, // Only named pipes + DEVICE, // Only character and block devices + LINK, // Only symbolic links + DIR // Only directories + }; + + enum // Data opcodes + { + END, // End of primitive/icon + COLOR, // Followed by color index + LINE, // Start of line + CLOSEDLINE, // Start of closed line + POLYGON, // Start of polygon + OUTLINEPOLYGON, // Followed by outline color + VERTEX // Followed by scaled X,Y + }; + + Fl_FileIcon(const char *p, int t, int nd = 0, short *d = 0); + ~Fl_FileIcon(); + + short *add(short d); + short *add_color(short c) + { short *d = add(COLOR); add(c); return (d); } + short *add_vertex(int x, int y) + { short *d = add(VERTEX); add(x); add(y); return (d); } + short *add_vertex(float x, float y) + { short *d = add(VERTEX); add((int)(x * 10000.0)); + add((int)(y * 10000.0)); return (d); } + void clear() { num_data_ = 0; } + void draw(int x, int y, int w, int h, Fl_Color ic, int active = 1); + void label(Fl_Widget *w); +// static void labeltype(const Fl_Label *o, int x, int y, int w, int h, Fl_Align a); + void load(const char *f); + void load_fti(const char *fti); + void load_xpm(const char *xpm); + const char *pattern() { return (pattern_); } + int size() { return (num_data_); } + int type() { return (type_); } + short *value() { return (data_); } + + static Fl_FileIcon *find(const char *filename, int filetype = ANY); + static Fl_FileIcon *first() { return (first_); } + static void load_system_icons(void); +}; + +//#define _FL_ICON_LABEL FL_FREE_LABELTYPE + +#endif // !_FL_FILEICON_H_ + +// +// End of "$Id: Fl_FileIcon.H,v 1.1 2000/01/08 22:14:13 vincent Exp $". +// diff --git a/FL/Fl_Shared_Image.H b/FL/Fl_Shared_Image.H new file mode 100644 index 000000000..11c5ce794 --- /dev/null +++ b/FL/Fl_Shared_Image.H @@ -0,0 +1,203 @@ +// +// "$Id: Fl_Shared_Image.H,v 1.22 2001/07/16 19:38:17 robertk Exp $" +// +// Image file header file for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-1999 by Bill Spitzak and others. +// +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@easysw.com". +// + +#ifndef Fl_Shared_Image_H +#define Fl_Shared_Image_H + +#include <FL/Fl_Image.H> +#include <stddef.h> + +struct FL_IMAGES_API Fl_Image_Type; + +// Shared images class. +class FL_IMAGES_API Fl_Shared_Image : public Fl_Image { +protected: + static const char* fl_shared_image_root; + + static int image_used; + static size_t mem_usage_limit; + + static size_t mem_used; + static int forbid_delete; + + Fl_Shared_Image* l1; // Left leaf in the binary tree + Fl_Shared_Image* l2; // Right leaf in the binary tree + const char* name; // Used to indentify the image, and as filename + const uchar* datas; // If non zero, pointers on inlined compressed datas + unsigned int used; // Last time used, for cache handling purpose + int refcount; // Number of time this image has been get + + Fl_Shared_Image() { }; // Constructor is private on purpose, + // use the get function rather + ~Fl_Shared_Image(); + + void find_less_used(); + static void check_mem_usage(); + + const char* get_filename();// Return the filename obtained from the concatenation + // of the image root directory and this image name + // WARNING : the returned pointer will be + // available only until next call to get_filename + + static const char* get_filename(const char*); + + virtual void read() = 0;// decompress the image and create its pixmap + + static void insert(Fl_Shared_Image*& p, Fl_Shared_Image* image); + static Fl_Shared_Image* find(Fl_Shared_Image* image, const char* name); + void remove_from_tree(Fl_Shared_Image*& p, Fl_Shared_Image* image); + + +public: + static Fl_Shared_Image *first_image; + + // Return an Fl_Shared_Image, using the create function if an image with + // the given name doesn't already exist. Use datas, or read from the + // file with filename name if datas==0. + static Fl_Shared_Image* get(Fl_Shared_Image* (*create)(), + const char* name, const uchar* datas=0); + + // Reload the image, useful if it has changed on disk, or if the datas + // in memory have changed (you can also give a new pointer on datas) + void reload(const uchar* datas=0); + static void reload(const char* name, const uchar* datas=0); + + // Remove an image from the database and delete it if its refcount has + // fallen to zero + // Each remove decrement the refcount, each get increment it + // Return 1 if it has been really deleted. + int remove(); + static int remove(const char* name); + + // Clear the cache for this image and all of its children in the binary tree + void clear_cache(); + + // Try to guess the filetype + // Beware that calling this force you to link in all image types ! + static Fl_Image_Type* guess(const char* name, const uchar* datas=0); + + // Set the position where images are looked for on disk + static void set_root_directory(const char* d); + + // Set the size of the cache (0 = unlimited is the default) + static void set_cache_size(size_t l); + + virtual void draw(int X, int Y, int W, int H, int cx, int cy); +}; + + + +// Description of a file format +struct FL_IMAGES_API Fl_Image_Type { + // Name of the filetype as it appear in the source code (uppercase) + const char* name; + // Function to test the filetype + int (*test)(const uchar* datas, size_t size=0); + // Function to get/create an image of this type + Fl_Shared_Image* (*get)(const char* name, const uchar* datas=0); +}; +extern FL_IMAGES_API Fl_Image_Type fl_image_filetypes[]; + +/* Specific image format functions. Add you own file format here. */ + +// PNG image class +class FL_IMAGES_API Fl_PNG_Image : public Fl_Shared_Image { + void read(); // Uncompress PNG datas + Fl_PNG_Image() { } + static Fl_Shared_Image* create() { return new Fl_PNG_Image; } // Instantiate +public: +// Check the given buffer if it is in PNG format + static int test(const uchar* datas, size_t size=0); + void measure(int& W, int& H); // Return width and heigth + static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) { + return Fl_Shared_Image::get(create, name, datas); + } +}; + +class FL_IMAGES_API Fl_GIF_Image : public Fl_Shared_Image { + void read(); + Fl_GIF_Image() { } + static Fl_Shared_Image* create() { return new Fl_GIF_Image; } +public: + static int test(const uchar* datas, size_t size=0); + void measure(int& W, int& H); + static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) { + return Fl_Shared_Image::get(create, name, datas); + } +}; + +class FL_IMAGES_API Fl_XPM_Image : public Fl_Shared_Image { + void read(); + Fl_XPM_Image() { } + static Fl_Shared_Image* create() { return new Fl_XPM_Image; } +public: + static int test(const uchar* datas, size_t size=0); + void measure(int& W, int& H); + static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) { + return Fl_Shared_Image::get(create, name, datas); + } +}; + +class FL_IMAGES_API Fl_BMP_Image : public Fl_Shared_Image { + void read(); + Fl_BMP_Image() { } + static Fl_Shared_Image* create() { return new Fl_BMP_Image; } +public: + static int test(const uchar* datas, size_t size=0); + void measure(int& W, int& H); + static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) { + return Fl_Shared_Image::get(create, name, datas); + } +}; + +class FL_IMAGES_API Fl_JPEG_Image : public Fl_Shared_Image { + void read(); + Fl_JPEG_Image() { } + static Fl_Shared_Image* create() { return new Fl_JPEG_Image; } +public: + static int test(const uchar* datas, size_t size=0); + void measure(int& W, int& H); + static Fl_Shared_Image* get(const char* name, const uchar* datas = 0) { + return Fl_Shared_Image::get(create, name, datas); + } +}; + +//class FL_API Fl_Bitmap; +class Fl_Bitmap; +extern FL_IMAGES_API Fl_Bitmap nosuch_bitmap; + +class FL_IMAGES_API Fl_UNKNOWN_Image { +public: + static int test(const uchar*, size_t =0) { return 1; }; + static Fl_Shared_Image* get(const char*, const uchar* = 0) { + return (Fl_Shared_Image*) &nosuch_bitmap; + }; +}; + +#endif + +// +// End of "$Id: Fl_Shared_Image.H,v 1.22 2001/07/16 19:38:17 robertk Exp $" +// diff --git a/FL/Fl_Text_Buffer.H b/FL/Fl_Text_Buffer.H new file mode 100644 index 000000000..2528c2fa8 --- /dev/null +++ b/FL/Fl_Text_Buffer.H @@ -0,0 +1,241 @@ +// +// "$Id: Fl_Text_Buffer.H,v 1.3 2001/02/21 06:15:44 clip Exp $" +// +// Header file for Fl_Text_Buffer class. +// +// Copyright Mark Edel. Permission to distribute under the LGPL for +// the FLTK library granted by Mark Edel. +// +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@fltk.org". +// + +#ifndef FL_TEXT_BUFFER_H +#define FL_TEXT_BUFFER_H + +/* Maximum length in characters of a tab or control character expansion + of a single buffer character */ +#define FL_TEXT_MAX_EXP_CHAR_LEN 20 + +#include <FL/Fl_Export.H> + +class FL_API Fl_Text_Selection { + friend class Fl_Text_Buffer; + + public: + void set(int start, int end); + void set_rectangular(int start, int end, int rectStart, int rectEnd); + void update(int pos, int nDeleted, int nInserted); + char rectangular() { return mRectangular; } + int start() { return mStart; } + int end() { return mEnd; } + int rect_start() { return mRectStart; } + int rect_end() { return mRectEnd; } + char selected() { return mSelected; } + void selected(char b) { mSelected = b; } + int includes(int pos, int lineStartPos, int dispIndex); + int position(int* start, int* end); + int position(int* start, int* end, int* isRect, int* rectStart, int* rectEnd); + + + protected: + char mSelected; + char mRectangular; + int mStart; + int mEnd; + int mRectStart; + int mRectEnd; +}; + +typedef void (*Fl_Text_Modify_Cb)(int pos, int nInserted, int nDeleted, + int nRestyled, const char* deletedText, + void* cbArg); + +class FL_API Fl_Text_Buffer { + public: + Fl_Text_Buffer(int requestedSize = 0); + ~Fl_Text_Buffer(); + + int length() { return mLength; } + const char* text(); + void text(const char* text); + const char* text_range(int start, int end); + char character(int pos); + const char* text_in_rectangle(int start, int end, int rectStart, int rectEnd); + void insert(int pos, const char* text); + void append(const char* text) { insert(length(), text); } + void remove(int start, int end); + void replace(int start, int end, const char *text); + void copy(Fl_Text_Buffer* fromBuf, int fromStart, int fromEnd, int toPos); + int insertfile(const char *file, int pos, int buflen = 128*1024); + int appendfile(const char *file, int buflen = 128*1024) + { return insertfile(file, length(), buflen); } + int loadfile(const char *file, int buflen = 128*1024) + { select(0, length()); remove_selection(); return appendfile(file, buflen); } + int outputfile(const char *file, int start, int end, int buflen = 128*1024); + int savefile(const char *file, int buflen = 128*1024) + { return outputfile(file, 0, length(), buflen); } + + void insert_column(int column, int startPos, const char* text, + int* charsInserted, int* charsDeleted); + + void replace_rectangular(int start, int end, int rectStart, int rectEnd, + const char* text); + + void overlay_rectangular(int startPos, int rectStart, int rectEnd, + const char* text, int* charsInserted, + int* charsDeleted); + + void remove_rectangular(int start, int end, int rectStart, int rectEnd); + void clear_rectangular(int start, int end, int rectStart, int rectEnd); + int tab_distance() { return mTabDist; } + void tab_distance(int tabDist); + void select(int start, int end); + int selected() { return mPrimary.selected(); } + void unselect(); + void select_rectangular(int start, int end, int rectStart, int rectEnd); + int selection_position(int* start, int* end); + + int selection_position(int* start, int* end, int* isRect, int* rectStart, + int* rectEnd); + + const char* selection_text(); + void remove_selection(); + void replace_selection(const char* text); + void secondary_select(int start, int end); + void secondary_unselect(); + + void secondary_select_rectangular(int start, int end, int rectStart, + int rectEnd); + + int secondary_selection_position(int* start, int* end, int* isRect, + int* rectStart, int* rectEnd); + + const char* secondary_selection_text(); + void remove_secondary_selection(); + void replace_secondary_selection(const char* text); + void highlight(int start, int end); + void unhighlight(); + void highlight_rectangular(int start, int end, int rectStart, int rectEnd); + + int highlight_position(int* start, int* end, int* isRect, int* rectStart, + int* rectEnd); + + const char* highlight_text(); + void add_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void* cbArg); + void remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void* cbArg); + + void call_modify_callbacks() { call_modify_callbacks(0, 0, 0, 0, 0); } + + const char* line_text(int pos); + int line_start(int pos); + int line_end(int pos); + int word_start(int pos); + int word_end(int pos); + int expand_character(int pos, int indent, char *outStr); + + static int expand_character(char c, int indent, char* outStr, int tabDist, + char nullSubsChar); + + static int character_width(char c, int indent, int tabDist, char nullSubsChar); + int count_displayed_characters(int lineStartPos, int targetPos); + int skip_displayed_characters(int lineStartPos, int nChars); + int count_lines(int startPos, int endPos); + int skip_lines(int startPos, int nLines); + int rewind_lines(int startPos, int nLines); + int findchar_forward(int startPos, char searchChar, int* foundPos); + int findchar_backward(int startPos, char searchChar, int* foundPos); + int findchars_forward(int startPos, const char* searchChars, int* foundPos); + int findchars_backward(int startPos, const char* searchChars, int* foundPos); + + int search_forward(int startPos, const char* searchString, int* foundPos, + int matchCase = 0); + + int search_backward(int startPos, const char* searchString, int* foundPos, + int matchCase = 0); + + int substitute_null_characters(char* string, int length); + void unsubstitute_null_characters(char* string); + char null_substitution_character() { return mNullSubsChar; } + Fl_Text_Selection* primary_selection() { return &mPrimary; } + Fl_Text_Selection* secondary_selection() { return &mSecondary; } + Fl_Text_Selection* highlight_selection() { return &mHighlight; } + + protected: + void call_modify_callbacks(int pos, int nDeleted, int nInserted, + int nRestyled, const char* deletedText); + + int insert_(int pos, const char* text); + void remove_(int start, int end); + + void remove_rectangular_(int start, int end, int rectStart, int rectEnd, + int* replaceLen, int* endPos); + + void insert_column_(int column, int startPos, const char* insText, + int* nDeleted, int* nInserted, int* endPos); + + void overlay_rectangular_(int startPos, int rectStart, int rectEnd, + const char* insText, int* nDeleted, + int* nInserted, int* endPos); + + void redisplay_selection(Fl_Text_Selection* oldSelection, + Fl_Text_Selection* newSelection); + + void move_gap(int pos); + void reallocate_with_gap(int newGapStart, int newGapLen); + const char* selection_text_(Fl_Text_Selection* sel); + void remove_selection_(Fl_Text_Selection* sel); + void replace_selection_(Fl_Text_Selection* sel, const char* text); + + void rectangular_selection_boundaries(int lineStartPos, int rectStart, + int rectEnd, int* selStart, + int* selEnd); + + void update_selections(int pos, int nDeleted, int nInserted); + + Fl_Text_Selection mPrimary; /* highlighted areas */ + Fl_Text_Selection mSecondary; + Fl_Text_Selection mHighlight; + int mLength; /* length of the text in the buffer (the length + of the buffer itself must be calculated: + gapEnd - gapStart + length) */ + char* mBuf; /* allocated memory where the text is stored */ + int mGapStart; /* points to the first character of the gap */ + int mGapEnd; /* points to the first char after the gap */ + // The hardware tab distance used by all displays for this buffer, + // and used in computing offsets for rectangular selection operations. + int mTabDist; /* equiv. number of characters in a tab */ + int mUseTabs; /* True if buffer routines are allowed to use + tabs for padding in rectangular operations */ + int mNModifyProcs; /* number of modify-redisplay procs attached */ + Fl_Text_Modify_Cb* /* procedures to call when buffer is */ + mNodifyProcs; /* modified to redisplay contents */ + void** mCbArgs; /* caller arguments for modifyProcs above */ + int mCursorPosHint; /* hint for reasonable cursor position after + a buffer modification operation */ + char mNullSubsChar; /* NEdit is based on C null-terminated strings, + so ascii-nul characters must be substituted + with something else. This is the else, but + of course, things get quite messy when you + use it */ +}; + +#endif + +// +// End of "$Id: Fl_Text_Buffer.H,v 1.3 2001/02/21 06:15:44 clip Exp $". +// diff --git a/FL/Fl_Text_Display.H b/FL/Fl_Text_Display.H new file mode 100644 index 000000000..af9d3df0b --- /dev/null +++ b/FL/Fl_Text_Display.H @@ -0,0 +1,217 @@ +// +// "$Id: Fl_Text_Display.H,v 1.4 2000/08/20 04:31:36 spitzak Exp $" +// +// Header file for Fl_Text_Display class. +// +// Copyright Mark Edel. Permission to distribute under the LGPL for +// the FLTK library granted by Mark Edel. +// +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@fltk.org". +// + +#ifndef FL_TEXT_DISPLAY_H +#define FL_TEXT_DISPLAY_H + +#include <FL/fl_draw.H> +#include <FL/Fl_Group.H> +#include <FL/Fl_Widget.H> +#include <FL/Fl_Scrollbar.H> +#include <FL/Fl_Text_Buffer.H> + +class FL_API Fl_Text_Display: public Fl_Group { + public: + enum { + NORMAL_CURSOR, CARET_CURSOR, DIM_CURSOR, + BLOCK_CURSOR, HEAVY_CURSOR + }; + + enum { + CURSOR_POS, CHARACTER_POS + }; + + // drag types- they match Fl::event_clicks() so that single clicking to + // start a collection selects by character, double clicking selects by + // word and triple clicking selects by line. + enum { + DRAG_CHAR = 0, DRAG_WORD = 1, DRAG_LINE = 2 + }; + friend void fl_text_drag_me(int pos, Fl_Text_Display* d); + + typedef void (*Unfinished_Style_Cb)(); + + struct FL_API Style_Table_Entry { + Fl_Color color; + Fl_Font font; + int size; + }; + + Fl_Text_Display(int X, int Y, int W, int H, const char *l = 0); + ~Fl_Text_Display(); + + virtual int handle(int e); + void buffer(Fl_Text_Buffer* buf); + void buffer(Fl_Text_Buffer& buf) { buffer(&buf); } + Fl_Text_Buffer* buffer() { return mBuffer; } + void redisplay_range(int start, int end); + void scroll(int topLineNum, int horizOffset); + void insert(const char* text); + void overstrike(const char* text); + void insert_position(int newPos); + int insert_position() { return mCursorPos; } + int in_selection(int x, int y); + void show_insert_position(); + int move_right(); + int move_left(); + int move_up(); + int move_down(); + void next_word(void); + void previous_word(void); + void show_cursor(int b = 1); + void hide_cursor() { show_cursor(0); } + void cursor_style(int style); + int scrollbar_width() { return scrollbar_width_; } + Fl_Flags scrollbar_align() { return scrollbar_align_; } + void scrollbar_width(int w) { scrollbar_width_ = w; } + void scrollbar_align(Fl_Flags a) { scrollbar_align_ = a; } + int word_start(int pos) { return buffer()->word_start(pos); } + int word_end(int pos) { return buffer()->word_end(pos); } + + void highlight_data(Fl_Text_Buffer *styleBuffer, + Style_Table_Entry *styleTable, + int nStyles, char unfinishedStyle, + Unfinished_Style_Cb unfinishedHighlightCB, + void *cbArg); + + int position_style(int lineStartPos, int lineLen, int lineIndex, + int dispIndex); + + protected: + // Most (all?) of this stuff should only be called from layout() or + // draw(). + // Anything with "vline" indicates thats it deals with currently + // visible lines. + virtual void layout(); + + virtual void draw(); + void draw_text(int X, int Y, int W, int H); + void draw_range(int start, int end); + void draw_cursor(int, int); + + void draw_string(int style, int x, int y, int toX, const char *string, + int nChars); + + void draw_vline(int visLineNum, int leftClip, int rightClip, + int leftCharIndex, int rightCharIndex); + + void clear_rect(int style, int x, int y, int width, int height); + void display_insert(); + + void offset_line_starts(int newTopLineNum); + + void calc_line_starts(int startLine, int endLine); + + void update_line_starts(int pos, int charsInserted, int charsDeleted, + int linesInserted, int linesDeleted, int *scrolled); + + void calc_last_char(); + + int position_to_line( int pos, int* lineNum ); + int string_width(const char* string, int length, int style); + + static void buffer_modified_cb(int pos, int nInserted, int nDeleted, + int nRestyled, const char* deletedText, + void* cbArg); + + static void h_scrollbar_cb(Fl_Scrollbar* w, Fl_Text_Display* d); + static void v_scrollbar_cb( Fl_Scrollbar* w, Fl_Text_Display* d); + void update_v_scrollbar(); + void update_h_scrollbar(); + int measure_vline(int visLineNum); + int longest_vline(); + int empty_vlines(); + int vline_length(int visLineNum); + int xy_to_position(int x, int y, int PosType = CHARACTER_POS); + + void xy_to_rowcol(int x, int y, int* row, int* column, + int PosType = CHARACTER_POS); + + int position_to_xy(int pos, int* x, int* y); + int position_to_linecol(int pos, int* lineNum, int* column); + void scroll_(int topLineNum, int horizOffset); + + void extend_range_for_styles(int* start, int* end); + + + int damage_range1_start, damage_range1_end; + int damage_range2_start, damage_range2_end; + int mCursorPos; + int mCursorOn; + int mCursorOldY; /* Y pos. of cursor for blanking */ + int mCursorToHint; /* Tells the buffer modified callback + where to move the cursor, to reduce + the number of redraw calls */ + int mCursorStyle; /* One of enum cursorStyles above */ + int mCursorPreferredCol; /* Column for vert. cursor movement */ + int mNVisibleLines; /* # of visible (displayed) lines */ + int mNBufferLines; /* # of newlines in the buffer */ + Fl_Text_Buffer* mBuffer; /* Contains text to be displayed */ + Fl_Text_Buffer* mStyleBuffer; /* Optional parallel buffer containing + color and font information */ + int mFirstChar, mLastChar; /* Buffer positions of first and last + displayed character (lastChar points + either to a newline or one character + beyond the end of the buffer) */ + int* mLineStarts; + int mTopLineNum; /* Line number of top displayed line + of file (first line of file is 1) */ + int mHorizOffset; /* Horizontal scroll pos. in pixels */ + int mTopLineNumHint; /* Line number of top displayed line + of file (first line of file is 1) */ + int mHorizOffsetHint; /* Horizontal scroll pos. in pixels */ + int mVisibility; /* Window visibility (see XVisibility + event) */ + int mNStyles; /* Number of entries in styleTable */ + Style_Table_Entry *mStyleTable; /* Table of fonts and colors for + coloring/syntax-highlighting */ + char mUnfinishedStyle; /* Style buffer entry which triggers + on-the-fly reparsing of region */ + Unfinished_Style_Cb mUnfinishedHighlightCB; /* Callback to parse "unfinished" */ + /* regions */ + void* mHighlightCBArg; /* Arg to unfinishedHighlightCB */ + + int mMaxsize; + + int mFixedFontWidth; /* Font width if all current fonts are + fixed and match in width, else -1 */ + + Fl_Color mCursor_color; + + Fl_Scrollbar* mHScrollBar; + Fl_Scrollbar* mVScrollBar; + int scrollbar_width_; + Fl_Flags scrollbar_align_; + int dragPos, dragType, dragging; + int display_insert_position_hint; + struct { int x, y, w, h; } text_area; +}; + +#endif + +// +// End of "$Id: Fl_Text_Display.H,v 1.4 2000/08/20 04:31:36 spitzak Exp $". +// diff --git a/FL/Fl_Text_Editor.H b/FL/Fl_Text_Editor.H new file mode 100644 index 000000000..980a7fb84 --- /dev/null +++ b/FL/Fl_Text_Editor.H @@ -0,0 +1,105 @@ +// +// "$Id: Fl_Text_Editor.H,v 1.1 2000/08/04 10:21:59 clip Exp $" +// +// Header file for Fl_Text_Editor class. +// +// Copyright Mark Edel. Permission to distribute under the LGPL for +// the FLTK library granted by Mark Edel. +// +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@fltk.org". +// + + +#ifndef FL_TEXT_EDITOR_H +#define FL_TEXT_EDITOR_H + +#include <FL/Fl_Text_Display.H> + +// key will match in any state +#define FL_TEXT_EDITOR_ANY_STATE (-1L) + +class FL_API Fl_Text_Editor : public Fl_Text_Display { + public: + typedef int (*Key_Func)(int key, Fl_Text_Editor* editor); + + struct FL_API Key_Binding { + int key; + int state; + Key_Func function; + Key_Binding* next; + }; + + Fl_Text_Editor(int X, int Y, int W, int H, const char* l = 0); + ~Fl_Text_Editor() { remove_all_key_bindings(); } + virtual int handle(int e); + void insert_mode(int b) { insert_mode_ = b; } + int insert_mode() { return insert_mode_; } + + void add_key_binding(int key, int state, Key_Func f, Key_Binding** list); + void add_key_binding(int key, int state, Key_Func f) + { add_key_binding(key, state, f, &key_bindings); } + void remove_key_binding(int key, int state, Key_Binding** list); + void remove_key_binding(int key, int state) + { remove_key_binding(key, state, &key_bindings); } + void remove_all_key_bindings(Key_Binding** list); + void remove_all_key_bindings() { remove_all_key_bindings(&key_bindings); } + void add_default_key_bindings(Key_Binding** list); + Key_Func bound_key_function(int key, int state, Key_Binding* list); + Key_Func bound_key_function(int key, int state) + { return bound_key_function(key, state, key_bindings); } + void default_key_function(Key_Func f) { default_key_function_ = f; } + + // functions for the built in default bindings + static int kf_default(int c, Fl_Text_Editor* e); + static int kf_ignore(int c, Fl_Text_Editor* e); + static int kf_backspace(int c, Fl_Text_Editor* e); + static int kf_enter(int c, Fl_Text_Editor* e); + static int kf_move(int c, Fl_Text_Editor* e); + static int kf_shift_move(int c, Fl_Text_Editor* e); + static int kf_ctrl_move(int c, Fl_Text_Editor* e); + static int kf_c_s_move(int c, Fl_Text_Editor* e); + static int kf_home(int, Fl_Text_Editor* e); + static int kf_end(int c, Fl_Text_Editor* e); + static int kf_left(int c, Fl_Text_Editor* e); + static int kf_up(int c, Fl_Text_Editor* e); + static int kf_right(int c, Fl_Text_Editor* e); + static int kf_down(int c, Fl_Text_Editor* e); + static int kf_page_up(int c, Fl_Text_Editor* e); + static int kf_page_down(int c, Fl_Text_Editor* e); + static int kf_insert(int c, Fl_Text_Editor* e); + static int kf_delete(int c, Fl_Text_Editor* e); + static int kf_copy(int c, Fl_Text_Editor* e); + static int kf_cut(int c, Fl_Text_Editor* e); + static int kf_paste(int c, Fl_Text_Editor* e); + static int kf_select_all(int c, Fl_Text_Editor* e); + + protected: + int handle_key(); + + int insert_mode_; + Key_Binding* key_bindings; + static Key_Binding* global_key_bindings; + Key_Func default_key_function_; +}; + +#endif + +// +// End of "$Id: Fl_Text_Editor.H,v 1.1 2000/08/04 10:21:59 clip Exp $". +// + diff --git a/FL/Fl_Tooltip.H b/FL/Fl_Tooltip.H new file mode 100644 index 000000000..054c16786 --- /dev/null +++ b/FL/Fl_Tooltip.H @@ -0,0 +1,72 @@ +// +// "$Id: Fl_Tooltip.H,v 1.16 2001/02/25 01:41:19 clip Exp $" +// +// Tooltip definitions for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-1999 by Bill Spitzak and others. +// +// 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 +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// 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 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@easysw.com". +// + +#ifndef _FL_TOOLTIP_H_ +#define _FL_TOOLTIP_H_ + +#include <FL/Fl.H> +#include <FL/Fl_Widget.H> + +class FL_API Fl_Tooltip { +public: + static float delay() { return delay_; } + static void delay(float f) { delay_ = f; } + static int enabled() { return enabled_; } + static void enable(int b = 1) { enabled_ = b; } + static void disable() { enable(0); } + + // This is called when the pointer enters a widget, + // Also enter(0) gets rid of any displayed or pending tooltip: + static void (*enter)(Fl_Widget* w); + + // A widget may also pop up tooltips for internal parts by calling this: + static void (*enter_area)(Fl_Widget* w, int X, int Y, int W, int H, const char* tip); + + // This is called when a widget is destroyed or hidden: + static void (*exit)(Fl_Widget *w); + + static Fl_Style* style() { return default_style; } + static Fl_Font font() { return style()->label_font; } + static void font(Fl_Font i) { style()->label_font = i; } + static unsigned size() { return style()->label_size; } + static void size(unsigned s) { style()->label_size = s; } + static void color(Fl_Color c) { style()->color = c; } + static Fl_Color color() { return style()->color; } + static void textcolor(Fl_Color c) {style()->label_color = c; } + static Fl_Color textcolor() { return style()->label_color; } + static void boxtype(Fl_Boxtype b) {style()->box = b; } + static Fl_Boxtype boxtype() { return style()->box; } + +private: + static Fl_Named_Style* default_style; + static float delay_; + static int enabled_; +}; + +#endif + +// +// End of "$Id: Fl_Tooltip.H,v 1.16 2001/02/25 01:41:19 clip Exp $". +// |
