mirror of
https://github.com/fltk/fltk.git
synced 2026-05-22 23:37:02 +08:00
Adding embedded documentation to Fluid if installed odcs are not found. Falls back to the internet if that does not exist either. Also, adds JPEG and PNG images to the Shared Image list if they were loaded from memory - see example use in fluid.cxx which loads and embedded html document containing an embedded PNG image.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8306 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -45,8 +45,8 @@
|
||||
//
|
||||
|
||||
/** The Fl_File_Browser widget displays a list of filenames, optionally with file-specific icons. */
|
||||
class FL_EXPORT Fl_File_Browser : public Fl_Browser
|
||||
{
|
||||
class FL_EXPORT Fl_File_Browser : public Fl_Browser {
|
||||
|
||||
int filetype_;
|
||||
const char *directory_;
|
||||
uchar iconsize_;
|
||||
|
||||
+2
-2
@@ -53,8 +53,8 @@
|
||||
The Fl_File_Icon class manages icon images that can be used
|
||||
as labels in other widgets and as icons in the FileBrowser widget.
|
||||
*/
|
||||
class FL_EXPORT Fl_File_Icon //// Icon data
|
||||
{
|
||||
class FL_EXPORT Fl_File_Icon { //// Icon data
|
||||
|
||||
static Fl_File_Icon *first_; // Pointer to first icon/filetype
|
||||
Fl_File_Icon *next_; // Pointer to next icon/filetype
|
||||
const char *pattern_; // Pattern string
|
||||
|
||||
+2
-2
@@ -51,8 +51,8 @@
|
||||
One resulting side effect is that you should call clear_changed() early in your callback
|
||||
to avoid reentrant calls if you plan to show another window or dialog box in the callback.
|
||||
*/
|
||||
class FL_EXPORT Fl_File_Input : public Fl_Input
|
||||
{
|
||||
class FL_EXPORT Fl_File_Input : public Fl_Input {
|
||||
|
||||
Fl_Color errorcolor_;
|
||||
char ok_entry_;
|
||||
uchar down_box_;
|
||||
|
||||
+5
-8
@@ -57,8 +57,7 @@ typedef const char *(Fl_Help_Func)(Fl_Widget *, const char *);
|
||||
// Fl_Help_Block structure...
|
||||
//
|
||||
|
||||
struct Fl_Help_Block
|
||||
{
|
||||
struct Fl_Help_Block {
|
||||
const char *start, // Start of text
|
||||
*end; // End of text
|
||||
uchar border; // Draw border?
|
||||
@@ -74,8 +73,7 @@ struct Fl_Help_Block
|
||||
// Fl_Help_Link structure...
|
||||
//
|
||||
/** Definition of a link for the html viewer. */
|
||||
struct Fl_Help_Link
|
||||
{
|
||||
struct Fl_Help_Link {
|
||||
char filename[192], ///< Reference filename
|
||||
name[32]; ///< Link target (blank if none)
|
||||
int x, ///< X offset of link text
|
||||
@@ -138,8 +136,7 @@ protected:
|
||||
|
||||
/** Fl_Help_Target structure */
|
||||
|
||||
struct Fl_Help_Target
|
||||
{
|
||||
struct Fl_Help_Target {
|
||||
char name[32]; ///< Target name
|
||||
int y; ///< Y offset of target
|
||||
};
|
||||
@@ -209,8 +206,8 @@ struct Fl_Help_Target
|
||||
- yen Yuml yuml
|
||||
|
||||
*/
|
||||
class FL_EXPORT Fl_Help_View : public Fl_Group // Help viewer widget
|
||||
{
|
||||
class FL_EXPORT Fl_Help_View : public Fl_Group { // Help viewer widget
|
||||
|
||||
enum { RIGHT = -1, CENTER, LEFT }; ///< Alignments
|
||||
|
||||
char title_[1024]; ///< Title string
|
||||
|
||||
+2
-4
@@ -67,8 +67,7 @@
|
||||
}
|
||||
\endcode
|
||||
*/
|
||||
class FL_EXPORT Fl_Plugin
|
||||
{
|
||||
class FL_EXPORT Fl_Plugin {
|
||||
Fl_Preferences::ID id;
|
||||
public:
|
||||
Fl_Plugin(const char *klass, const char *name);
|
||||
@@ -80,8 +79,7 @@ public:
|
||||
\brief Fl_Plugin_Manager manages link-time and run-time plugin binaries.
|
||||
\see Fl_Plugin
|
||||
*/
|
||||
class FL_EXPORT Fl_Plugin_Manager : public Fl_Preferences
|
||||
{
|
||||
class FL_EXPORT Fl_Plugin_Manager : public Fl_Preferences {
|
||||
public:
|
||||
Fl_Plugin_Manager(const char *klass);
|
||||
~Fl_Plugin_Manager();
|
||||
|
||||
+2
-2
@@ -44,8 +44,8 @@
|
||||
/**
|
||||
Displays a progress bar for the user.
|
||||
*/
|
||||
class FL_EXPORT Fl_Progress : public Fl_Widget
|
||||
{
|
||||
class FL_EXPORT Fl_Progress : public Fl_Widget {
|
||||
|
||||
float value_,
|
||||
minimum_,
|
||||
maximum_;
|
||||
|
||||
@@ -47,7 +47,11 @@ typedef Fl_Image *(*Fl_Shared_Handler)(const char *name, uchar *header,
|
||||
function to support standard image formats such as BMP, GIF, JPEG, and PNG.
|
||||
*/
|
||||
class FL_EXPORT Fl_Shared_Image : public Fl_Image {
|
||||
protected:
|
||||
|
||||
friend class Fl_JPEG_Image;
|
||||
friend class Fl_PNG_Image;
|
||||
|
||||
protected:
|
||||
|
||||
static Fl_Shared_Image **images_; // Shared images
|
||||
static int num_images_; // Number of shared images
|
||||
|
||||
+2
-2
@@ -48,8 +48,8 @@
|
||||
widget and repeat buttons. The user can either type into the
|
||||
input area or use the buttons to change the value.
|
||||
*/
|
||||
class FL_EXPORT Fl_Spinner : public Fl_Group
|
||||
{
|
||||
class FL_EXPORT Fl_Spinner : public Fl_Group {
|
||||
|
||||
double value_; // Current value
|
||||
double minimum_; // Minimum value
|
||||
double maximum_; // Maximum value
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
in the widget is managed by the Fl_Text_Buffer class. A single Text Buffer
|
||||
can be displayed by multiple Text Displays.
|
||||
*/
|
||||
class FL_EXPORT Fl_Text_Display: public Fl_Group
|
||||
{
|
||||
class FL_EXPORT Fl_Text_Display: public Fl_Group {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -47,8 +47,8 @@
|
||||
<P>As with Fl_Tabs, wizard panes are composed of child (usually
|
||||
Fl_Group) widgets. Navigation buttons must be added separately.
|
||||
*/
|
||||
class FL_EXPORT Fl_Wizard : public Fl_Group
|
||||
{
|
||||
class FL_EXPORT Fl_Wizard : public Fl_Group {
|
||||
|
||||
Fl_Widget *value_;
|
||||
|
||||
void draw();
|
||||
|
||||
@@ -109,8 +109,8 @@ extern void *fl_default_cursor;
|
||||
|
||||
// This object contains all mac-specific stuff about a window:
|
||||
// WARNING: this object is highly subject to change!
|
||||
class Fl_X
|
||||
{
|
||||
class Fl_X {
|
||||
|
||||
public:
|
||||
Window xid; // pointer to the Cocoa window object (FLWindow*)
|
||||
Fl_Offscreen other_xid; // pointer for offscreen bitmaps (overlay window)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,10 +34,9 @@ comment {//
|
||||
decl {void show_help(const char *name);} {public local
|
||||
}
|
||||
|
||||
Function {make_about_panel()} {open
|
||||
} {
|
||||
Function {make_about_panel()} {} {
|
||||
Fl_Window about_panel {
|
||||
label {About FLUID} open selected
|
||||
label {About FLUID} open
|
||||
xywh {419 216 345 180} type Double color 50 selection_color 47 hotspot non_modal visible
|
||||
} {
|
||||
Fl_Box {} {
|
||||
@@ -67,6 +66,10 @@ Bill Spitzak and others}
|
||||
}
|
||||
}
|
||||
|
||||
data fluid_org_png {
|
||||
comment {Embedded image for internal fluid.html web page.} public local filename {../documentation/src/fluid-org.png}
|
||||
}
|
||||
|
||||
comment {
|
||||
//
|
||||
// End of "$Id$".
|
||||
|
||||
@@ -37,6 +37,7 @@ extern Fl_Double_Window *about_panel;
|
||||
#include <FL/Fl_Button.H>
|
||||
#include <FL/Fl_Return_Button.H>
|
||||
Fl_Double_Window* make_about_panel();
|
||||
extern unsigned char fluid_org_png[12690];
|
||||
#endif
|
||||
|
||||
//
|
||||
|
||||
+52
-2
@@ -38,6 +38,7 @@
|
||||
#include <FL/fl_ask.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/Fl_File_Chooser.H>
|
||||
#include <FL/Fl_PNG_Image.H>
|
||||
#include <FL/fl_message.H>
|
||||
#include <FL/filename.H>
|
||||
#include <stdio.h>
|
||||
@@ -866,7 +867,56 @@ void show_help(const char *name) {
|
||||
}
|
||||
snprintf(helpname, sizeof(helpname), "%s/%s", docdir, name);
|
||||
|
||||
help_dialog->load(helpname);
|
||||
// make sure that we can read the file
|
||||
FILE *f = fopen(helpname, "rb");
|
||||
if (f) {
|
||||
fclose(f);
|
||||
help_dialog->load(helpname);
|
||||
} else {
|
||||
// if we can not read the file, we display the canned version instead
|
||||
// or ask the native browser to open the page on www.fltk.org
|
||||
if (strcmp(name, "fluid.html")==0) {
|
||||
if (!Fl_Shared_Image::find("embedded:/fluid-org.png"))
|
||||
new Fl_PNG_Image("embedded:/fluid-org.png", fluid_org_png, sizeof(fluid_org_png));
|
||||
help_dialog->value
|
||||
(
|
||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
|
||||
"<html><head><title>FLTK: Programming with FLUID</title></head><body>\n"
|
||||
"<h2>What is FLUID?</h2>\n"
|
||||
"The Fast Light User Interface Designer, or FLUID, is a graphical editor "
|
||||
"that is used to produce FLTK source code. FLUID edits and saves its state "
|
||||
"in <code>.fl</code> files. These files are text, and you can (with care) "
|
||||
"edit them in a text editor, perhaps to get some special effects.<p>\n"
|
||||
"FLUID can \"compile\" the <code>.fl</code> file into a <code>.cxx</code> "
|
||||
"and a <code>.h</code> file. The <code>.cxx</code> file defines all the "
|
||||
"objects from the <code>.fl</code> file and the <code>.h</code> file "
|
||||
"declares all the global ones. FLUID also supports localization "
|
||||
"(Internationalization) of label strings using message files and the GNU "
|
||||
"gettext or POSIX catgets interfaces.<p>\n"
|
||||
"A simple program can be made by putting all your code (including a <code>"
|
||||
"main()</code> function) into the <code>.fl</code> file and thus making the "
|
||||
"<code>.cxx</code> file a single source file to compile. Most programs are "
|
||||
"more complex than this, so you write other <code>.cxx</code> files that "
|
||||
"call the FLUID functions. These <code>.cxx</code> files must <code>"
|
||||
"#include</code> the <code>.h</code> file or they can <code>#include</code> "
|
||||
"the <code>.cxx</code> file so it still appears to be a single source file.<p>"
|
||||
"<img src=\"embedded:/fluid-org.png\"></p>"
|
||||
"<p>More information is available online at <a href="
|
||||
"\"http://www.fltk.org/doc-1.3/fluid.html\">http://www.fltk.org/</a>"
|
||||
"</body></html>"
|
||||
);
|
||||
} else if (strcmp(name, "license.html")==0) {
|
||||
fl_open_uri("http://www.fltk.org/doc-1.3/license.html");
|
||||
return;
|
||||
} else if (strcmp(name, "index.html")==0) {
|
||||
fl_open_uri("http://www.fltk.org/doc-1.3/index.html");
|
||||
return;
|
||||
} else {
|
||||
snprintf(helpname, sizeof(helpname), "http://www.fltk.org/%s", name);
|
||||
fl_open_uri(helpname);
|
||||
return;
|
||||
}
|
||||
}
|
||||
help_dialog->show();
|
||||
}
|
||||
|
||||
@@ -875,7 +925,7 @@ void help_cb(Fl_Widget *, void *) {
|
||||
}
|
||||
|
||||
void manual_cb(Fl_Widget *, void *) {
|
||||
show_help("main.html");
|
||||
show_help("index.html");
|
||||
}
|
||||
|
||||
|
||||
|
||||
+12
-2
@@ -35,6 +35,7 @@
|
||||
//
|
||||
|
||||
#include <FL/Fl_JPEG_Image.H>
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
#include <FL/fl_utf8.h>
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
@@ -268,14 +269,18 @@ static void jpeg_mem_src(j_decompress_ptr cinfo, const unsigned char *data)
|
||||
/**
|
||||
\brief The constructor loads the JPEG image from memory.
|
||||
|
||||
Construct an image from a block of memory inside the application. Fluid offers
|
||||
"binary Data" chunks as a great way to add image data into the C++ source code.
|
||||
name_png can be NULL. If a name is givem the image is added to the the list of
|
||||
shared images (see: Fl_Shared_Image) and will be available by that name.
|
||||
|
||||
The inherited destructor frees all memory and server resources that are used
|
||||
by the image.
|
||||
|
||||
There is no error function in this class. If the image has loaded correctly,
|
||||
w(), h(), and d() should return values greater zero.
|
||||
|
||||
\param name The developer should provide a unique name for this image.
|
||||
Note: currently this is not used!
|
||||
\param name A unique name or NULL
|
||||
\param data A pointer to the memory location of the JPEG image
|
||||
*/
|
||||
Fl_JPEG_Image::Fl_JPEG_Image(const char *name, const unsigned char *data)
|
||||
@@ -363,6 +368,11 @@ Fl_JPEG_Image::Fl_JPEG_Image(const char *name, const unsigned char *data)
|
||||
|
||||
free(max_destroy_decompress_err);
|
||||
free(max_finish_decompress_err);
|
||||
|
||||
if (w() && h() && name) {
|
||||
Fl_Shared_Image *si = new Fl_Shared_Image(name, this);
|
||||
si->add();
|
||||
}
|
||||
#endif // HAVE_LIBJPEG
|
||||
}
|
||||
|
||||
|
||||
+19
-5
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_PNG_Image.H>
|
||||
#include <FL/Fl_Shared_Image.H>
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -89,11 +90,17 @@ Fl_PNG_Image::Fl_PNG_Image (const char *filename): Fl_RGB_Image(0,0,0)
|
||||
load_png_(filename, NULL, 0);
|
||||
}
|
||||
|
||||
/** Constructor that reads a PNG image from memory.
|
||||
/**
|
||||
\brief Constructor that reads a PNG image from memory.
|
||||
|
||||
\param name_png A name given to this image
|
||||
Construct an image from a block of memory inside the application. Fluid offers
|
||||
"binary Data" chunks as a great way to add image data into the C++ source code.
|
||||
name_png can be NULL. If a name is givem the image is added to the the list of
|
||||
shared images (see: Fl_Shared_Image) and will be available by that name.
|
||||
|
||||
\param name_png A name given to this image or NULL
|
||||
\param buffer Pointer to the start of the PNG image in memory
|
||||
\param maxsize Size in bytes of the memory buffer containing the PNG image
|
||||
\param maxsize Size in bytes of the memory buffer containing the PNG image
|
||||
*/
|
||||
Fl_PNG_Image::Fl_PNG_Image (
|
||||
const char *name_png, const unsigned char *buffer, int maxsize): Fl_RGB_Image(0,0,0)
|
||||
@@ -111,7 +118,7 @@ void Fl_PNG_Image::load_png_(const char *name_png, const unsigned char *buffer_p
|
||||
png_infop info; // PNG info pointers
|
||||
png_bytep *rows;// PNG row pointers
|
||||
fl_png_memory png_mem_data;
|
||||
int from_memory = (buffer_png != NULL); // true iff reading image from memory
|
||||
int from_memory = (buffer_png != NULL); // true if reading image from memory
|
||||
|
||||
if (!from_memory) {
|
||||
if ((fp = fl_fopen(name_png, "rb")) == NULL) return;
|
||||
@@ -200,7 +207,14 @@ void Fl_PNG_Image::load_png_(const char *name_png, const unsigned char *buffer_p
|
||||
png_read_end(pp, info);
|
||||
png_destroy_read_struct(&pp, &info, NULL);
|
||||
|
||||
if (!from_memory) fclose(fp);
|
||||
if (from_memory) {
|
||||
if (w() && h() && name_png) {
|
||||
Fl_Shared_Image *si = new Fl_Shared_Image(name_png, this);
|
||||
si->add();
|
||||
}
|
||||
} else {
|
||||
fclose(fp);
|
||||
}
|
||||
#endif // HAVE_LIBPNG && HAVE_LIBZ
|
||||
}
|
||||
|
||||
|
||||
+18
-5
@@ -374,11 +374,24 @@ Fl_Shared_Image* Fl_Shared_Image::find(const char *n, int W, int H) {
|
||||
|
||||
|
||||
/**
|
||||
Gets a shared image, if it exists already ; it will return it.
|
||||
If it does not exist or if it exist but with other size,
|
||||
then the existing image is deleted and replaced
|
||||
by a new image from the n filename of the proper dimension.
|
||||
If n is not a valid image filename, then get() will return NULL.
|
||||
\brief Find or load an image that can be shared by multiple widgets.
|
||||
|
||||
Gets a shared image, if it exists already ; it will return it.
|
||||
If it does not exist or if it exist but with other size,
|
||||
then the existing image is deleted and replaced
|
||||
by a new image from the n filename of the proper dimension.
|
||||
If n is not a valid image filename, then get() will return NULL.
|
||||
|
||||
Shared JPEG and PNG images can also be created from memory by using their
|
||||
named memory access constructor.
|
||||
|
||||
\param n name of the image
|
||||
\param W, H desired size
|
||||
|
||||
\see Fl_Shared_Image::find(const char *n, int W, int H)
|
||||
\see Fl_Shared_Image::release()
|
||||
\see Fl_JPEG_Image::Fl_JPEG_Image(const char *name, const unsigned char *data)
|
||||
\see Fl_PNG_Image::Fl_PNG_Image (const char *name_png, const unsigned char *buffer, int maxsize)
|
||||
*/
|
||||
Fl_Shared_Image* Fl_Shared_Image::get(const char *n, int W, int H) {
|
||||
Fl_Shared_Image *temp; // Image
|
||||
|
||||
Reference in New Issue
Block a user