Browse Source

HelpView/HelpDialog updates.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1585 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/168/head
Michael R Sweet 24 years ago
parent
commit
743cd4f95d
  1. 3
      CHANGES
  2. 4
      FL/Fl_HelpDialog.H
  3. 7
      FL/Fl_HelpView.H
  4. 10
      documentation/index.html
  5. 16
      fluid/makedepend
  6. 6
      src/Fl_HelpDialog.cxx
  7. 11
      src/Fl_HelpDialog.fl
  8. 568
      src/Fl_HelpView.cxx
  9. 2
      src/makedepend

3
CHANGES

@ -22,6 +22,9 @@ CHANGES IN FLTK 1.1.0b2
style (round radio buttons with dots and square check style (round radio buttons with dots and square check
buttons with check marks.) buttons with check marks.)
- Improved the appearance of Fl_Check_Button. - Improved the appearance of Fl_Check_Button.
- Improved the Fl_HelpView table formatting code; now
dynamically sizes the table columns, and supports
COLSPAN.
CHANGES IN FLTK 1.1.0b1 CHANGES IN FLTK 1.1.0b1

4
FL/Fl_HelpDialog.H

@ -3,7 +3,7 @@
#ifndef Fl_HelpDialog_H #ifndef Fl_HelpDialog_H
#define Fl_HelpDialog_H #define Fl_HelpDialog_H
#include <FL/Fl.H> #include <FL/Fl.H>
#include <FL/Fl_Window.H> #include <FL/Fl_Double_Window.H>
#include <string.h> #include <string.h>
#include <FL/Fl_HelpView.H> #include <FL/Fl_HelpView.H>
#include <FL/Fl_Button.H> #include <FL/Fl_Button.H>
@ -16,7 +16,7 @@ class Fl_HelpDialog {
public: public:
Fl_HelpDialog(); Fl_HelpDialog();
private: private:
Fl_Window *window_; Fl_Double_Window *window_;
Fl_HelpView *view_; Fl_HelpView *view_;
inline void cb_view__i(Fl_HelpView*, void*); inline void cb_view__i(Fl_HelpView*, void*);
static void cb_view_(Fl_HelpView*, void*); static void cb_view_(Fl_HelpView*, void*);

7
FL/Fl_HelpView.H

@ -1,5 +1,5 @@
// //
// "$Id: Fl_HelpView.H,v 1.1.2.2 2001/08/06 23:51:39 easysw Exp $" // "$Id: Fl_HelpView.H,v 1.1.2.3 2001/09/10 03:09:43 easysw Exp $"
// //
// Help Viewer widget definitions. // Help Viewer widget definitions.
// //
@ -101,6 +101,7 @@ struct Fl_HelpImage
hattr[8]; // Height attribute hattr[8]; // Height attribute
Fl_Image *image; // FLTK image representation Fl_Image *image; // FLTK image representation
unsigned char *data; // Raw image data unsigned char *data; // Raw image data
int copy; // Data is a copy?
int w, h, d; // Image size & depth int w, h, d; // Image size & depth
}; };
@ -157,12 +158,14 @@ class Fl_HelpView : public Fl_Group //// Help viewer widget
int load_png(Fl_HelpImage *img, FILE *fp); int load_png(Fl_HelpImage *img, FILE *fp);
Fl_HelpBlock *add_block(const char *s, int xx, int yy, int ww, int hh, uchar border = 0); Fl_HelpBlock *add_block(const char *s, int xx, int yy, int ww, int hh, uchar border = 0);
static int compare_blocks(const void *a, const void *b);
void add_link(const char *n, int xx, int yy, int ww, int hh); void add_link(const char *n, int xx, int yy, int ww, int hh);
void add_target(const char *n, int yy); void add_target(const char *n, int yy);
static int compare_targets(const Fl_HelpTarget *t0, const Fl_HelpTarget *t1); static int compare_targets(const Fl_HelpTarget *t0, const Fl_HelpTarget *t1);
int do_align(Fl_HelpBlock *block, int line, int xx, int a, int &l); int do_align(Fl_HelpBlock *block, int line, int xx, int a, int &l);
void draw(); void draw();
void format(); void format();
void format_table(int *table_width, int *columns, const char *table);
int get_align(const char *p, int a); int get_align(const char *p, int a);
const char *get_attr(const char *p, const char *n, char *buf, int bufsize); const char *get_attr(const char *p, const char *n, char *buf, int bufsize);
Fl_Color get_color(const char *n, Fl_Color c); Fl_Color get_color(const char *n, Fl_Color c);
@ -207,5 +210,5 @@ class Fl_HelpView : public Fl_Group //// Help viewer widget
#endif // !_Fl_HelpView_H_ #endif // !_Fl_HelpView_H_
// //
// End of "$Id: Fl_HelpView.H,v 1.1.2.2 2001/08/06 23:51:39 easysw Exp $". // End of "$Id: Fl_HelpView.H,v 1.1.2.3 2001/09/10 03:09:43 easysw Exp $".
// //

10
documentation/index.html

@ -4,7 +4,7 @@
</HEAD> </HEAD>
<BODY> <BODY>
<CENTER><TABLE WIDTH=90% BGCOLOR=#9f9f9f CELLPADDING=8 CELLSPACING=0 SUMMARY="TITLE BAR"> <TABLE WIDTH=90% BGCOLOR=#9f9f9f CELLPADDING=8 CELLSPACING=0 SUMMARY="TITLE BAR">
<TR> <TR>
<TD ALIGN=CENTER VALIGN=MIDDLE WIDTH=100><IMG SRC="FL.gif" WIDTH=100 HEIGHT=70 ALIGN="ABSMIDDLE" ALT="FL"></TD> <TD ALIGN=CENTER VALIGN=MIDDLE WIDTH=100><IMG SRC="FL.gif" WIDTH=100 HEIGHT=70 ALIGN="ABSMIDDLE" ALT="FL"></TD>
<TD ALIGN=CENTER VALIGN=MIDDLE WIDTH=500> <TD ALIGN=CENTER VALIGN=MIDDLE WIDTH=500>
@ -13,6 +13,7 @@ Revision 0 by Michael Sweet, Craig P. Earls, and Bill Spitzak<BR>
Copyright 1998-2001 by Bill Spitzak and others.<BR> Copyright 1998-2001 by Bill Spitzak and others.<BR>
</TD> </TD>
</TR> </TR>
</TABLE>
<TABLE WIDTH=90% BGCOLOR=#9f9f9f CELLPADDING=8 CELLSPACING=0 SUMMARY="TITLE BAR"> <TABLE WIDTH=90% BGCOLOR=#9f9f9f CELLPADDING=8 CELLSPACING=0 SUMMARY="TITLE BAR">
<TR> <TR>
<TD ALIGN=CENTER WIDTH=600> <TD ALIGN=CENTER WIDTH=600>
@ -20,9 +21,8 @@ This software is provided under the terms of the GNU Library General
Public License. Public License.
</TD> </TD>
</TR> </TR>
</TABLE></CENTER> </TABLE>
<TABLE WIDTH=90% COLS=2 BGCOLOR=#9f9fef CELLPADDING=8 CELLSPACING=0 SUMMARY="Table of Contents">
<CENTER><TABLE WIDTH=90% COLS=2 BGCOLOR=#9f9fef CELLPADDING=8 CELLSPACING=0 SUMMARY="Table of Contents">
<TR> <TR>
<TD ALIGN=LEFT VALIGN=TOP WIDTH=300> <TD ALIGN=LEFT VALIGN=TOP WIDTH=300>
<B><A HREF=preface.html#preface>Preface</A></B> <B><A HREF=preface.html#preface>Preface</A></B>
@ -89,7 +89,7 @@ Widgets</A></B>
<B><A HREF=license.html#license>G - Software License</A></B> <B><A HREF=license.html#license>G - Software License</A></B>
</TD> </TD>
</TR> </TR>
</TABLE></CENTER> </TABLE>
</BODY> </BODY>
</HTML> </HTML>

16
fluid/makedepend

@ -110,15 +110,17 @@ file.o: ../FL/Fl_Tabs.H ../FL/Fl_Pack.H ../FL/Fl_Group.H ../FL/Fl_Wizard.H
file.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Button.H ../FL/Fl_Menu_Bar.H file.o: ../FL/Fl_Menu_.H ../FL/Fl_Menu_Button.H ../FL/Fl_Menu_Bar.H
fluid.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H fluid.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fluid.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H ../FL/Fl_Group.H fluid.o: ../FL/Fl_Double_Window.H ../FL/Fl_Window.H ../FL/Fl_Group.H
fluid.o: ../FL/Fl_Box.H ../FL/Fl_Button.H ../FL/Fl_Hold_Browser.H fluid.o: ../FL/Fl_Box.H ../FL/Fl_Button.H ../FL/Fl_HelpDialog.H
fluid.o: ../FL/Fl_Window.H ../FL/Fl_HelpView.H ../FL/Fl_Group.H
fluid.o: ../FL/Fl_Scrollbar.H ../FL/fl_draw.H ../FL/Fl_Hold_Browser.H
fluid.o: ../FL/Fl_Browser.H ../FL/Fl_Menu_Bar.H ../FL/Fl_Menu_.H fluid.o: ../FL/Fl_Browser.H ../FL/Fl_Menu_Bar.H ../FL/Fl_Menu_.H
fluid.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/fl_ask.H ../FL/fl_draw.H fluid.o: ../FL/Fl_Input.H ../FL/Fl_Input_.H ../FL/fl_ask.H
fluid.o: ../FL/fl_file_chooser.H ../FL/fl_message.H ../FL/fl_ask.H fluid.o: ../FL/fl_file_chooser.H ../FL/fl_message.H ../FL/fl_ask.H
fluid.o: ../FL/filename.H about_panel.h ../FL/Fl_Window.H ../FL/Fl_Group.H fluid.o: ../FL/filename.H ../config.h about_panel.h ../FL/Fl_Return_Button.H
fluid.o: ../FL/Fl_Return_Button.H ../FL/Fl_Button.H Fl_Type.h fluid.o: ../FL/Fl_Button.H Fl_Type.h ../FL/Fl_Widget.H ../FL/Fl_Menu.H
fluid.o: ../FL/Fl_Widget.H ../FL/Fl_Menu.H ../FL/Fl_Menu_Item.H Fluid_Image.h fluid.o: ../FL/Fl_Menu_Item.H Fluid_Image.h ../FL/Fl_Tabs.H ../FL/Fl_Pack.H
fluid.o: ../FL/Fl_Tabs.H ../FL/Fl_Pack.H ../FL/Fl_Wizard.H ../FL/Fl_Menu_.H fluid.o: ../FL/Fl_Wizard.H ../FL/Fl_Menu_.H ../FL/Fl_Menu_Button.H
fluid.o: ../FL/Fl_Menu_Button.H ../FL/Fl_Choice.H fluid.o: ../FL/Fl_Choice.H
about_panel.o: about_panel.h ../FL/Fl.H ../FL/Enumerations.H about_panel.o: about_panel.h ../FL/Fl.H ../FL/Enumerations.H
about_panel.o: ../FL/Fl_Export.H ../FL/Fl_Window.H ../FL/Fl_Group.H about_panel.o: ../FL/Fl_Export.H ../FL/Fl_Window.H ../FL/Fl_Group.H
about_panel.o: ../FL/Fl_Group.H ../FL/Fl_Box.H ../FL/Fl_Button.H about_panel.o: ../FL/Fl_Group.H ../FL/Fl_Box.H ../FL/Fl_Button.H

6
src/Fl_HelpDialog.cxx

@ -106,8 +106,8 @@ void Fl_HelpDialog::cb_larger_(Fl_Button* o, void* v) {
} }
Fl_HelpDialog::Fl_HelpDialog() { Fl_HelpDialog::Fl_HelpDialog() {
Fl_Window* w; Fl_Double_Window* w;
{ Fl_Window* o = window_ = new Fl_Window(530, 385, "Help Dialog"); { Fl_Double_Window* o = window_ = new Fl_Double_Window(530, 385, "Help Dialog");
w = o; w = o;
o->user_data((void*)(this)); o->user_data((void*)(this));
{ Fl_HelpView* o = view_ = new Fl_HelpView(10, 10, 510, 330); { Fl_HelpView* o = view_ = new Fl_HelpView(10, 10, 510, 330);
@ -121,13 +121,11 @@ Fl_HelpDialog::Fl_HelpDialog() {
} }
{ Fl_Button* o = back_ = new Fl_Button(365, 350, 25, 25, "@<-"); { Fl_Button* o = back_ = new Fl_Button(365, 350, 25, 25, "@<-");
o->shortcut(0xff51); o->shortcut(0xff51);
o->labeltype(FL_SYMBOL_LABEL);
o->labelcolor(2); o->labelcolor(2);
o->callback((Fl_Callback*)cb_back_); o->callback((Fl_Callback*)cb_back_);
} }
{ Fl_Button* o = forward_ = new Fl_Button(395, 350, 25, 25, "@->"); { Fl_Button* o = forward_ = new Fl_Button(395, 350, 25, 25, "@->");
o->shortcut(0xff53); o->shortcut(0xff53);
o->labeltype(FL_SYMBOL_LABEL);
o->labelcolor(2); o->labelcolor(2);
o->callback((Fl_Callback*)cb_forward_); o->callback((Fl_Callback*)cb_forward_);
} }

11
src/Fl_HelpDialog.fl

@ -14,8 +14,8 @@ class Fl_HelpDialog {open
Function {Fl_HelpDialog()} {open Function {Fl_HelpDialog()} {open
} { } {
Fl_Window window_ { Fl_Window window_ {
label {Help Dialog} open label {Help Dialog} open selected
private xywh {470 402 530 385} resizable private xywh {470 380 530 385} type Double resizable
code0 {\#include <string.h>} visible code0 {\#include <string.h>} visible
} { } {
Fl_Group view_ { Fl_Group view_ {
@ -72,7 +72,7 @@ if (strcmp(view_->filename(), file_[index_]) != 0)
view_->load(file_[index_]); view_->load(file_[index_]);
view_->topline(line_[index_]);} view_->topline(line_[index_]);}
private xywh {365 350 25 25} shortcut 0xff51 labeltype SYMBOL_LABEL labelcolor 2 private xywh {365 350 25 25} shortcut 0xff51 labelcolor 2
} }
Fl_Button forward_ { Fl_Button forward_ {
label {@->} label {@->}
@ -88,7 +88,7 @@ if (strcmp(view_->filename(), file_[index_]) != 0)
view_->load(file_[index_]); view_->load(file_[index_]);
view_->topline(line_[index_]);} view_->topline(line_[index_]);}
private xywh {395 350 25 25} shortcut 0xff53 labeltype SYMBOL_LABEL labelcolor 2 private xywh {395 350 25 25} shortcut 0xff53 labelcolor 2
} }
Fl_Button smaller_ { Fl_Button smaller_ {
label F label F
@ -117,8 +117,7 @@ forward_->deactivate();
index_ = -1; index_ = -1;
max_ = 0;} {} max_ = 0;} {}
} }
Function {~Fl_HelpDialog()} {selected Function {~Fl_HelpDialog()} {} {
} {
code {delete window_;} {} code {delete window_;} {}
} }
Function {h()} {return_type int Function {h()} {return_type int

568
src/Fl_HelpView.cxx

@ -1,5 +1,5 @@
// //
// "$Id: Fl_HelpView.cxx,v 1.1.2.4 2001/08/05 23:58:54 easysw Exp $" // "$Id: Fl_HelpView.cxx,v 1.1.2.5 2001/09/10 03:09:43 easysw Exp $"
// //
// Fl_HelpView widget routines. // Fl_HelpView widget routines.
// //
@ -35,6 +35,7 @@
// Fl_HelpView::draw() - Draw the Fl_HelpView widget. // Fl_HelpView::draw() - Draw the Fl_HelpView widget.
// Fl_HelpView::find_image() - Find an image by name // Fl_HelpView::find_image() - Find an image by name
// Fl_HelpView::format() - Format the help text. // Fl_HelpView::format() - Format the help text.
// Fl_HelpView::format_table() - Format a table...
// Fl_HelpView::get_align() - Get an alignment attribute. // Fl_HelpView::get_align() - Get an alignment attribute.
// Fl_HelpView::get_attr() - Get an attribute value from the string. // Fl_HelpView::get_attr() - Get an attribute value from the string.
// Fl_HelpView::get_color() - Get an alignment attribute. // Fl_HelpView::get_color() - Get an alignment attribute.
@ -49,6 +50,7 @@
// Fl_HelpView::topline() - Set the top line to the named target. // Fl_HelpView::topline() - Set the top line to the named target.
// Fl_HelpView::topline() - Set the top line by number. // Fl_HelpView::topline() - Set the top line by number.
// Fl_HelpView::value() - Set the help text directly. // Fl_HelpView::value() - Set the help text directly.
// Fl_HelpView::compare_blocks() - Compare two blocks.
// gif_read_cmap() - Read the colormap from a GIF file... // gif_read_cmap() - Read the colormap from a GIF file...
// gif_get_block() - Read a GIF data block... // gif_get_block() - Read a GIF data block...
// gif_get_code() - Get a LZW code from the file... // gif_get_code() - Get a LZW code from the file...
@ -99,6 +101,9 @@ extern "C"
#endif // HAVE_LIBJPEG #endif // HAVE_LIBJPEG
} }
#define MAX_COLUMNS 200
// //
// Typedef the C API sort function type the only way I know how... // Typedef the C API sort function type the only way I know how...
// //
@ -448,6 +453,9 @@ Fl_HelpView::add_block(const char *s, // I - Pointer to start of block text
Fl_HelpBlock *temp; // New block Fl_HelpBlock *temp; // New block
// printf("add_block(s = %p, xx = %d, yy = %d, ww = %d, hh = %d, border = %d)\n",
// s, xx, yy, ww, hh, border);
if (nblocks_ >= ablocks_) if (nblocks_ >= ablocks_)
{ {
ablocks_ += 16; ablocks_ += 16;
@ -511,11 +519,16 @@ Fl_HelpView::add_image(const char *name, // I - Path of image
if (aimage_ == nimage_) if (aimage_ == nimage_)
{ {
aimage_ += 16; aimage_ += 16;
if (aimage_ == 16)
image_ = (Fl_HelpImage *)malloc(sizeof(Fl_HelpImage) * aimage_);
else
image_ = (Fl_HelpImage *)realloc(image_, sizeof(Fl_HelpImage) * aimage_); image_ = (Fl_HelpImage *)realloc(image_, sizeof(Fl_HelpImage) * aimage_);
} }
img = image_ + nimage_; img = image_ + nimage_;
img->name = strdup(name); img->name = strdup(name);
img->copy = 0;
if (!orig) if (!orig)
{ {
@ -614,11 +627,15 @@ Fl_HelpView::add_image(const char *name, // I - Path of image
img->name = strdup(name); img->name = strdup(name);
} }
// printf("orig->data = %p, width = %d, height = %d\n", orig->data,
// orig->w, orig->h);
// Copy image data from original image... // Copy image data from original image...
img->data = orig->data; img->data = orig->data;
img->w = orig->w; img->w = orig->w;
img->h = orig->h; img->h = orig->h;
img->d = orig->d; img->d = orig->d;
img->copy = 1;
// Figure out the size of the image... // Figure out the size of the image...
if (wattr[0]) if (wattr[0])
@ -674,6 +691,8 @@ Fl_HelpView::add_image(const char *name, // I - Path of image
if ((scaled = (unsigned char *)malloc(width * height * img->d)) != NULL) if ((scaled = (unsigned char *)malloc(width * height * img->d)) != NULL)
{ {
img->copy = 0;
// Scale the image... // Scale the image...
for (dy = height, sy = 0, yerr = height / 2, dptr = scaled; dy > 0; dy --) for (dy = height, sy = 0, yerr = height / 2, dptr = scaled; dy > 0; dy --)
{ {
@ -729,6 +748,9 @@ Fl_HelpView::add_image(const char *name, // I - Path of image
nimage_ ++; nimage_ ++;
// printf("img->data = %p, width = %d, height = %d\n", img->data,
// img->w, img->h);
return (img); return (img);
} }
@ -1173,8 +1195,11 @@ Fl_HelpView::draw()
get_attr(attrs, "HEIGHT", hattr, sizeof(hattr)); get_attr(attrs, "HEIGHT", hattr, sizeof(hattr));
if (get_attr(attrs, "SRC", attr, sizeof(attr))) if (get_attr(attrs, "SRC", attr, sizeof(attr)))
if ((img = find_image(attr, wattr, hattr)) != NULL && !img->image) if ((img = add_image(attr, wattr, hattr)) != NULL)
{
if (!img->image)
img = (Fl_HelpImage *)0; img = (Fl_HelpImage *)0;
}
if (img) if (img)
{ {
@ -1380,7 +1405,8 @@ Fl_HelpView::format()
needspace; // Do we need whitespace? needspace; // Do we need whitespace?
int table_width; // Width of table int table_width; // Width of table
int column, // Current table column number int column, // Current table column number
columns[200]; // Column widths columns[MAX_COLUMNS];
// Column widths
// Reset state variables... // Reset state variables...
@ -1445,6 +1471,9 @@ Fl_HelpView::format()
if (needspace && xx > block->x) if (needspace && xx > block->x)
ww += (int)fl_width(' '); ww += (int)fl_width(' ');
// printf("line = %d, xx = %d, ww = %d, block->x = %d, block->w = %d\n",
// line, xx, ww, block->x, block->w);
if ((xx + ww) > block->w) if ((xx + ww) > block->w)
{ {
line = do_align(block, line, xx, newalign, links); line = do_align(block, line, xx, newalign, links);
@ -1511,6 +1540,8 @@ Fl_HelpView::format()
*s = '\0'; *s = '\0';
s = buf; s = buf;
// puts(buf);
attrs = ptr; attrs = ptr;
while (*ptr && *ptr != '>') while (*ptr && *ptr != '>')
ptr ++; ptr ++;
@ -1584,18 +1615,12 @@ Fl_HelpView::format()
xx = block->x; xx = block->x;
block->h += hh; block->h += hh;
if (!block->h && nblocks_ > 1)
{
nblocks_ --;
block --;
}
if (strcasecmp(buf, "UL") == 0 || if (strcasecmp(buf, "UL") == 0 ||
strcasecmp(buf, "OL") == 0 || strcasecmp(buf, "OL") == 0 ||
strcasecmp(buf, "DL") == 0) strcasecmp(buf, "DL") == 0)
{ {
xx += 4 * size;
block->h += size + 2; block->h += size + 2;
xx += 4 * size;
} }
else if (strcasecmp(buf, "TABLE") == 0) else if (strcasecmp(buf, "TABLE") == 0)
{ {
@ -1606,18 +1631,7 @@ Fl_HelpView::format()
block->h += size + 2; block->h += size + 2;
if (get_attr(attrs, "WIDTH", attr, sizeof(attr))) format_table(&table_width, columns, start);
{
if (attr[strlen(attr) - 1] == '%')
table_width = atoi(attr) * w() / 100;
else
table_width = atoi(attr);
}
else
table_width = w();
for (column = 0; column < 200; column ++)
columns[column] = table_width / 3;
column = 0; column = 0;
} }
@ -1652,8 +1666,6 @@ Fl_HelpView::format()
if ((tolower(buf[0]) == 'h' && isdigit(buf[1])) || if ((tolower(buf[0]) == 'h' && isdigit(buf[1])) ||
strcasecmp(buf, "DD") == 0 || strcasecmp(buf, "DD") == 0 ||
strcasecmp(buf, "DT") == 0 || strcasecmp(buf, "DT") == 0 ||
strcasecmp(buf, "UL") == 0 ||
strcasecmp(buf, "OL") == 0 ||
strcasecmp(buf, "P") == 0) strcasecmp(buf, "P") == 0)
yy += size + 2; yy += size + 2;
else if (strcasecmp(buf, "HR") == 0) else if (strcasecmp(buf, "HR") == 0)
@ -1663,7 +1675,7 @@ Fl_HelpView::format()
} }
if (row) if (row)
block = add_block(start, block->x, yy, block->w, 0); block = add_block(start, xx, yy, block->w, 0);
else else
block = add_block(start, xx, yy, w() - 24, 0); block = add_block(start, xx, yy, w() - 24, 0);
@ -1710,7 +1722,7 @@ Fl_HelpView::format()
else if (strcasecmp(buf, "/CENTER") == 0) else if (strcasecmp(buf, "/CENTER") == 0)
align = LEFT; align = LEFT;
initfont(font, size); popfont(font, size);
while (isspace(*ptr)) while (isspace(*ptr))
ptr ++; ptr ++;
@ -1721,7 +1733,11 @@ Fl_HelpView::format()
if (tolower(buf[2]) == 'l') if (tolower(buf[2]) == 'l')
yy += size + 2; yy += size + 2;
if (row)
block = add_block(ptr, xx, yy, block->w, 0);
else
block = add_block(ptr, xx, yy, w() - 24, 0); block = add_block(ptr, xx, yy, w() - 24, 0);
needspace = 0; needspace = 0;
hh = 0; hh = 0;
line = 0; line = 0;
@ -1764,12 +1780,6 @@ Fl_HelpView::format()
xx = blocks_[row].x; xx = blocks_[row].x;
if (block->end == block->start && nblocks_ > 1)
{
nblocks_ --;
block --;
}
yy = blocks_[row].y + blocks_[row].h; yy = blocks_[row].y + blocks_[row].h;
for (cell = blocks_ + row + 1; cell <= block; cell ++) for (cell = blocks_ + row + 1; cell <= block; cell ++)
@ -1790,6 +1800,9 @@ Fl_HelpView::format()
else if ((strcasecmp(buf, "TD") == 0 || else if ((strcasecmp(buf, "TD") == 0 ||
strcasecmp(buf, "TH") == 0) && row) strcasecmp(buf, "TH") == 0) && row)
{ {
int colspan; // COLSPAN attribute
line = do_align(block, line, xx, newalign, links); line = do_align(block, line, xx, newalign, links);
block->end = start; block->end = start;
block->h += hh; block->h += hh;
@ -1801,10 +1814,17 @@ Fl_HelpView::format()
size = textsize_; size = textsize_;
if (column == 0) xx = blocks_[row].x + size + 3;
xx = block->x + size + 3; for (i = 0; i < column; i ++)
xx += columns[i] + 6;
if (get_attr(attrs, "COLSPAN", attr, sizeof(attr)) != NULL)
colspan = atoi(attr);
else else
xx = block->w + 6; colspan = 1;
for (i = 0, ww = 0; i < colspan; i ++)
ww += columns[column + i];
if (block->end == block->start && nblocks_ > 1) if (block->end == block->start && nblocks_ > 1)
{ {
@ -1814,18 +1834,6 @@ Fl_HelpView::format()
pushfont(font, size); pushfont(font, size);
if (get_attr(attrs, "WIDTH", attr, sizeof(attr)) != NULL)
{
ww = atoi(attr);
if (attr[strlen(attr) - 1] == '%')
ww = ww * w() / 100;
columns[column] = ww;
}
else
ww = columns[column];
yy = blocks_[row].y; yy = blocks_[row].y;
hh = 0; hh = 0;
block = add_block(start, xx, yy, xx + ww, 0, border); block = add_block(start, xx, yy, xx + ww, 0, border);
@ -1979,6 +1987,9 @@ Fl_HelpView::format()
*s = '\0'; *s = '\0';
ww = (int)fl_width(buf); ww = (int)fl_width(buf);
// printf("line = %d, xx = %d, ww = %d, block->x = %d, block->w = %d\n",
// line, xx, ww, block->x, block->w);
if (needspace && xx > block->x) if (needspace && xx > block->x)
ww += (int)fl_width(' '); ww += (int)fl_width(' ');
@ -2008,6 +2019,10 @@ Fl_HelpView::format()
qsort(targets_, ntargets_, sizeof(Fl_HelpTarget), qsort(targets_, ntargets_, sizeof(Fl_HelpTarget),
(compare_func_t)compare_targets); (compare_func_t)compare_targets);
if (nblocks_ > 1)
qsort(blocks_, nblocks_, sizeof(Fl_HelpBlock),
(compare_func_t)compare_blocks);
if (size_ < (h() - 8)) if (size_ < (h() - 8))
scrollbar_.hide(); scrollbar_.hide();
else else
@ -2017,6 +2032,435 @@ Fl_HelpView::format()
} }
//
// 'Fl_HelpView::format_table()' - Format a table...
//
void
Fl_HelpView::format_table(int *table_width, // O - Total table width
int *columns, // O - Column widths
const char *table) // I - Pointer to start of table
{
int column, // Current column
num_columns, // Number of columns
colspan, // COLSPAN attribute
width, // Current width
temp_width, // Temporary width
max_width, // Maximum width
incell, // In a table cell?
pre, // <PRE> text?
needspace; // Need whitespace?
char *s, // Pointer into buffer
buf[1024], // Text buffer
attr[1024], // Other attribute
wattr[1024], // WIDTH attribute
hattr[1024]; // HEIGHT attribute
const char *ptr, // Pointer into table
*attrs, // Pointer to attributes
*start; // Start of element
int minwidths[MAX_COLUMNS]; // Minimum widths for each column
unsigned char font, size; // Current font and size
// Clear widths...
*table_width = 0;
for (column = 0; column < MAX_COLUMNS; column ++)
{
columns[column] = 0;
minwidths[column] = 0;
}
num_columns = 0;
colspan = 0;
max_width = 0;
pre = 0;
// Scan the table...
for (ptr = table, column = -1, width = 0, s = buf, incell = 0; *ptr;)
{
if ((*ptr == '<' || isspace(*ptr)) && s > buf && incell)
{
// Check width...
if (needspace)
{
*s++ = ' ';
needspace = 0;
}
*s = '\0';
temp_width = (int)fl_width(buf);
s = buf;
if (temp_width > minwidths[column])
minwidths[column] = temp_width;
width += temp_width;
if (width > max_width)
max_width = width;
}
if (*ptr == '<')
{
start = ptr;
for (s = buf, ptr ++; *ptr && *ptr != '>' && !isspace(*ptr);)
if (s < (buf + sizeof(buf) - 1))
*s++ = *ptr++;
else
ptr ++;
*s = '\0';
s = buf;
attrs = ptr;
while (*ptr && *ptr != '>')
ptr ++;
if (*ptr == '>')
ptr ++;
if (strcasecmp(buf, "BR") == 0 ||
strcasecmp(buf, "HR") == 0)
{
width = 0;
needspace = 0;
}
else if (strcasecmp(buf, "TABLE") == 0 && start > table)
break;
else if (strcasecmp(buf, "CENTER") == 0 ||
strcasecmp(buf, "P") == 0 ||
strcasecmp(buf, "H1") == 0 ||
strcasecmp(buf, "H2") == 0 ||
strcasecmp(buf, "H3") == 0 ||
strcasecmp(buf, "H4") == 0 ||
strcasecmp(buf, "H5") == 0 ||
strcasecmp(buf, "H6") == 0 ||
strcasecmp(buf, "UL") == 0 ||
strcasecmp(buf, "OL") == 0 ||
strcasecmp(buf, "DL") == 0 ||
strcasecmp(buf, "LI") == 0 ||
strcasecmp(buf, "DD") == 0 ||
strcasecmp(buf, "DT") == 0 ||
strcasecmp(buf, "PRE") == 0)
{
width = 0;
needspace = 0;
if (tolower(buf[0]) == 'h' && isdigit(buf[1]))
{
font = FL_HELVETICA_BOLD;
size = textsize_ + '7' - buf[1];
}
else if (strcasecmp(buf, "DT") == 0)
{
font = textfont_ | FL_ITALIC;
size = textsize_;
}
else if (strcasecmp(buf, "PRE") == 0)
{
font = FL_COURIER;
size = textsize_;
pre = 1;
}
else if (strcasecmp(buf, "LI") == 0)
{
width += 4 * size;
font = textfont_;
size = textsize_;
}
else
{
font = textfont_;
size = textsize_;
}
pushfont(font, size);
}
else if (strcasecmp(buf, "/CENTER") == 0 ||
strcasecmp(buf, "/P") == 0 ||
strcasecmp(buf, "/H1") == 0 ||
strcasecmp(buf, "/H2") == 0 ||
strcasecmp(buf, "/H3") == 0 ||
strcasecmp(buf, "/H4") == 0 ||
strcasecmp(buf, "/H5") == 0 ||
strcasecmp(buf, "/H6") == 0 ||
strcasecmp(buf, "/PRE") == 0 ||
strcasecmp(buf, "/UL") == 0 ||
strcasecmp(buf, "/OL") == 0 ||
strcasecmp(buf, "/DL") == 0)
{
width = 0;
needspace = 0;
popfont(font, size);
}
else if (strcasecmp(buf, "TR") == 0 || strcasecmp(buf, "/TR") == 0 ||
strcasecmp(buf, "/TABLE") == 0)
{
// printf("%s column = %d, colspan = %d, num_columns = %d\n",
// buf, column, colspan, num_columns);
if (column >= 0)
{
// This is a hack to support COLSPAN...
max_width /= colspan;
while (colspan > 0)
{
if (max_width > columns[column])
columns[column] = max_width;
column ++;
colspan --;
}
}
if (strcasecmp(buf, "/TABLE") == 0)
break;
needspace = 0;
column = -1;
width = 0;
max_width = 0;
incell = 0;
}
else if (strcasecmp(buf, "TD") == 0 ||
strcasecmp(buf, "TH") == 0)
{
// printf("BEFORE column = %d, colspan = %d, num_columns = %d\n",
// column, colspan, num_columns);
if (column >= 0)
{
// This is a hack to support COLSPAN...
max_width /= colspan;
while (colspan > 0)
{
if (max_width > columns[column])
columns[column] = max_width;
column ++;
colspan --;
}
}
else
column ++;
if (get_attr(attrs, "COLSPAN", attr, sizeof(attr)) != NULL)
colspan = atoi(attr);
else
colspan = 1;
// printf("AFTER column = %d, colspan = %d, num_columns = %d\n",
// column, colspan, num_columns);
if ((column + colspan) >= num_columns)
num_columns = column + colspan;
needspace = 0;
width = 0;
incell = 1;
if (strcasecmp(buf, "TH") == 0)
font = textfont_ | FL_BOLD;
else
font = textfont_;
size = textsize_;
pushfont(font, size);
if (get_attr(attrs, "WIDTH", attr, sizeof(attr)) != NULL)
{
max_width = atoi(attr);
if (attr[strlen(attr) - 1] == '%')
max_width = max_width * w() / 100;
}
else
max_width = 0;
// printf("max_width = %d\n", max_width);
}
else if (strcasecmp(buf, "/TD") == 0 ||
strcasecmp(buf, "/TH") == 0)
{
incell = 0;
popfont(font, size);
}
else if (strcasecmp(buf, "B") == 0)
pushfont(font |= FL_BOLD, size);
else if (strcasecmp(buf, "I") == 0)
pushfont(font |= FL_ITALIC, size);
else if (strcasecmp(buf, "CODE") == 0)
pushfont(font = FL_COURIER, size);
else if (strcasecmp(buf, "KBD") == 0)
pushfont(font = FL_COURIER_BOLD, size);
else if (strcasecmp(buf, "VAR") == 0)
pushfont(font = FL_COURIER_ITALIC, size);
else if (strcasecmp(buf, "/B") == 0 ||
strcasecmp(buf, "/I") == 0 ||
strcasecmp(buf, "/CODE") == 0 ||
strcasecmp(buf, "/KBD") == 0 ||
strcasecmp(buf, "/VAR") == 0)
popfont(font, size);
else if (strcasecmp(buf, "IMG") == 0 && incell)
{
Fl_HelpImage *img = (Fl_HelpImage *)0;
get_attr(attrs, "WIDTH", wattr, sizeof(wattr));
get_attr(attrs, "HEIGHT", hattr, sizeof(hattr));
if (get_attr(attrs, "SRC", attr, sizeof(attr)))
if ((img = add_image(attr, wattr, hattr)) != (Fl_HelpImage *)0 &&
img->image == NULL)
img = (Fl_HelpImage *)0;
if (img)
temp_width = img->w;
else
temp_width = 16;
if (temp_width > minwidths[column])
minwidths[column] = temp_width;
width += temp_width;
if (needspace)
width += (int)fl_width(' ');
if (width > max_width)
max_width = width;
needspace = 0;
}
}
else if (*ptr == '\n' && pre)
{
width = 0;
needspace = 0;
ptr ++;
}
else if (isspace(*ptr))
{
needspace = 1;
ptr ++;
}
else if (*ptr == '&' && s < (buf + sizeof(buf) - 1))
{
ptr ++;
if (strncasecmp(ptr, "amp;", 4) == 0)
{
*s++ = '&';
ptr += 4;
}
else if (strncasecmp(ptr, "lt;", 3) == 0)
{
*s++ = '<';
ptr += 3;
}
else if (strncasecmp(ptr, "gt;", 3) == 0)
{
*s++ = '>';
ptr += 3;
}
else if (strncasecmp(ptr, "nbsp;", 5) == 0)
{
*s++ = '\240';
ptr += 5;
}
else if (strncasecmp(ptr, "copy;", 5) == 0)
{
*s++ = '\251';
ptr += 5;
}
else if (strncasecmp(ptr, "reg;", 4) == 0)
{
*s++ = '\256';
ptr += 4;
}
else if (strncasecmp(ptr, "quot;", 5) == 0)
{
*s++ = '\"';
ptr += 5;
}
}
else
{
if (s < (buf + sizeof(buf) - 1))
*s++ = *ptr++;
else
ptr ++;
}
}
// Now that we have scanned the entire table, adjust the table and
// cell widths to fit on the screen...
if (get_attr(table + 6, "WIDTH", attr, sizeof(attr)))
{
if (attr[strlen(attr) - 1] == '%')
*table_width = atoi(attr) * w() / 100;
else
*table_width = atoi(attr);
}
else
*table_width = 0;
// printf("num_columns = %d, table_width = %d\n", num_columns, *table_width);
if (num_columns == 0)
return;
// Add up the widths...
for (column = 0, width = 0; column < num_columns; column ++)
width += columns[column];
// printf("width = %d, w() = %d\n", width, w());
// for (column = 0; column < num_columns; column ++)
// printf(" columns[%d] = %d, minwidths[%d] = %d\n", column, columns[column],
// column, minwidths[column]);
// Adjust the width if needed...
int scale_width = *table_width;
if (scale_width == 0 && width > w())
scale_width = width;
if (width > scale_width)
{
*table_width = 0;
for (column = 0; column < num_columns; column ++)
{
if (width > 0)
{
temp_width = scale_width * columns[column] / width;
if (temp_width < minwidths[column])
temp_width = minwidths[column];
}
else
temp_width = minwidths[column];
width -= columns[column];
scale_width -= temp_width;
columns[column] = temp_width;
(*table_width) += temp_width;
}
}
else if (*table_width == 0)
*table_width = width;
// printf("FINAL table_width = %d\n", *table_width);
// for (column = 0; column < num_columns; column ++)
// printf(" columns[%d] = %d\n", column, columns[column]);
}
// //
// 'Fl_HelpView::get_align()' - Get an alignment attribute. // 'Fl_HelpView::get_align()' - Get an alignment attribute.
// //
@ -2198,24 +2642,15 @@ Fl_HelpView::handle(int event) // I - Event to handle
switch (event) switch (event)
{ {
case FL_PUSH : case FL_PUSH :
if (Fl_Group::handle(event))
return (1);
case FL_MOVE : case FL_MOVE :
xx = Fl::event_x() - x(); xx = Fl::event_x() - x();
yy = Fl::event_y() - y() + topline_; yy = Fl::event_y() - y() + topline_;
if (!scrollbar_.visible() || xx < (w() - 20))
break; break;
case FL_MOUSEWHEEL :
i = topline() + Fl::e_dy * textsize_ * 3;
if (i < 0)
i = 0;
else if (i > (size_ - h()))
i = size_ - h();
topline(i);
return (1);
default : default :
// Use the Fl_Group handler...
return (Fl_Group::handle(event)); return (Fl_Group::handle(event));
} }
@ -2370,6 +2805,7 @@ Fl_HelpView::~Fl_HelpView()
for (i = nimage_, img = image_; i > 0; i --, img ++) for (i = nimage_, img = image_; i > 0; i --, img ++)
{ {
delete img->image; delete img->image;
if (!img->copy)
free(img->data); free(img->data);
free(img->name); free(img->name);
} }
@ -2775,6 +3211,18 @@ Fl_HelpView::value(const char *v) // I - Text to view
} }
//
// 'Fl_HelpView::compare_blocks()' - Compare two blocks.
//
int // O - Result of comparison
Fl_HelpView::compare_blocks(const void *a, // I - First block
const void *b) // I - Second block
{
return (((Fl_HelpBlock *)a)->y - ((Fl_HelpBlock *)b)->y);
}
// //
// 'gif_read_cmap()' - Read the colormap from a GIF file... // 'gif_read_cmap()' - Read the colormap from a GIF file...
// //
@ -3132,5 +3580,5 @@ scrollbar_callback(Fl_Widget *s, void *)
// //
// End of "$Id: Fl_HelpView.cxx,v 1.1.2.4 2001/08/05 23:58:54 easysw Exp $". // End of "$Id: Fl_HelpView.cxx,v 1.1.2.5 2001/09/10 03:09:43 easysw Exp $".
// //

2
src/makedepend

@ -288,7 +288,7 @@ fl_font.o: ../config.h ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_font.o: ../FL/fl_draw.H ../FL/x.H ../FL/Fl_Window.H Fl_Font.H fl_font.o: ../FL/fl_draw.H ../FL/x.H ../FL/Fl_Window.H Fl_Font.H
fl_labeltype.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H fl_labeltype.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_labeltype.o: ../FL/Fl_Widget.H ../FL/Fl_Group.H ../FL/fl_draw.H fl_labeltype.o: ../FL/Fl_Widget.H ../FL/Fl_Group.H ../FL/fl_draw.H
fl_labeltype.o: ../FL/Fl_Input_.H ../FL/Fl_Widget.H fl_labeltype.o: ../FL/Fl_Image.H ../FL/Fl_Input_.H ../FL/Fl_Widget.H
fl_line_style.o: ../FL/fl_draw.H ../FL/Enumerations.H ../FL/Fl_Export.H fl_line_style.o: ../FL/fl_draw.H ../FL/Enumerations.H ../FL/Fl_Export.H
fl_line_style.o: ../FL/x.H ../FL/Fl_Window.H fl_line_style.o: ../FL/x.H ../FL/Fl_Window.H
fl_oval_box.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H fl_oval_box.o: ../FL/Fl.H ../FL/Enumerations.H ../FL/Fl_Export.H

Loading…
Cancel
Save