1998-10-21 20:29:01 +04:00
|
|
|
//
|
2005-02-06 19:28:36 +03:00
|
|
|
// "$Id$"
|
1998-10-21 20:29:01 +04:00
|
|
|
//
|
|
|
|
// FLUID main entry for the Fast Light Tool Kit (FLTK).
|
|
|
|
//
|
2010-11-29 00:06:39 +03:00
|
|
|
// Copyright 1998-2010 by Bill Spitzak and others.
|
1998-10-21 20:29:01 +04:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
2005-04-16 04:13:17 +04:00
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
1998-10-21 20:29:01 +04:00
|
|
|
//
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
#include <FL/Fl.H>
|
|
|
|
#include <FL/Fl_Double_Window.H>
|
|
|
|
#include <FL/Fl_Box.H>
|
|
|
|
#include <FL/Fl_Button.H>
|
2001-09-30 02:59:45 +04:00
|
|
|
#include <FL/Fl_File_Icon.H>
|
2001-09-29 18:38:59 +04:00
|
|
|
#include <FL/Fl_Help_Dialog.H>
|
1998-10-06 22:21:25 +04:00
|
|
|
#include <FL/Fl_Hold_Browser.H>
|
|
|
|
#include <FL/Fl_Menu_Bar.H>
|
|
|
|
#include <FL/Fl_Input.H>
|
2010-01-24 03:20:26 +03:00
|
|
|
#include <FL/Fl_Plugin.H>
|
1998-10-06 22:21:25 +04:00
|
|
|
#include <FL/fl_ask.H>
|
|
|
|
#include <FL/fl_draw.H>
|
2001-09-30 21:37:06 +04:00
|
|
|
#include <FL/Fl_File_Chooser.H>
|
1998-10-06 22:21:25 +04:00
|
|
|
#include <FL/fl_message.H>
|
|
|
|
#include <FL/filename.H>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
2005-03-20 20:41:56 +03:00
|
|
|
#include <sys/stat.h>
|
2005-08-06 09:02:56 +04:00
|
|
|
#include <time.h> // time(), localtime(), etc.
|
2001-08-11 20:09:26 +04:00
|
|
|
|
2002-04-01 20:19:32 +04:00
|
|
|
#include "../src/flstring.h"
|
2002-04-30 22:11:49 +04:00
|
|
|
#include "alignment_panel.h"
|
2002-10-31 21:49:05 +03:00
|
|
|
#include "function_panel.h"
|
2005-03-21 00:27:20 +03:00
|
|
|
#include "template_panel.h"
|
2005-03-26 00:12:15 +03:00
|
|
|
#if !defined(WIN32) || defined(__CYGWIN__)
|
2005-04-13 20:36:14 +04:00
|
|
|
# include "print_panel.cxx"
|
|
|
|
#endif // !WIN32 || __CYGWIN__
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2000-04-04 21:57:05 +04:00
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
2001-03-16 01:39:57 +03:00
|
|
|
# include <direct.h>
|
|
|
|
# include <windows.h>
|
2005-03-19 17:54:54 +03:00
|
|
|
# include <io.h>
|
2008-11-29 20:06:31 +03:00
|
|
|
# include <fcntl.h>
|
2005-03-26 08:58:20 +03:00
|
|
|
# include <commdlg.h>
|
|
|
|
# include <FL/x.H>
|
2007-02-20 21:43:10 +03:00
|
|
|
# ifndef __WATCOMC__
|
2005-11-27 17:45:48 +03:00
|
|
|
// Visual C++ 2005 incorrectly displays a warning about the use of POSIX APIs
|
|
|
|
// on Windows, which is supposed to be POSIX compliant...
|
2007-02-20 20:02:41 +03:00
|
|
|
# define access _access
|
|
|
|
# define chdir _chdir
|
|
|
|
# define getcwd _getcwd
|
|
|
|
# endif // !__WATCOMC__
|
1998-10-06 22:21:25 +04:00
|
|
|
#else
|
2001-03-16 01:39:57 +03:00
|
|
|
# include <unistd.h>
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|
2001-12-21 21:16:50 +03:00
|
|
|
#ifdef __EMX__
|
|
|
|
# include <X11/Xlibint.h>
|
|
|
|
#endif
|
1998-10-06 22:21:25 +04:00
|
|
|
|
1998-12-06 18:09:22 +03:00
|
|
|
#include "about_panel.h"
|
2005-03-20 07:00:48 +03:00
|
|
|
#include "undo.h"
|
1998-10-06 22:21:25 +04:00
|
|
|
|
1998-12-06 18:09:22 +03:00
|
|
|
#include "Fl_Type.h"
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2005-03-20 20:41:56 +03:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#if defined(HAVE_LIBPNG) && defined(HAVE_LIBZ)
|
|
|
|
# include <zlib.h>
|
|
|
|
# ifdef HAVE_PNG_H
|
|
|
|
# include <png.h>
|
|
|
|
# else
|
|
|
|
# include <libpng/png.h>
|
|
|
|
# endif // HAVE_PNG_H
|
|
|
|
#endif // HAVE_LIBPNG && HAVE_LIBZ
|
|
|
|
}
|
|
|
|
|
2001-09-29 18:38:59 +04:00
|
|
|
static Fl_Help_Dialog *help_dialog = 0;
|
2001-08-11 20:09:26 +04:00
|
|
|
|
2002-04-30 22:11:49 +04:00
|
|
|
Fl_Preferences fluid_prefs(Fl_Preferences::USER, "fltk.org", "fluid");
|
2002-05-01 23:17:24 +04:00
|
|
|
int gridx = 5;
|
|
|
|
int gridy = 5;
|
|
|
|
int snap = 1;
|
2005-02-26 23:27:19 +03:00
|
|
|
int show_guides = 1;
|
2008-09-19 01:11:28 +04:00
|
|
|
int show_comments = 1;
|
2010-02-28 01:38:25 +03:00
|
|
|
int show_coredevmenus = 1;
|
2002-04-30 22:11:49 +04:00
|
|
|
|
|
|
|
// File history info...
|
2010-12-20 00:20:10 +03:00
|
|
|
char absolute_history[10][FL_PATH_MAX];
|
|
|
|
char relative_history[10][FL_PATH_MAX];
|
2002-04-30 22:11:49 +04:00
|
|
|
|
2002-05-01 14:36:08 +04:00
|
|
|
void load_history();
|
|
|
|
void update_history(const char *);
|
2002-04-30 22:11:49 +04:00
|
|
|
|
2002-05-01 14:36:08 +04:00
|
|
|
// Shell command support...
|
|
|
|
void show_shell_window();
|
2001-08-11 20:09:26 +04:00
|
|
|
|
2010-02-26 16:03:21 +03:00
|
|
|
Fl_Menu_Item *save_item = 0L;
|
|
|
|
Fl_Menu_Item *history_item = 0L;
|
|
|
|
Fl_Menu_Item *widgetbin_item = 0L;
|
|
|
|
Fl_Menu_Item *sourceview_item = 0L;
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static const char *filename;
|
|
|
|
void set_filename(const char *c);
|
2005-03-19 11:38:21 +03:00
|
|
|
void set_modflag(int mf);
|
1998-10-06 22:21:25 +04:00
|
|
|
int modflag;
|
|
|
|
|
|
|
|
static char* pwd;
|
|
|
|
static char in_source_dir;
|
|
|
|
void goto_source_dir() {
|
|
|
|
if (in_source_dir) return;
|
|
|
|
if (!filename || !*filename) return;
|
2002-03-26 00:08:42 +03:00
|
|
|
const char *p = fl_filename_name(filename);
|
1998-10-06 22:21:25 +04:00
|
|
|
if (p <= filename) return; // it is in the current directory
|
2010-12-20 00:20:10 +03:00
|
|
|
char buffer[FL_PATH_MAX];
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcpy(buffer, filename, sizeof(buffer));
|
1998-10-06 22:21:25 +04:00
|
|
|
int n = p-filename; if (n>1) n--; buffer[n] = 0;
|
|
|
|
if (!pwd) {
|
2010-12-20 00:20:10 +03:00
|
|
|
pwd = getcwd(0,FL_PATH_MAX);
|
1998-10-06 22:21:25 +04:00
|
|
|
if (!pwd) {fprintf(stderr,"getwd : %s\n",strerror(errno)); return;}
|
|
|
|
}
|
|
|
|
if (chdir(buffer)<0) {fprintf(stderr, "Can't chdir to %s : %s\n",
|
|
|
|
buffer, strerror(errno)); return;}
|
|
|
|
in_source_dir = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void leave_source_dir() {
|
|
|
|
if (!in_source_dir) return;
|
|
|
|
if (chdir(pwd)<0) {fprintf(stderr, "Can't chdir to %s : %s\n",
|
1999-01-19 22:10:39 +03:00
|
|
|
pwd, strerror(errno));}
|
1998-10-06 22:21:25 +04:00
|
|
|
in_source_dir = 0;
|
|
|
|
}
|
2008-11-29 20:06:31 +03:00
|
|
|
|
2002-11-03 03:01:21 +03:00
|
|
|
char position_window(Fl_Window *w, const char *prefsName, int Visible, int X, int Y, int W=0, int H=0 ) {
|
2002-10-31 21:49:05 +03:00
|
|
|
Fl_Preferences pos(fluid_prefs, prefsName);
|
2002-11-03 03:01:21 +03:00
|
|
|
if (prevpos_button->value()) {
|
|
|
|
pos.get("x", X, X);
|
|
|
|
pos.get("y", Y, Y);
|
|
|
|
if ( W!=0 ) {
|
|
|
|
pos.get("w", W, W);
|
|
|
|
pos.get("h", H, H);
|
|
|
|
w->resize( X, Y, W, H );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
w->position( X, Y );
|
2002-10-31 21:49:05 +03:00
|
|
|
}
|
2002-11-03 03:01:21 +03:00
|
|
|
pos.get("visible", Visible, Visible);
|
|
|
|
return Visible;
|
2002-10-31 21:49:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void save_position(Fl_Window *w, const char *prefsName) {
|
|
|
|
Fl_Preferences pos(fluid_prefs, prefsName);
|
|
|
|
pos.set("x", w->x());
|
|
|
|
pos.set("y", w->y());
|
|
|
|
pos.set("w", w->w());
|
|
|
|
pos.set("h", w->h());
|
2004-09-08 00:59:18 +04:00
|
|
|
pos.set("visible", (int)(w->shown() && w->visible()));
|
2002-10-31 21:49:05 +03:00
|
|
|
}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Window *main_window;
|
2005-03-18 00:57:17 +03:00
|
|
|
Fl_Menu_Bar *main_menubar;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2005-03-21 00:27:20 +03:00
|
|
|
static char* cutfname(int which = 0) {
|
2010-12-20 00:20:10 +03:00
|
|
|
static char name[2][FL_PATH_MAX];
|
2005-03-21 00:27:20 +03:00
|
|
|
static char beenhere = 0;
|
|
|
|
|
|
|
|
if (!beenhere) {
|
|
|
|
beenhere = 1;
|
|
|
|
fluid_prefs.getUserdataPath(name[0], sizeof(name[0]));
|
|
|
|
strlcat(name[0], "cut_buffer", sizeof(name[0]));
|
|
|
|
fluid_prefs.getUserdataPath(name[1], sizeof(name[1]));
|
|
|
|
strlcat(name[1], "dup_buffer", sizeof(name[1]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return name[which];
|
|
|
|
}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
void save_cb(Fl_Widget *, void *v) {
|
|
|
|
const char *c = filename;
|
|
|
|
if (v || !c || !*c) {
|
2005-03-25 21:58:18 +03:00
|
|
|
fl_file_chooser_ok_label("Save");
|
2005-03-20 20:41:56 +03:00
|
|
|
c=fl_file_chooser("Save To:", "FLUID Files (*.f[ld])", c);
|
2005-03-25 21:58:18 +03:00
|
|
|
fl_file_chooser_ok_label(NULL);
|
2005-03-19 11:38:21 +03:00
|
|
|
if (!c) return;
|
|
|
|
|
2005-03-20 20:41:56 +03:00
|
|
|
if (!access(c, 0)) {
|
2005-03-19 11:38:21 +03:00
|
|
|
const char *basename;
|
|
|
|
if ((basename = strrchr(c, '/')) != NULL)
|
|
|
|
basename ++;
|
|
|
|
#if defined(WIN32) || defined(__EMX__)
|
|
|
|
if ((basename = strrchr(c, '\\')) != NULL)
|
|
|
|
basename ++;
|
|
|
|
#endif // WIN32 || __EMX__
|
|
|
|
else
|
|
|
|
basename = c;
|
|
|
|
|
|
|
|
if (fl_choice("The file \"%s\" already exists.\n"
|
|
|
|
"Do you want to replace it?", "Cancel",
|
|
|
|
"Replace", NULL, basename) == 0) return;
|
|
|
|
}
|
|
|
|
|
2005-03-24 19:31:59 +03:00
|
|
|
if (v != (void *)2) set_filename(c);
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
if (!write_file(c)) {
|
2005-03-20 20:41:56 +03:00
|
|
|
fl_alert("Error writing %s: %s", c, strerror(errno));
|
1998-10-06 22:21:25 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-03-24 19:31:59 +03:00
|
|
|
|
|
|
|
if (v != (void *)2) {
|
|
|
|
set_modflag(0);
|
|
|
|
undo_save = undo_current;
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
|
2005-03-20 20:41:56 +03:00
|
|
|
void save_template_cb(Fl_Widget *, void *) {
|
2005-03-21 00:27:20 +03:00
|
|
|
// Setup the template panel...
|
|
|
|
if (!template_panel) make_template_panel();
|
2005-03-20 20:41:56 +03:00
|
|
|
|
2005-03-21 00:27:20 +03:00
|
|
|
template_clear();
|
|
|
|
template_browser->add("New Template");
|
|
|
|
template_load();
|
|
|
|
|
|
|
|
template_name->show();
|
|
|
|
template_name->value("");
|
|
|
|
|
|
|
|
template_instance->hide();
|
|
|
|
|
|
|
|
template_delete->show();
|
|
|
|
template_delete->deactivate();
|
|
|
|
|
|
|
|
template_submit->label("Save");
|
|
|
|
template_submit->deactivate();
|
|
|
|
|
|
|
|
template_panel->label("Save Template");
|
|
|
|
|
|
|
|
// Show the panel and wait for the user to do something...
|
|
|
|
template_panel->show();
|
|
|
|
while (template_panel->shown()) Fl::wait();
|
|
|
|
|
|
|
|
// Get the template name, return if it is empty...
|
|
|
|
const char *c = template_name->value();
|
|
|
|
if (!c || !*c) return;
|
|
|
|
|
|
|
|
// Convert template name to filename_with_underscores
|
2010-12-20 00:20:10 +03:00
|
|
|
char safename[FL_PATH_MAX], *safeptr;
|
2005-03-21 00:27:20 +03:00
|
|
|
strlcpy(safename, c, sizeof(safename));
|
|
|
|
for (safeptr = safename; *safeptr; safeptr ++) {
|
|
|
|
if (isspace(*safeptr)) *safeptr = '_';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the templates directory...
|
2010-12-20 00:20:10 +03:00
|
|
|
char filename[FL_PATH_MAX];
|
2005-03-20 20:41:56 +03:00
|
|
|
fluid_prefs.getUserdataPath(filename, sizeof(filename));
|
|
|
|
|
|
|
|
strlcat(filename, "templates", sizeof(filename));
|
2005-03-26 00:12:15 +03:00
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
|
|
|
if (access(filename, 0)) mkdir(filename);
|
|
|
|
#else
|
2005-03-20 20:41:56 +03:00
|
|
|
if (access(filename, 0)) mkdir(filename, 0777);
|
2005-03-26 00:12:15 +03:00
|
|
|
#endif // WIN32 && !__CYGWIN__
|
2005-03-20 20:41:56 +03:00
|
|
|
|
|
|
|
strlcat(filename, "/", sizeof(filename));
|
2005-03-21 00:27:20 +03:00
|
|
|
strlcat(filename, safename, sizeof(filename));
|
2005-03-20 20:41:56 +03:00
|
|
|
|
|
|
|
char *ext = filename + strlen(filename);
|
|
|
|
if (ext >= (filename + sizeof(filename) - 5)) {
|
|
|
|
fl_alert("The template name \"%s\" is too long!", c);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-03-21 00:27:20 +03:00
|
|
|
// Save the .fl file...
|
2005-03-20 20:41:56 +03:00
|
|
|
strcpy(ext, ".fl");
|
|
|
|
|
|
|
|
if (!access(filename, 0)) {
|
|
|
|
if (fl_choice("The template \"%s\" already exists.\n"
|
|
|
|
"Do you want to replace it?", "Cancel",
|
|
|
|
"Replace", NULL, c) == 0) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!write_file(filename)) {
|
|
|
|
fl_alert("Error writing %s: %s", filename, strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined(HAVE_LIBPNG) && defined(HAVE_LIBZ)
|
|
|
|
// Get the screenshot, if any...
|
|
|
|
Fl_Type *t;
|
|
|
|
|
|
|
|
for (t = Fl_Type::first; t; t = t->next) {
|
|
|
|
// Find the first window...
|
|
|
|
if (t->is_window()) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!t) return;
|
|
|
|
|
|
|
|
// Grab a screenshot...
|
|
|
|
Fl_Window_Type *wt = (Fl_Window_Type *)t;
|
|
|
|
uchar *pixels;
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
if ((pixels = wt->read_image(w, h)) == NULL) return;
|
|
|
|
|
|
|
|
// Save to a PNG file...
|
|
|
|
strcpy(ext, ".png");
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
2010-11-18 23:00:01 +03:00
|
|
|
if ((fp = fl_fopen(filename, "wb")) == NULL) {
|
2005-03-20 20:41:56 +03:00
|
|
|
delete[] pixels;
|
|
|
|
fl_alert("Error writing %s: %s", filename, strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
png_structp pptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
|
|
|
|
png_infop iptr = png_create_info_struct(pptr);
|
|
|
|
png_bytep ptr = (png_bytep)pixels;
|
|
|
|
|
|
|
|
png_init_io(pptr, fp);
|
|
|
|
png_set_IHDR(pptr, iptr, w, h, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
|
|
|
|
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
|
|
|
|
png_set_sRGB(pptr, iptr, PNG_sRGB_INTENT_PERCEPTUAL);
|
|
|
|
|
|
|
|
png_write_info(pptr, iptr);
|
|
|
|
|
|
|
|
for (int i = h; i > 0; i --, ptr += w * 3) {
|
|
|
|
png_write_row(pptr, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
png_write_end(pptr, iptr);
|
|
|
|
png_destroy_write_struct(&pptr, &iptr);
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
# if 0 // The original PPM output code...
|
|
|
|
strcpy(ext, ".ppm");
|
2010-11-18 23:00:01 +03:00
|
|
|
fp = fl_fopen(filename, "wb");
|
2005-03-20 20:41:56 +03:00
|
|
|
fprintf(fp, "P6\n%d %d 255\n", w, h);
|
|
|
|
fwrite(pixels, w * h, 3, fp);
|
|
|
|
fclose(fp);
|
|
|
|
# endif // 0
|
|
|
|
|
|
|
|
delete[] pixels;
|
|
|
|
#endif // HAVE_LIBPNG && HAVE_LIBZ
|
|
|
|
}
|
|
|
|
|
2005-03-24 19:31:59 +03:00
|
|
|
void revert_cb(Fl_Widget *,void *) {
|
|
|
|
if (modflag) {
|
|
|
|
if (!fl_choice("This user interface has been changed. Really revert?",
|
|
|
|
"Cancel", "Revert", NULL)) return;
|
|
|
|
}
|
|
|
|
undo_suspend();
|
|
|
|
if (!read_file(filename, 0)) {
|
|
|
|
undo_resume();
|
|
|
|
fl_message("Can't read %s: %s", filename, strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
undo_resume();
|
|
|
|
set_modflag(0);
|
|
|
|
undo_clear();
|
|
|
|
}
|
|
|
|
|
1999-04-19 03:43:42 +04:00
|
|
|
void exit_cb(Fl_Widget *,void *) {
|
|
|
|
if (modflag)
|
2005-03-19 11:38:21 +03:00
|
|
|
switch (fl_choice("Do you want to save changes to this user\n"
|
2005-03-21 00:27:20 +03:00
|
|
|
"interface before exiting?", "Cancel",
|
|
|
|
"Save", "Don't Save"))
|
1999-04-19 03:43:42 +04:00
|
|
|
{
|
2005-03-21 00:27:20 +03:00
|
|
|
case 0 : /* Cancel */
|
1999-04-19 03:43:42 +04:00
|
|
|
return;
|
2005-03-20 02:49:46 +03:00
|
|
|
case 1 : /* Save */
|
1999-04-19 03:43:42 +04:00
|
|
|
save_cb(NULL, NULL);
|
|
|
|
if (modflag) return; // Didn't save!
|
|
|
|
}
|
|
|
|
|
2002-10-31 21:49:05 +03:00
|
|
|
save_position(main_window,"main_window_pos");
|
|
|
|
|
|
|
|
if (widgetbin_panel) {
|
|
|
|
save_position(widgetbin_panel,"widgetbin_pos");
|
|
|
|
delete widgetbin_panel;
|
|
|
|
}
|
2005-11-03 23:43:19 +03:00
|
|
|
if (sourceview_panel) {
|
|
|
|
Fl_Preferences svp(fluid_prefs, "sourceview");
|
|
|
|
svp.set("autorefresh", sv_autorefresh->value());
|
|
|
|
svp.set("autoposition", sv_autoposition->value());
|
|
|
|
svp.set("tab", sv_tab->find(sv_tab->value()));
|
|
|
|
save_position(sourceview_panel,"sourceview_pos");
|
|
|
|
delete sourceview_panel;
|
|
|
|
}
|
2001-08-11 20:09:26 +04:00
|
|
|
if (about_panel)
|
|
|
|
delete about_panel;
|
|
|
|
if (help_dialog)
|
|
|
|
delete help_dialog;
|
|
|
|
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_clear();
|
|
|
|
|
1999-04-19 03:43:42 +04:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2003-06-01 04:23:57 +04:00
|
|
|
#ifdef __APPLE__
|
|
|
|
# include <FL/x.H>
|
|
|
|
|
|
|
|
void
|
|
|
|
apple_open_cb(const char *c) {
|
2005-03-24 19:31:59 +03:00
|
|
|
if (modflag) {
|
2005-03-19 11:38:21 +03:00
|
|
|
switch (fl_choice("Do you want to save changes to this user\n"
|
2005-03-20 02:49:46 +03:00
|
|
|
"interface before opening another one?", "Don't Save",
|
|
|
|
"Save", "Cancel"))
|
2005-03-19 11:38:21 +03:00
|
|
|
{
|
2005-03-21 00:27:20 +03:00
|
|
|
case 0 : /* Cancel */
|
2005-03-19 11:38:21 +03:00
|
|
|
return;
|
2005-03-20 02:49:46 +03:00
|
|
|
case 1 : /* Save */
|
2005-03-19 11:38:21 +03:00
|
|
|
save_cb(NULL, NULL);
|
|
|
|
if (modflag) return; // Didn't save!
|
|
|
|
}
|
|
|
|
}
|
2003-06-01 04:23:57 +04:00
|
|
|
const char *oldfilename;
|
|
|
|
oldfilename = filename;
|
|
|
|
filename = NULL;
|
|
|
|
set_filename(c);
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_suspend();
|
2003-06-01 04:23:57 +04:00
|
|
|
if (!read_file(c, 0)) {
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
2003-06-01 04:23:57 +04:00
|
|
|
fl_message("Can't read %s: %s", c, strerror(errno));
|
|
|
|
free((void *)filename);
|
|
|
|
filename = oldfilename;
|
|
|
|
if (main_window) main_window->label(filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Loaded a file; free the old filename...
|
2005-03-19 11:38:21 +03:00
|
|
|
set_modflag(0);
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
|
|
|
undo_clear();
|
2003-06-01 04:23:57 +04:00
|
|
|
if (oldfilename) free((void *)oldfilename);
|
|
|
|
}
|
|
|
|
#endif // __APPLE__
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
void open_cb(Fl_Widget *, void *v) {
|
2005-03-24 19:31:59 +03:00
|
|
|
if (!v && modflag) {
|
2005-03-19 11:38:21 +03:00
|
|
|
switch (fl_choice("Do you want to save changes to this user\n"
|
2005-03-21 00:27:20 +03:00
|
|
|
"interface before opening another one?", "Cancel",
|
|
|
|
"Save", "Don't Save"))
|
2005-03-19 11:38:21 +03:00
|
|
|
{
|
2005-03-21 00:27:20 +03:00
|
|
|
case 0 : /* Cancel */
|
2005-03-19 11:38:21 +03:00
|
|
|
return;
|
2005-03-20 02:49:46 +03:00
|
|
|
case 1 : /* Save */
|
2005-03-19 11:38:21 +03:00
|
|
|
save_cb(NULL, NULL);
|
|
|
|
if (modflag) return; // Didn't save!
|
|
|
|
}
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
const char *c;
|
2002-05-02 14:08:44 +04:00
|
|
|
const char *oldfilename;
|
2005-03-25 21:58:18 +03:00
|
|
|
fl_file_chooser_ok_label("Open");
|
2005-03-19 11:38:21 +03:00
|
|
|
c = fl_file_chooser("Open:", "FLUID Files (*.f[ld])", filename);
|
2005-03-25 21:58:18 +03:00
|
|
|
fl_file_chooser_ok_label(NULL);
|
2005-03-19 11:38:21 +03:00
|
|
|
if (!c) return;
|
2002-05-02 14:08:44 +04:00
|
|
|
oldfilename = filename;
|
|
|
|
filename = NULL;
|
|
|
|
set_filename(c);
|
2005-03-20 07:00:48 +03:00
|
|
|
if (v != 0) undo_checkpoint();
|
|
|
|
undo_suspend();
|
1998-10-06 22:21:25 +04:00
|
|
|
if (!read_file(c, v!=0)) {
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
1998-11-05 19:04:53 +03:00
|
|
|
fl_message("Can't read %s: %s", c, strerror(errno));
|
2002-05-02 14:08:44 +04:00
|
|
|
free((void *)filename);
|
|
|
|
filename = oldfilename;
|
2005-03-24 19:31:59 +03:00
|
|
|
if (main_window) set_modflag(modflag);
|
1998-10-06 22:21:25 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
2002-05-02 14:08:44 +04:00
|
|
|
if (v) {
|
|
|
|
// Inserting a file; restore the original filename...
|
|
|
|
free((void *)filename);
|
|
|
|
filename = oldfilename;
|
2005-03-24 19:31:59 +03:00
|
|
|
set_modflag(1);
|
2002-05-02 14:08:44 +04:00
|
|
|
} else {
|
|
|
|
// Loaded a file; free the old filename...
|
2005-03-19 11:38:21 +03:00
|
|
|
set_modflag(0);
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_clear();
|
2002-05-02 14:08:44 +04:00
|
|
|
if (oldfilename) free((void *)oldfilename);
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
|
2002-04-30 22:11:49 +04:00
|
|
|
void open_history_cb(Fl_Widget *, void *v) {
|
2005-03-24 19:31:59 +03:00
|
|
|
if (modflag) {
|
2005-03-19 11:38:21 +03:00
|
|
|
switch (fl_choice("Do you want to save changes to this user\n"
|
2005-03-21 00:27:20 +03:00
|
|
|
"interface before opening another one?", "Cancel",
|
|
|
|
"Save", "Don't Save"))
|
2005-03-19 11:38:21 +03:00
|
|
|
{
|
2005-03-21 00:27:20 +03:00
|
|
|
case 0 : /* Cancel */
|
2005-03-19 11:38:21 +03:00
|
|
|
return;
|
2005-03-20 02:49:46 +03:00
|
|
|
case 1 : /* Save */
|
2005-03-19 11:38:21 +03:00
|
|
|
save_cb(NULL, NULL);
|
|
|
|
if (modflag) return; // Didn't save!
|
|
|
|
}
|
|
|
|
}
|
2002-05-02 14:08:44 +04:00
|
|
|
const char *oldfilename = filename;
|
|
|
|
filename = NULL;
|
|
|
|
set_filename((char *)v);
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_suspend();
|
2002-05-02 14:08:44 +04:00
|
|
|
if (!read_file(filename, 0)) {
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
|
|
|
undo_clear();
|
2002-05-02 14:08:44 +04:00
|
|
|
fl_message("Can't read %s: %s", filename, strerror(errno));
|
|
|
|
free((void *)filename);
|
|
|
|
filename = oldfilename;
|
|
|
|
if (main_window) main_window->label(filename);
|
2002-04-30 22:11:49 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-03-19 11:38:21 +03:00
|
|
|
set_modflag(0);
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
|
|
|
undo_clear();
|
2002-05-02 14:08:44 +04:00
|
|
|
if (oldfilename) free((void *)oldfilename);
|
2002-04-30 22:11:49 +04:00
|
|
|
}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
void new_cb(Fl_Widget *, void *v) {
|
2005-03-21 00:27:20 +03:00
|
|
|
// Check if the current file has been modified...
|
2005-03-24 19:31:59 +03:00
|
|
|
if (!v && modflag) {
|
2005-03-21 00:27:20 +03:00
|
|
|
// Yes, ask the user what to do...
|
2005-03-19 11:38:21 +03:00
|
|
|
switch (fl_choice("Do you want to save changes to this user\n"
|
2005-03-21 00:27:20 +03:00
|
|
|
"interface before creating a new one?", "Cancel",
|
|
|
|
"Save", "Don't Save"))
|
2005-03-19 11:38:21 +03:00
|
|
|
{
|
2005-03-21 00:27:20 +03:00
|
|
|
case 0 : /* Cancel */
|
2005-03-19 11:38:21 +03:00
|
|
|
return;
|
2005-03-20 02:49:46 +03:00
|
|
|
case 1 : /* Save */
|
2005-03-19 11:38:21 +03:00
|
|
|
save_cb(NULL, NULL);
|
|
|
|
if (modflag) return; // Didn't save!
|
|
|
|
}
|
|
|
|
}
|
2005-03-21 00:27:20 +03:00
|
|
|
|
|
|
|
// Setup the template panel...
|
|
|
|
if (!template_panel) make_template_panel();
|
|
|
|
|
|
|
|
template_clear();
|
|
|
|
template_browser->add("Blank");
|
|
|
|
template_load();
|
|
|
|
|
|
|
|
template_name->hide();
|
|
|
|
template_name->value("");
|
|
|
|
|
|
|
|
template_instance->show();
|
|
|
|
template_instance->deactivate();
|
|
|
|
template_instance->value("");
|
|
|
|
|
|
|
|
template_delete->hide();
|
|
|
|
|
|
|
|
template_submit->label("New");
|
|
|
|
template_submit->deactivate();
|
|
|
|
|
|
|
|
template_panel->label("New");
|
|
|
|
|
|
|
|
// Show the panel and wait for the user to do something...
|
|
|
|
template_panel->show();
|
|
|
|
while (template_panel->shown()) Fl::wait();
|
|
|
|
|
|
|
|
// See if the user chose anything...
|
|
|
|
int item = template_browser->value();
|
|
|
|
if (item < 1) return;
|
|
|
|
|
|
|
|
// Clear the current data...
|
1998-10-06 22:21:25 +04:00
|
|
|
delete_all();
|
2005-03-19 11:38:21 +03:00
|
|
|
set_filename(NULL);
|
2005-03-21 00:27:20 +03:00
|
|
|
|
|
|
|
// Load the template, if any...
|
|
|
|
const char *tname = (const char *)template_browser->data(item);
|
|
|
|
|
|
|
|
if (tname) {
|
|
|
|
// Grab the instance name...
|
|
|
|
const char *iname = template_instance->value();
|
|
|
|
|
|
|
|
if (iname && *iname) {
|
|
|
|
// Copy the template to a temp file, then read it in...
|
|
|
|
char line[1024], *ptr, *next;
|
|
|
|
FILE *infile, *outfile;
|
|
|
|
|
2010-11-18 23:00:01 +03:00
|
|
|
if ((infile = fl_fopen(tname, "r")) == NULL) {
|
2005-03-21 00:27:20 +03:00
|
|
|
fl_alert("Error reading template file \"%s\":\n%s", tname,
|
|
|
|
strerror(errno));
|
|
|
|
set_modflag(0);
|
|
|
|
undo_clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-18 23:00:01 +03:00
|
|
|
if ((outfile = fl_fopen(cutfname(1), "w")) == NULL) {
|
2005-03-21 00:27:20 +03:00
|
|
|
fl_alert("Error writing buffer file \"%s\":\n%s", cutfname(1),
|
|
|
|
strerror(errno));
|
|
|
|
fclose(infile);
|
|
|
|
set_modflag(0);
|
|
|
|
undo_clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fgets(line, sizeof(line), infile)) {
|
|
|
|
// Replace @INSTANCE@ with the instance name...
|
|
|
|
for (ptr = line; (next = strstr(ptr, "@INSTANCE@")) != NULL; ptr = next + 10) {
|
|
|
|
fwrite(ptr, next - ptr, 1, outfile);
|
|
|
|
fputs(iname, outfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs(ptr, outfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(infile);
|
|
|
|
fclose(outfile);
|
|
|
|
|
|
|
|
undo_suspend();
|
|
|
|
read_file(cutfname(1), 0);
|
|
|
|
unlink(cutfname(1));
|
|
|
|
undo_resume();
|
|
|
|
} else {
|
|
|
|
// No instance name, so read the template without replacements...
|
|
|
|
undo_suspend();
|
|
|
|
read_file(tname, 0);
|
|
|
|
undo_resume();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-19 11:38:21 +03:00
|
|
|
set_modflag(0);
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_clear();
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
|
2010-01-24 03:20:26 +03:00
|
|
|
int exit_early = 0;
|
1999-11-20 12:17:21 +03:00
|
|
|
int compile_only = 0;
|
2000-06-08 12:26:45 +04:00
|
|
|
int compile_strings = 0;
|
1999-03-04 21:10:01 +03:00
|
|
|
int header_file_set = 0;
|
|
|
|
int code_file_set = 0;
|
1998-12-06 17:59:14 +03:00
|
|
|
const char* header_file_name = ".h";
|
|
|
|
const char* code_file_name = ".cxx";
|
2000-04-24 22:22:50 +04:00
|
|
|
int i18n_type = 0;
|
|
|
|
const char* i18n_include = "";
|
|
|
|
const char* i18n_function = "";
|
|
|
|
const char* i18n_file = "";
|
|
|
|
const char* i18n_set = "";
|
2010-12-20 00:20:10 +03:00
|
|
|
char i18n_program[FL_PATH_MAX] = "";
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
void write_cb(Fl_Widget *, void *) {
|
|
|
|
if (!filename) {
|
|
|
|
save_cb(0,0);
|
|
|
|
if (!filename) return;
|
|
|
|
}
|
2010-12-20 00:20:10 +03:00
|
|
|
char cname[FL_PATH_MAX];
|
|
|
|
char hname[FL_PATH_MAX];
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcpy(i18n_program, fl_filename_name(filename), sizeof(i18n_program));
|
|
|
|
fl_filename_setext(i18n_program, sizeof(i18n_program), "");
|
2001-08-02 20:17:04 +04:00
|
|
|
if (*code_file_name == '.' && strchr(code_file_name, '/') == NULL) {
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcpy(cname, fl_filename_name(filename), sizeof(cname));
|
|
|
|
fl_filename_setext(cname, sizeof(cname), code_file_name);
|
1998-10-06 22:21:25 +04:00
|
|
|
} else {
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcpy(cname, code_file_name, sizeof(hname));
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
2001-08-02 20:17:04 +04:00
|
|
|
if (*header_file_name == '.' && strchr(header_file_name, '/') == NULL) {
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcpy(hname, fl_filename_name(filename), sizeof(hname));
|
|
|
|
fl_filename_setext(hname, sizeof(hname), header_file_name);
|
1998-10-06 22:21:25 +04:00
|
|
|
} else {
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcpy(hname, header_file_name, sizeof(hname));
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
1999-03-09 09:59:05 +03:00
|
|
|
if (!compile_only) goto_source_dir();
|
1998-10-06 22:21:25 +04:00
|
|
|
int x = write_code(cname,hname);
|
1999-03-09 09:59:05 +03:00
|
|
|
if (!compile_only) leave_source_dir();
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcat(cname, " and ", sizeof(cname));
|
|
|
|
strlcat(cname, hname, sizeof(cname));
|
1998-10-06 22:21:25 +04:00
|
|
|
if (compile_only) {
|
|
|
|
if (!x) {fprintf(stderr,"%s : %s\n",cname,strerror(errno)); exit(1);}
|
|
|
|
} else {
|
|
|
|
if (!x) {
|
1998-11-05 19:04:53 +03:00
|
|
|
fl_message("Can't write %s: %s", cname, strerror(errno));
|
2002-04-30 22:11:49 +04:00
|
|
|
} else if (completion_button->value()) {
|
2005-03-25 20:27:07 +03:00
|
|
|
fl_message("Wrote %s", cname);
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-24 22:22:50 +04:00
|
|
|
void write_strings_cb(Fl_Widget *, void *) {
|
2000-08-20 08:35:17 +04:00
|
|
|
static const char *exts[] = { ".txt", ".po", ".msg" };
|
2000-04-24 22:22:50 +04:00
|
|
|
if (!filename) {
|
|
|
|
save_cb(0,0);
|
|
|
|
if (!filename) return;
|
|
|
|
}
|
2010-12-20 00:20:10 +03:00
|
|
|
char sname[FL_PATH_MAX];
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcpy(sname, fl_filename_name(filename), sizeof(sname));
|
|
|
|
fl_filename_setext(sname, sizeof(sname), exts[i18n_type]);
|
2000-04-24 22:22:50 +04:00
|
|
|
if (!compile_only) goto_source_dir();
|
|
|
|
int x = write_strings(sname);
|
|
|
|
if (!compile_only) leave_source_dir();
|
|
|
|
if (compile_only) {
|
|
|
|
if (x) {fprintf(stderr,"%s : %s\n",sname,strerror(errno)); exit(1);}
|
|
|
|
} else {
|
|
|
|
if (x) {
|
|
|
|
fl_message("Can't write %s: %s", sname, strerror(errno));
|
2002-04-30 22:11:49 +04:00
|
|
|
} else if (completion_button->value()) {
|
2000-04-24 22:22:50 +04:00
|
|
|
fl_message("Wrote %s", sname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
void openwidget_cb(Fl_Widget *, void *) {
|
|
|
|
if (!Fl_Type::current) {
|
|
|
|
fl_message("Please select a widget");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Fl_Type::current->open();
|
|
|
|
}
|
|
|
|
|
|
|
|
void toggle_overlays(Fl_Widget *,void *);
|
|
|
|
|
|
|
|
void select_all_cb(Fl_Widget *,void *);
|
2005-03-20 03:12:21 +03:00
|
|
|
void select_none_cb(Fl_Widget *,void *);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
void group_cb(Fl_Widget *, void *);
|
|
|
|
|
|
|
|
void ungroup_cb(Fl_Widget *, void *);
|
|
|
|
|
|
|
|
extern int pasteoffset;
|
|
|
|
static int ipasteoffset;
|
|
|
|
|
|
|
|
void copy_cb(Fl_Widget*, void*) {
|
2005-03-18 00:57:17 +03:00
|
|
|
if (!Fl_Type::current) {
|
|
|
|
fl_beep();
|
|
|
|
return;
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
ipasteoffset = 10;
|
|
|
|
if (!write_file(cutfname(),1)) {
|
1998-11-05 19:04:53 +03:00
|
|
|
fl_message("Can't write %s: %s", cutfname(), strerror(errno));
|
1998-10-06 22:21:25 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern void select_only(Fl_Type *);
|
|
|
|
void cut_cb(Fl_Widget *, void *) {
|
2005-03-18 00:57:17 +03:00
|
|
|
if (!Fl_Type::current) {
|
|
|
|
fl_beep();
|
|
|
|
return;
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
if (!write_file(cutfname(),1)) {
|
1998-11-05 19:04:53 +03:00
|
|
|
fl_message("Can't write %s: %s", cutfname(), strerror(errno));
|
1998-10-06 22:21:25 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_checkpoint();
|
|
|
|
set_modflag(1);
|
|
|
|
ipasteoffset = 0;
|
|
|
|
Fl_Type *p = Fl_Type::current->parent;
|
|
|
|
while (p && p->selected) p = p->parent;
|
1998-10-06 22:21:25 +04:00
|
|
|
delete_all(1);
|
|
|
|
if (p) select_only(p);
|
|
|
|
}
|
|
|
|
|
2005-03-20 04:49:46 +03:00
|
|
|
void delete_cb(Fl_Widget *, void *) {
|
|
|
|
if (!Fl_Type::current) {
|
|
|
|
fl_beep();
|
|
|
|
return;
|
|
|
|
}
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_checkpoint();
|
|
|
|
set_modflag(1);
|
2005-03-20 04:49:46 +03:00
|
|
|
ipasteoffset = 0;
|
|
|
|
Fl_Type *p = Fl_Type::current->parent;
|
|
|
|
while (p && p->selected) p = p->parent;
|
|
|
|
delete_all(1);
|
|
|
|
if (p) select_only(p);
|
|
|
|
}
|
|
|
|
|
2002-05-01 23:17:24 +04:00
|
|
|
extern int force_parent;
|
1998-10-06 22:21:25 +04:00
|
|
|
|
|
|
|
void paste_cb(Fl_Widget*, void*) {
|
2003-07-19 10:10:20 +04:00
|
|
|
//if (ipasteoffset) force_parent = 1;
|
1998-10-06 22:21:25 +04:00
|
|
|
pasteoffset = ipasteoffset;
|
|
|
|
if (gridx>1) pasteoffset = ((pasteoffset-1)/gridx+1)*gridx;
|
|
|
|
if (gridy>1) pasteoffset = ((pasteoffset-1)/gridy+1)*gridy;
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_checkpoint();
|
|
|
|
undo_suspend();
|
1998-10-06 22:21:25 +04:00
|
|
|
if (!read_file(cutfname(), 1)) {
|
1998-11-05 19:04:53 +03:00
|
|
|
fl_message("Can't read %s: %s", cutfname(), strerror(errno));
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
1998-10-06 22:21:25 +04:00
|
|
|
pasteoffset = 0;
|
|
|
|
ipasteoffset += 10;
|
|
|
|
force_parent = 0;
|
|
|
|
}
|
|
|
|
|
2005-03-18 00:57:17 +03:00
|
|
|
// Duplicate the selected widgets...
|
|
|
|
void duplicate_cb(Fl_Widget*, void*) {
|
|
|
|
if (!Fl_Type::current) {
|
|
|
|
fl_beep();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!write_file(cutfname(1),1)) {
|
|
|
|
fl_message("Can't write %s: %s", cutfname(1), strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pasteoffset = 0;
|
|
|
|
force_parent = 1;
|
|
|
|
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_checkpoint();
|
|
|
|
undo_suspend();
|
2005-03-18 00:57:17 +03:00
|
|
|
if (!read_file(cutfname(1), 1)) {
|
|
|
|
fl_message("Can't read %s: %s", cutfname(1), strerror(errno));
|
|
|
|
}
|
2005-03-21 00:27:20 +03:00
|
|
|
unlink(cutfname(1));
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
2005-03-18 00:57:17 +03:00
|
|
|
|
|
|
|
force_parent = 0;
|
|
|
|
}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
void earlier_cb(Fl_Widget*,void*);
|
|
|
|
|
|
|
|
void later_cb(Fl_Widget*,void*);
|
|
|
|
|
|
|
|
Fl_Type *sort(Fl_Type *parent);
|
|
|
|
|
|
|
|
static void sort_cb(Fl_Widget *,void *) {
|
|
|
|
sort((Fl_Type*)0);
|
|
|
|
}
|
|
|
|
|
2002-05-01 23:17:24 +04:00
|
|
|
void show_project_cb(Fl_Widget *, void *);
|
|
|
|
void show_grid_cb(Fl_Widget *, void *);
|
2002-04-30 22:11:49 +04:00
|
|
|
void show_settings_cb(Fl_Widget *, void *);
|
2010-12-21 01:19:24 +03:00
|
|
|
void show_global_settings_cb(Fl_Widget *, void *);
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2002-05-01 21:35:30 +04:00
|
|
|
void align_widget_cb(Fl_Widget *, long);
|
2005-03-19 07:09:32 +03:00
|
|
|
void widget_size_cb(Fl_Widget *, long);
|
2002-05-01 21:35:30 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
void about_cb(Fl_Widget *, void *) {
|
2002-01-01 18:11:33 +03:00
|
|
|
if (!about_panel) make_about_panel();
|
1998-10-06 22:21:25 +04:00
|
|
|
about_panel->show();
|
|
|
|
}
|
|
|
|
|
2001-09-23 17:08:03 +04:00
|
|
|
void show_help(const char *name) {
|
|
|
|
const char *docdir;
|
2010-12-20 00:20:10 +03:00
|
|
|
char helpname[FL_PATH_MAX];
|
2008-11-29 20:06:31 +03:00
|
|
|
|
2001-09-29 18:38:59 +04:00
|
|
|
if (!help_dialog) help_dialog = new Fl_Help_Dialog();
|
2001-09-23 17:08:03 +04:00
|
|
|
|
2001-12-21 21:16:50 +03:00
|
|
|
if ((docdir = getenv("FLTK_DOCDIR")) == NULL) {
|
|
|
|
#ifdef __EMX__
|
|
|
|
// Doesn't make sense to have a hardcoded fallback
|
2010-12-20 00:20:10 +03:00
|
|
|
static char fltk_docdir[FL_PATH_MAX];
|
2001-12-21 21:16:50 +03:00
|
|
|
|
2002-08-10 02:57:00 +04:00
|
|
|
strlcpy(fltk_docdir, __XOS2RedirRoot("/XFree86/lib/X11/fltk/doc"),
|
|
|
|
sizeof(fltk_docdir));
|
2001-09-23 17:08:03 +04:00
|
|
|
|
2001-12-21 21:16:50 +03:00
|
|
|
docdir = fltk_docdir;
|
|
|
|
#else
|
|
|
|
docdir = FLTK_DOCDIR;
|
|
|
|
#endif // __EMX__
|
|
|
|
}
|
2008-11-29 20:06:31 +03:00
|
|
|
snprintf(helpname, sizeof(helpname), "%s/%s", docdir, name);
|
2001-09-23 17:08:03 +04:00
|
|
|
|
2002-08-10 02:57:00 +04:00
|
|
|
help_dialog->load(helpname);
|
2001-08-11 20:09:26 +04:00
|
|
|
help_dialog->show();
|
|
|
|
}
|
|
|
|
|
2001-09-23 17:08:03 +04:00
|
|
|
void help_cb(Fl_Widget *, void *) {
|
|
|
|
show_help("fluid.html");
|
|
|
|
}
|
|
|
|
|
2001-08-11 20:09:26 +04:00
|
|
|
void manual_cb(Fl_Widget *, void *) {
|
2009-01-20 11:47:18 +03:00
|
|
|
show_help("main.html");
|
2001-08-11 20:09:26 +04:00
|
|
|
}
|
|
|
|
|
2005-03-21 07:51:16 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-03-26 08:58:20 +03:00
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
|
|
|
// Draw a shaded box...
|
2005-03-26 19:02:27 +03:00
|
|
|
static void win_box(int x, int y, int w, int h) {
|
|
|
|
fl_color(0xc0, 0xc0, 0xc0);
|
2005-03-26 08:58:20 +03:00
|
|
|
fl_rectf(x, y, w, h);
|
2005-03-26 19:02:27 +03:00
|
|
|
fl_color(0, 0, 0);
|
2005-03-26 08:58:20 +03:00
|
|
|
fl_rect(x, y, w, h);
|
2005-03-26 19:02:27 +03:00
|
|
|
fl_color(0xf0, 0xf0, 0xf0);
|
2005-03-26 08:58:20 +03:00
|
|
|
fl_rectf(x + 1, y + 1, 4, h - 2);
|
|
|
|
fl_rectf(x + 1, y + 1, w - 2, 4);
|
2005-03-26 19:02:27 +03:00
|
|
|
fl_color(0x90, 0x90, 0x90);
|
2005-03-26 08:58:20 +03:00
|
|
|
fl_rectf(x + w - 5, y + 1, 4, h - 2);
|
|
|
|
fl_rectf(x + 1, y + h - 5, w - 2, 4);
|
|
|
|
}
|
|
|
|
|
2005-03-21 07:51:16 +03:00
|
|
|
// Load and show the print dialog...
|
|
|
|
void print_menu_cb(Fl_Widget *, void *) {
|
2005-03-26 08:58:20 +03:00
|
|
|
PRINTDLG dialog; // Print dialog
|
|
|
|
DOCINFO docinfo; // Document info
|
|
|
|
int first, last; // First and last page
|
|
|
|
int page; // Current page
|
|
|
|
int winpage; // Current window page
|
|
|
|
int num_pages; // Number of pages
|
|
|
|
Fl_Type *t; // Current widget
|
|
|
|
int num_windows; // Number of windows
|
|
|
|
Fl_Window_Type *windows[1000]; // Windows to print
|
|
|
|
|
|
|
|
|
|
|
|
// Show print dialog...
|
|
|
|
for (t = Fl_Type::first, num_pages = 0; t; t = t->next) {
|
|
|
|
if (t->is_window()) num_pages ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&dialog, 0, sizeof(dialog));
|
|
|
|
dialog.lStructSize = sizeof(dialog);
|
|
|
|
dialog.hwndOwner = fl_xid(main_window);
|
|
|
|
dialog.Flags = PD_ALLPAGES |
|
|
|
|
PD_RETURNDC;
|
|
|
|
dialog.nFromPage = 1;
|
|
|
|
dialog.nToPage = num_pages;
|
|
|
|
dialog.nMinPage = 1;
|
|
|
|
dialog.nMaxPage = num_pages;
|
|
|
|
dialog.nCopies = 1;
|
|
|
|
|
|
|
|
if (!PrintDlg(&dialog)) return;
|
|
|
|
|
|
|
|
// Get the base filename...
|
|
|
|
const char *basename = strrchr(filename, '/');
|
|
|
|
if (basename) basename ++;
|
|
|
|
else basename = filename;
|
|
|
|
|
|
|
|
// Do the print job...
|
|
|
|
memset(&docinfo, 0, sizeof(docinfo));
|
|
|
|
docinfo.cbSize = sizeof(docinfo);
|
|
|
|
docinfo.lpszDocName = basename;
|
|
|
|
|
|
|
|
StartDoc(dialog.hDC, &docinfo);
|
|
|
|
|
|
|
|
// Figure out how many pages we'll have to print...
|
|
|
|
if (dialog.Flags & PD_PAGENUMS) {
|
|
|
|
// Get from and to page numbers...
|
|
|
|
first = dialog.nFromPage;
|
|
|
|
last = dialog.nToPage;
|
|
|
|
|
|
|
|
if (first > last) {
|
|
|
|
// Swap first/last page
|
|
|
|
page = first;
|
|
|
|
first = last;
|
|
|
|
last = page;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print everything...
|
|
|
|
first = 1;
|
|
|
|
last = dialog.nMaxPage;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (t = Fl_Type::first, num_windows = 0, winpage = 0; t; t = t->next) {
|
|
|
|
if (t->is_window()) {
|
|
|
|
winpage ++;
|
|
|
|
windows[num_windows] = (Fl_Window_Type *)t;
|
|
|
|
num_windows ++;
|
|
|
|
#if 0
|
|
|
|
if (dialog.Flags & PD_ALLPAGES) num_windows ++;
|
|
|
|
else if ((dialog.Flags & PD_PAGENUMS) && winpage >= first &&
|
|
|
|
winpage <= last) num_windows ++;
|
|
|
|
else if ((dialog.Flags & PD_SELECTION) && t->selected) num_windows ++;
|
|
|
|
#endif // 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
num_pages = num_windows;
|
|
|
|
|
|
|
|
// Figure out the page size and margins...
|
|
|
|
int width, length; // Size of page
|
|
|
|
int xdpi, ydpi; // Output resolution
|
|
|
|
char buffer[1024];
|
|
|
|
|
|
|
|
width = GetDeviceCaps(dialog.hDC, HORZRES);
|
|
|
|
length = GetDeviceCaps(dialog.hDC, VERTRES);
|
|
|
|
xdpi = GetDeviceCaps(dialog.hDC, LOGPIXELSX);
|
|
|
|
ydpi = GetDeviceCaps(dialog.hDC, LOGPIXELSY);
|
|
|
|
|
|
|
|
// fl_message("width=%d, length=%d, xdpi=%d, ydpi=%d, num_windows=%d\n",
|
|
|
|
// width, length, xdpi, ydpi, num_windows);
|
|
|
|
|
|
|
|
HDC save_dc = fl_gc;
|
2005-03-26 19:02:27 +03:00
|
|
|
HWND save_win = fl_window;
|
2005-03-26 08:58:20 +03:00
|
|
|
int fontsize = 14 * ydpi / 72;
|
|
|
|
|
|
|
|
fl_gc = dialog.hDC;
|
2005-03-26 19:02:27 +03:00
|
|
|
fl_window = (HWND)dialog.hDC;
|
2005-03-26 08:58:20 +03:00
|
|
|
fl_push_no_clip();
|
|
|
|
|
|
|
|
// Get the time and date...
|
|
|
|
time_t curtime = time(NULL);
|
|
|
|
struct tm *curdate = localtime(&curtime);
|
|
|
|
char date[1024];
|
|
|
|
|
|
|
|
strftime(date, sizeof(date), "%c", curdate);
|
2008-11-29 20:06:31 +03:00
|
|
|
|
2005-03-26 08:58:20 +03:00
|
|
|
// Print each of the windows...
|
|
|
|
for (winpage = 0; winpage < num_windows; winpage ++) {
|
|
|
|
// Draw header...
|
|
|
|
StartPage(dialog.hDC);
|
|
|
|
|
|
|
|
fl_font(FL_HELVETICA_BOLD, fontsize);
|
2005-03-26 19:02:27 +03:00
|
|
|
fl_color(0, 0, 0);
|
2005-03-26 08:58:20 +03:00
|
|
|
|
|
|
|
fl_draw(basename, 0, fontsize);
|
|
|
|
|
2005-04-14 17:56:07 +04:00
|
|
|
fl_draw(date, (width - (int)fl_width(date)) / 2, fontsize);
|
2005-03-26 08:58:20 +03:00
|
|
|
|
|
|
|
sprintf(buffer, "%d/%d", winpage + 1, num_windows);
|
2005-04-14 17:56:07 +04:00
|
|
|
fl_draw(buffer, width - (int)fl_width(buffer), fontsize);
|
2005-03-26 08:58:20 +03:00
|
|
|
|
|
|
|
// Get window image...
|
|
|
|
uchar *pixels; // Window image data
|
|
|
|
int w, h; // Window image dimensions
|
|
|
|
int ww, hh; // Scaled size
|
|
|
|
int ulx, uly; // Upper-lefthand corner
|
|
|
|
Fl_Window *win; // Window widget
|
|
|
|
BITMAPINFO info; // Bitmap information
|
|
|
|
|
|
|
|
win = (Fl_Window *)(windows[winpage]->o);
|
|
|
|
pixels = windows[winpage]->read_image(w, h);
|
|
|
|
|
2009-04-27 19:51:21 +04:00
|
|
|
// Swap colors: FLTK uses R-G-B --> Windows GDI uses B-G-R
|
|
|
|
|
|
|
|
{ uchar *p = pixels;
|
|
|
|
for (int i=0; i<w*h; i++, p+=3) {
|
|
|
|
uchar temp = p[0]; p[0] = p[2]; p[2] = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-26 08:58:20 +03:00
|
|
|
// Figure out the window size, first at 100 PPI and then scaled
|
|
|
|
// down if that is too big...
|
2005-04-14 17:56:07 +04:00
|
|
|
ww = w * xdpi / 100;
|
|
|
|
hh = h * ydpi / 100;
|
2005-03-26 08:58:20 +03:00
|
|
|
|
|
|
|
if (ww > width) {
|
|
|
|
ww = width;
|
|
|
|
hh = h * ww * ydpi / xdpi / w;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hh > (length - ydpi / 2)) {
|
|
|
|
hh = length - ydpi / 2;
|
|
|
|
ww = w * hh / h;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Position the window in the center...
|
|
|
|
ulx = (width - ww) / 2;
|
|
|
|
uly = (length - hh) / 2;
|
|
|
|
|
|
|
|
// fl_message("winpage=%d, ulx=%d, uly=%d, ww=%d, hh=%d",
|
|
|
|
// winpage, ulx, uly, ww, hh);
|
|
|
|
|
|
|
|
// Draw a simulated window border...
|
|
|
|
int xborder = 4 * ww / w;
|
|
|
|
int yborder = 4 * hh / h;
|
|
|
|
|
|
|
|
win_box(ulx - xborder, uly - 5 * yborder,
|
2005-03-26 19:02:27 +03:00
|
|
|
ww + 2 * xborder, hh + 6 * yborder);
|
2005-03-26 08:58:20 +03:00
|
|
|
|
2005-03-26 19:02:27 +03:00
|
|
|
fl_color(0, 0, 255);
|
2005-03-26 08:58:20 +03:00
|
|
|
fl_rectf(ulx, uly - 4 * yborder, ww, 4 * yborder);
|
|
|
|
|
2005-03-26 19:02:27 +03:00
|
|
|
fl_font(FL_HELVETICA_BOLD, 2 * yborder);
|
|
|
|
fl_color(255, 255, 255);
|
2005-03-26 08:58:20 +03:00
|
|
|
fl_draw(win->label() ? win->label() : "Window",
|
2005-03-26 19:02:27 +03:00
|
|
|
ulx + xborder, uly - 3 * yborder);
|
2005-03-26 08:58:20 +03:00
|
|
|
|
|
|
|
int x = ulx + ww - 4 * xborder;
|
|
|
|
|
2005-03-26 19:02:27 +03:00
|
|
|
win_box(x, uly - 4 * yborder, 4 * xborder, 4 * yborder);
|
|
|
|
fl_color(0, 0, 0);
|
|
|
|
fl_line(x + xborder, uly - yborder,
|
|
|
|
x + 3 * xborder, uly - 3 * yborder);
|
|
|
|
fl_line(x + xborder, uly - 3 * yborder,
|
|
|
|
x + 3 * xborder, uly - yborder);
|
2005-03-26 08:58:20 +03:00
|
|
|
x -= 4 * xborder;
|
|
|
|
|
|
|
|
if (win->resizable()) {
|
2005-03-26 19:02:27 +03:00
|
|
|
win_box(x, uly - 4 * yborder, 4 * xborder, 4 * yborder);
|
|
|
|
fl_color(0, 0, 0);
|
|
|
|
fl_rect(x + xborder, uly - 3 * yborder, 2 * xborder, 2 * yborder);
|
2005-03-26 08:58:20 +03:00
|
|
|
x -= 4 * xborder;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!win->modal()) {
|
2005-03-26 19:02:27 +03:00
|
|
|
win_box(x, uly - 4 * yborder, 4 * xborder, 4 * yborder);
|
|
|
|
fl_color(0, 0, 0);
|
|
|
|
fl_line(x + xborder, uly - yborder, x + 3 * xborder, uly - yborder);
|
2005-03-26 08:58:20 +03:00
|
|
|
x -= 4 * xborder;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Color image...
|
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
info.bmiHeader.biSize = sizeof(info);
|
|
|
|
info.bmiHeader.biWidth = w;
|
2005-03-26 19:02:27 +03:00
|
|
|
info.bmiHeader.biHeight = 1;
|
2005-03-26 08:58:20 +03:00
|
|
|
info.bmiHeader.biPlanes = 1;
|
|
|
|
info.bmiHeader.biBitCount = 24;
|
|
|
|
info.bmiHeader.biCompression = BI_RGB;
|
|
|
|
|
2005-03-26 19:02:27 +03:00
|
|
|
for (int y = 0; y < h; y ++) {
|
|
|
|
StretchDIBits(dialog.hDC, ulx, uly + y * hh / h, ww, (hh + h - 1) / h, 0, 0, w, 1,
|
|
|
|
pixels + y * w * 3, &info, DIB_RGB_COLORS, SRCCOPY);
|
|
|
|
}
|
2005-03-26 08:58:20 +03:00
|
|
|
|
|
|
|
delete[] pixels;
|
|
|
|
|
|
|
|
// Show the page...
|
|
|
|
EndPage(dialog.hDC);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finish up...
|
|
|
|
EndDoc(dialog.hDC);
|
|
|
|
|
|
|
|
fl_gc = save_dc;
|
2005-03-29 01:12:54 +04:00
|
|
|
fl_window = save_win;
|
2005-03-26 08:58:20 +03:00
|
|
|
fl_pop_clip();
|
|
|
|
|
|
|
|
// Free the print DC and return...
|
|
|
|
DeleteDC(dialog.hDC);
|
2005-03-21 07:51:16 +03:00
|
|
|
}
|
|
|
|
#else
|
2005-03-26 08:58:20 +03:00
|
|
|
// Load and show the print dialog...
|
|
|
|
void print_menu_cb(Fl_Widget *, void *) {
|
2005-03-21 07:51:16 +03:00
|
|
|
if (!print_panel) make_print_panel();
|
|
|
|
|
|
|
|
print_load();
|
|
|
|
|
|
|
|
print_selection->deactivate();
|
|
|
|
|
|
|
|
for (Fl_Type *t = Fl_Type::first; t; t = t->next) {
|
|
|
|
if (t->selected && t->is_window()) {
|
|
|
|
print_selection->activate();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print_all->setonly();
|
|
|
|
print_all->do_callback();
|
|
|
|
|
|
|
|
print_panel->show();
|
|
|
|
}
|
|
|
|
|
2005-03-21 22:35:43 +03:00
|
|
|
// Quote a string for PostScript printing
|
|
|
|
static const char *ps_string(const char *s) {
|
|
|
|
char *bufptr;
|
2010-12-20 00:20:10 +03:00
|
|
|
static char buffer[FL_PATH_MAX];
|
2005-03-21 22:35:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
if (!s) {
|
|
|
|
buffer[0] = '\0';
|
|
|
|
} else {
|
|
|
|
for (bufptr = buffer; bufptr < (buffer + sizeof(buffer) - 3) && *s;) {
|
|
|
|
if (*s == '(' || *s == ')' || *s == '\\') *bufptr++ = '\\';
|
|
|
|
*bufptr++ = *s++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*bufptr = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
return (buffer);
|
|
|
|
}
|
|
|
|
|
2005-03-21 07:51:16 +03:00
|
|
|
// Actually print...
|
|
|
|
void print_cb(Fl_Return_Button *, void *) {
|
|
|
|
FILE *outfile; // Output file or pipe to print command
|
|
|
|
char command[1024]; // Print command
|
|
|
|
int copies; // Collated copies
|
|
|
|
int first, last; // First and last page
|
|
|
|
int page; // Current page
|
|
|
|
int winpage; // Current window page
|
|
|
|
int num_pages; // Number of pages
|
|
|
|
Fl_Type *t; // Current widget
|
|
|
|
int num_windows; // Number of windows
|
|
|
|
Fl_Window_Type *windows[1000]; // Windows to print
|
|
|
|
|
|
|
|
// Show progress, deactivate controls...
|
|
|
|
print_panel_controls->deactivate();
|
|
|
|
print_progress->show();
|
|
|
|
|
|
|
|
// Figure out how many pages we'll have to print...
|
2005-03-25 05:39:25 +03:00
|
|
|
if (print_collate_button->value()) copies = (int)print_copies->value();
|
2005-03-21 07:51:16 +03:00
|
|
|
else copies = 1;
|
|
|
|
|
|
|
|
if (print_pages->value()) {
|
|
|
|
// Get from and to page numbers...
|
|
|
|
if ((first = atoi(print_from->value())) < 1) first = 1;
|
|
|
|
if ((last = atoi(print_to->value())) < 1) last = 1000;
|
|
|
|
|
|
|
|
if (first > last) {
|
|
|
|
// Swap first/last page
|
|
|
|
page = first;
|
|
|
|
first = last;
|
|
|
|
last = page;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Print everything...
|
|
|
|
first = 1;
|
|
|
|
last = 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (t = Fl_Type::first, num_windows = 0, winpage = 0; t; t = t->next) {
|
|
|
|
if (t->is_window()) {
|
|
|
|
winpage ++;
|
|
|
|
windows[num_windows] = (Fl_Window_Type *)t;
|
|
|
|
|
|
|
|
if (print_all->value()) num_windows ++;
|
|
|
|
else if (print_pages->value() && winpage >= first &&
|
|
|
|
winpage <= last) num_windows ++;
|
|
|
|
else if (print_selection->value() && t->selected) num_windows ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
num_pages = num_windows * copies;
|
|
|
|
|
|
|
|
print_progress->minimum(0);
|
|
|
|
print_progress->maximum(num_pages);
|
|
|
|
print_progress->value(0);
|
|
|
|
Fl::check();
|
|
|
|
|
|
|
|
// Get the base filename...
|
|
|
|
const char *basename = strrchr(filename, '/');
|
|
|
|
if (basename) basename ++;
|
|
|
|
else basename = filename;
|
|
|
|
|
|
|
|
// Open the print stream...
|
|
|
|
if (print_choice->value()) {
|
|
|
|
// Pipe the output into the lp command...
|
2005-03-21 20:34:03 +03:00
|
|
|
const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
|
|
|
|
|
2005-03-25 05:39:25 +03:00
|
|
|
snprintf(command, sizeof(command), "lp -s -d %s -n %.0f -t '%s' -o media=%s",
|
|
|
|
printer, print_collate_button->value() ? 1.0 : print_copies->value(),
|
2005-03-21 07:51:16 +03:00
|
|
|
basename, print_page_size->text(print_page_size->value()));
|
|
|
|
outfile = popen(command, "w");
|
|
|
|
} else {
|
|
|
|
// Print to file...
|
2005-03-25 21:58:18 +03:00
|
|
|
fl_file_chooser_ok_label("Print");
|
2005-03-21 22:35:43 +03:00
|
|
|
const char *outname = fl_file_chooser("Print To", "PostScript (*.ps)", NULL, 1);
|
2005-03-25 21:58:18 +03:00
|
|
|
fl_file_chooser_ok_label(NULL);
|
2005-03-21 07:51:16 +03:00
|
|
|
|
2005-03-21 22:35:43 +03:00
|
|
|
if (outname && !access(outname, 0)) {
|
|
|
|
if (fl_choice("The file \"%s\" already exists.\n"
|
|
|
|
"Do you want to replace it?", "Cancel",
|
|
|
|
"Replace", NULL, outname) == 0) outname = NULL;
|
|
|
|
}
|
|
|
|
|
2010-11-18 23:00:01 +03:00
|
|
|
if (outname) outfile = fl_fopen(outname, "w");
|
2005-03-21 20:34:03 +03:00
|
|
|
else outfile = NULL;
|
2005-03-21 07:51:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (outfile) {
|
|
|
|
// Figure out the page size and margins...
|
|
|
|
int width, length; // Size of page
|
|
|
|
int left, bottom, // Bottom lefthand corner
|
|
|
|
right, top; // Top righthand corner
|
|
|
|
|
|
|
|
if (print_page_size->value()) {
|
|
|
|
// A4
|
|
|
|
width = 595;
|
|
|
|
length = 842;
|
|
|
|
} else {
|
|
|
|
// Letter
|
|
|
|
width = 612;
|
|
|
|
length = 792;
|
|
|
|
}
|
|
|
|
|
|
|
|
int output_mode;
|
|
|
|
for (output_mode = 0; output_mode < 4; output_mode ++) {
|
|
|
|
if (print_output_mode[output_mode]->value()) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (output_mode & 1) {
|
|
|
|
// Landscape
|
|
|
|
left = 36;
|
|
|
|
bottom = 18;
|
|
|
|
right = length - 36;
|
|
|
|
top = width - 18;
|
|
|
|
} else {
|
|
|
|
// Portrait
|
|
|
|
left = 18;
|
|
|
|
bottom = 36;
|
|
|
|
right = width - 18;
|
|
|
|
top = length - 36;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the time and date...
|
|
|
|
time_t curtime = time(NULL);
|
|
|
|
struct tm *curdate = localtime(&curtime);
|
|
|
|
char date[1024];
|
|
|
|
|
|
|
|
strftime(date, sizeof(date), "%c", curdate);
|
2008-11-29 20:06:31 +03:00
|
|
|
|
2005-03-21 07:51:16 +03:00
|
|
|
// Write the prolog...
|
|
|
|
fprintf(outfile,
|
|
|
|
"%%!PS-Adobe-3.0\n"
|
|
|
|
"%%%%BoundingBox: 18 36 %d %d\n"
|
|
|
|
"%%%%Pages: %d\n"
|
|
|
|
"%%%%LanguageLevel: 1\n"
|
|
|
|
"%%%%DocumentData: Clean7Bit\n"
|
2005-03-21 22:35:43 +03:00
|
|
|
"%%%%DocumentNeededResources: font Helvetica-Bold\n"
|
2005-03-21 07:51:16 +03:00
|
|
|
"%%%%Creator: FLUID %.4f\n"
|
|
|
|
"%%%%CreationDate: %s\n"
|
|
|
|
"%%%%Title: (%s)\n"
|
|
|
|
"%%%%EndComments\n"
|
2005-03-21 22:35:43 +03:00
|
|
|
"%%%%BeginProlog\n"
|
|
|
|
"%%languagelevel 1 eq {\n"
|
|
|
|
" /rectfill {\n"
|
|
|
|
" newpath 4 2 roll moveto dup 0 exch rlineto exch 0 rlineto\n"
|
|
|
|
" neg 0 exch rlineto closepath fill\n"
|
|
|
|
" } bind def\n"
|
|
|
|
" /rectstroke {\n"
|
|
|
|
" newpath 4 2 roll moveto dup 0 exch rlineto exch 0 rlineto\n"
|
|
|
|
" neg 0 exch rlineto closepath stroke\n"
|
|
|
|
" } bind def\n"
|
|
|
|
"%%} if\n"
|
|
|
|
"%%%%EndProlog\n"
|
2005-03-21 07:51:16 +03:00
|
|
|
"%%%%BeginSetup\n"
|
|
|
|
"%%%%BeginFeature: *PageSize %s\n"
|
|
|
|
"languagelevel 1 ne {\n"
|
|
|
|
" <</PageSize[%d %d]/ImagingBBox null>>setpagedevice\n"
|
|
|
|
"} {\n"
|
|
|
|
" %s\n"
|
|
|
|
"} ifelse\n"
|
|
|
|
"%%%%EndFeature\n"
|
|
|
|
"%%%%EndSetup\n",
|
|
|
|
width - 18, length - 36,
|
|
|
|
num_pages,
|
|
|
|
FL_VERSION,
|
|
|
|
date,
|
|
|
|
basename,
|
|
|
|
print_page_size->text(print_page_size->value()),
|
|
|
|
width, length,
|
|
|
|
print_page_size->value() ? "a4tray" : "lettertray");
|
|
|
|
|
|
|
|
// Print each of the windows...
|
|
|
|
char progress[255]; // Progress text
|
|
|
|
int copy; // Current copy
|
|
|
|
|
|
|
|
for (copy = 0, page = 0; copy < copies; copy ++) {
|
|
|
|
for (winpage = 0; winpage < num_pages; winpage ++) {
|
|
|
|
// Start next page...
|
|
|
|
page ++;
|
|
|
|
sprintf(progress, "Printing page %d/%d...", page, num_pages);
|
|
|
|
print_progress->value(page);
|
|
|
|
print_progress->label(progress);
|
|
|
|
Fl::check();
|
|
|
|
|
|
|
|
// Add common page stuff...
|
|
|
|
fprintf(outfile,
|
|
|
|
"%%%%Page: %d %d\n"
|
|
|
|
"gsave\n",
|
|
|
|
page, page);
|
|
|
|
|
|
|
|
if (output_mode & 1) {
|
|
|
|
// Landscape...
|
|
|
|
fprintf(outfile, "%d 0 translate 90 rotate\n", width);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw header...
|
|
|
|
fprintf(outfile,
|
|
|
|
"0 setgray\n"
|
2005-03-21 22:35:43 +03:00
|
|
|
"/Helvetica-Bold findfont 14 scalefont setfont\n"
|
2005-03-21 07:51:16 +03:00
|
|
|
"%d %d moveto (%s) show\n"
|
|
|
|
"%.1f %d moveto (%s) dup stringwidth pop -0.5 mul 0 rmoveto show\n"
|
2005-03-21 20:34:03 +03:00
|
|
|
"%d %d moveto (%d/%d) dup stringwidth pop neg 0 rmoveto show\n",
|
2005-03-21 22:35:43 +03:00
|
|
|
left, top - 15, ps_string(basename),
|
2005-03-21 07:51:16 +03:00
|
|
|
0.5 * (left + right), top - 15, date,
|
2005-03-21 20:34:03 +03:00
|
|
|
right, top - 15, winpage + 1, num_windows);
|
2005-03-21 07:51:16 +03:00
|
|
|
|
|
|
|
// Get window image...
|
|
|
|
uchar *pixels; // Window image data
|
|
|
|
int w, h; // Window image dimensions
|
|
|
|
float ww, hh; // Scaled size
|
|
|
|
float border; // Width of 1 pixel
|
|
|
|
float llx, lly, // Lower-lefthand corner
|
|
|
|
urx, ury; // Upper-righthand corner
|
2005-03-21 22:35:43 +03:00
|
|
|
Fl_Window *win; // Window widget
|
2005-03-21 07:51:16 +03:00
|
|
|
|
2005-03-21 22:35:43 +03:00
|
|
|
win = (Fl_Window *)(windows[winpage]->o);
|
2005-03-21 07:51:16 +03:00
|
|
|
pixels = windows[winpage]->read_image(w, h);
|
|
|
|
|
|
|
|
// Figure out the window size, first at 100 PPI and then scaled
|
|
|
|
// down if that is too big...
|
|
|
|
ww = w * 72.0 / 100.0;
|
|
|
|
hh = h * 72.0 / 100.0;
|
|
|
|
|
|
|
|
if (ww > (right - left)) {
|
|
|
|
ww = right - left;
|
|
|
|
hh = h * ww / w;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hh > (top - bottom - 36)) {
|
|
|
|
hh = top - bottom;
|
|
|
|
ww = w * hh / h;
|
|
|
|
}
|
|
|
|
|
|
|
|
border = ww / w;
|
|
|
|
|
|
|
|
// Position the window in the center...
|
|
|
|
llx = 0.5 * (right - left - ww);
|
|
|
|
lly = 0.5 * (top - bottom - hh);
|
|
|
|
urx = 0.5 * (right - left + ww);
|
|
|
|
ury = 0.5 * (top - bottom + hh);
|
|
|
|
|
|
|
|
// Draw a simulated window border...
|
|
|
|
fprintf(outfile,
|
2005-03-21 22:35:43 +03:00
|
|
|
"0.75 setgray\n" // Gray background
|
2008-11-29 20:06:31 +03:00
|
|
|
"newpath %.2f %.2f %.2f 180 90 arcn\n" // Top left
|
2005-03-21 07:51:16 +03:00
|
|
|
"%.2f %.2f %.2f 90 0 arcn\n" // Top right
|
|
|
|
"%.2f %.2f %.2f 0 -90 arcn\n" // Bottom right
|
|
|
|
"%.2f %.2f %.2f -90 -180 arcn\n" // Bottom left
|
2005-03-21 22:35:43 +03:00
|
|
|
"closepath gsave fill grestore\n" // Fill
|
|
|
|
"0 setlinewidth 0 setgray stroke\n", // Outline
|
2005-03-21 08:02:05 +03:00
|
|
|
llx, ury + 12 * border, 4 * border,
|
|
|
|
urx, ury + 12 * border, 4 * border,
|
2005-03-21 07:51:16 +03:00
|
|
|
urx, lly, 4 * border,
|
|
|
|
llx, lly, 4 * border);
|
|
|
|
|
2005-03-21 22:35:43 +03:00
|
|
|
// Title bar...
|
|
|
|
if (output_mode & 2) {
|
|
|
|
fputs("0.25 setgray\n", outfile);
|
|
|
|
} else {
|
|
|
|
fputs("0.1 0.2 0.6 setrgbcolor\n", outfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(outfile, "%.2f %.2f %.2f %.2f rectfill\n",
|
|
|
|
llx + 12 * border, ury,
|
|
|
|
ww - (24 + 16 * (!win->modal() || win->resizable()) +
|
|
|
|
16 * (!win->modal() && win->resizable())) * border,
|
|
|
|
16 * border);
|
|
|
|
|
|
|
|
if (win->resizable()) {
|
|
|
|
fprintf(outfile,
|
|
|
|
"%.2f %.2f %.2f -90 -180 arcn\n" // Bottom left
|
|
|
|
"0 %.2f rlineto %.2f 0 rlineto 0 -%.2f rlineto closepath fill\n"
|
|
|
|
"%.2f %.2f %.2f 0 -90 arcn\n" // Bottom right
|
|
|
|
"-%.2f 0 rlineto 0 %.2f rlineto %.2f 0 rlineto closepath fill\n",
|
|
|
|
llx, lly, 4 * border,
|
|
|
|
12 * border, 16 * border, 16 * border,
|
|
|
|
urx, lly, 4 * border,
|
|
|
|
12 * border, 16 * border, 16 * border);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inside outline and button shading...
|
|
|
|
fprintf(outfile,
|
|
|
|
"%.2f setlinewidth 0.5 setgray\n"
|
|
|
|
"%.2f %.2f %.2f %.2f rectstroke\n"
|
|
|
|
"%.2f %.2f moveto 0 %.2f rlineto\n"
|
|
|
|
"%.2f %.2f moveto 0 %.2f rlineto\n",
|
|
|
|
border,
|
|
|
|
llx - 0.5 * border, lly - 0.5 * border, ww + border, hh + border,
|
|
|
|
llx + 12 * border, ury, 16 * border,
|
|
|
|
urx - 12 * border, ury, 16 * border);
|
|
|
|
|
|
|
|
if (!win->modal() || win->resizable()) {
|
|
|
|
fprintf(outfile, "%.2f %.2f moveto 0 %.2f rlineto\n",
|
|
|
|
urx - 28 * border, ury, 16 * border);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!win->modal() && win->resizable()) {
|
|
|
|
fprintf(outfile, "%.2f %.2f moveto 0 %.2f rlineto\n",
|
|
|
|
urx - 44 * border, ury, 16 * border);
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(outfile, "%.2f %.2f moveto %.2f 0 rlineto stroke\n",
|
|
|
|
llx - 3.5 * border, ury + 0.5 * border, ww + 7 * border);
|
|
|
|
|
|
|
|
// Button icons...
|
|
|
|
fprintf(outfile,
|
|
|
|
"%.2f setlinewidth 0 setgray\n"
|
|
|
|
"%.2f %.2f moveto %.2f -%.2f rlineto %.2f %.2f rlineto\n"
|
|
|
|
"%.2f %.2f moveto -%.2f -%.2f rlineto 0 %.2f rmoveto %.2f -%.2f rlineto\n",
|
|
|
|
2 * border,
|
|
|
|
llx, ury + 10 * border, 4 * border, 4 * border, 4 * border, 4 * border,
|
|
|
|
urx, ury + 12 * border, 8 * border, 8 * border, 8 * border, 8 * border, 8 * border);
|
|
|
|
|
|
|
|
float x = urx - 16 * border;
|
|
|
|
|
|
|
|
if (win->resizable()) {
|
|
|
|
// Maximize button
|
|
|
|
fprintf(outfile,
|
|
|
|
"%.2f %.2f moveto -%.2f 0 rlineto 0 -%.2f rlineto "
|
|
|
|
"%.2f 0 rlineto 0 %.2f rlineto\n",
|
|
|
|
x, ury + 12 * border, 8 * border, 8 * border,
|
|
|
|
8 * border, 8 * border);
|
|
|
|
|
|
|
|
x -= 16 * border;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!win->modal()) {
|
|
|
|
// Minimize button
|
|
|
|
fprintf(outfile,
|
|
|
|
"%.2f %.2f moveto -%.2f 0 rlineto\n",
|
|
|
|
x, ury + 4 * border, 8 * border);
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs("stroke\n", outfile);
|
|
|
|
|
|
|
|
if (win->label()) {
|
2005-03-21 07:51:16 +03:00
|
|
|
// Add window title...
|
|
|
|
fprintf(outfile,
|
|
|
|
"1 setgray\n"
|
2005-03-21 22:35:43 +03:00
|
|
|
"/Helvetica-Bold findfont %.2f scalefont setfont\n"
|
|
|
|
"(%s) %.2f %.2f moveto show\n",
|
2005-03-21 07:51:16 +03:00
|
|
|
12 * border,
|
2005-03-21 22:35:43 +03:00
|
|
|
ps_string(win->label()), llx + 16 * border, ury + 4 * border);
|
2005-03-21 07:51:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(outfile,
|
|
|
|
"gsave\n"
|
|
|
|
"%.2f %.2f translate %.2f %.2f scale\n",
|
2005-03-21 22:35:43 +03:00
|
|
|
llx, ury - border, border, border);
|
2005-03-21 07:51:16 +03:00
|
|
|
|
|
|
|
if (output_mode & 2) {
|
|
|
|
// Grayscale image...
|
|
|
|
fprintf(outfile,
|
|
|
|
"/imgdata %d string def\n"
|
|
|
|
"%d %d 8[1 0 0 -1 0 1] "
|
|
|
|
"{currentfile imgdata readhexstring pop} image\n",
|
|
|
|
w,
|
|
|
|
w, h);
|
|
|
|
|
|
|
|
uchar *ptr = pixels;
|
|
|
|
int i, count = w * h;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i ++, ptr += 3) {
|
|
|
|
fprintf(outfile, "%02X",
|
|
|
|
(31 * ptr[0] + 61 * ptr[1] + 8 * ptr[2]) / 100);
|
|
|
|
if (!(i % 40)) putc('\n', outfile);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Color image...
|
|
|
|
fprintf(outfile,
|
|
|
|
"/imgdata %d string def\n"
|
|
|
|
"%d %d 8[1 0 0 -1 0 1] "
|
|
|
|
"{currentfile imgdata readhexstring pop} false 3 colorimage\n",
|
|
|
|
w * 3,
|
|
|
|
w, h);
|
|
|
|
|
|
|
|
uchar *ptr = pixels;
|
|
|
|
int i, count = w * h;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i ++, ptr += 3) {
|
|
|
|
fprintf(outfile, "%02X%02X%02X", ptr[0], ptr[1], ptr[2]);
|
|
|
|
if (!(i % 13)) putc('\n', outfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs("\ngrestore\n", outfile);
|
|
|
|
|
|
|
|
delete[] pixels;
|
|
|
|
|
|
|
|
// Show the page...
|
|
|
|
fputs("grestore showpage\n", outfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Finish up...
|
|
|
|
fputs("%%EOF\n", outfile);
|
|
|
|
|
|
|
|
if (print_choice->value()) pclose(outfile);
|
|
|
|
else fclose(outfile);
|
|
|
|
} else {
|
|
|
|
// Unable to print...
|
|
|
|
fl_alert("Error printing: %s", strerror(errno));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hide progress, activate controls, hide print panel...
|
|
|
|
print_panel_controls->activate();
|
|
|
|
print_progress->hide();
|
|
|
|
print_panel->hide();
|
|
|
|
}
|
2005-03-26 00:12:15 +03:00
|
|
|
#endif // WIN32 && !__CYGWIN__
|
2005-03-21 07:51:16 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
extern Fl_Menu_Item New_Menu[];
|
|
|
|
|
2005-03-20 03:12:21 +03:00
|
|
|
void toggle_widgetbin_cb(Fl_Widget *, void *);
|
2005-11-03 23:43:19 +03:00
|
|
|
void toggle_sourceview_cb(Fl_Double_Window *, void *);
|
2005-03-20 03:12:21 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl_Menu_Item Main_Menu[] = {
|
1999-01-19 22:10:39 +03:00
|
|
|
{"&File",0,0,0,FL_SUBMENU},
|
2006-10-14 08:35:24 +04:00
|
|
|
{"&New...", FL_COMMAND+'n', new_cb, 0},
|
|
|
|
{"&Open...", FL_COMMAND+'o', open_cb, 0},
|
|
|
|
{"&Insert...", FL_COMMAND+'i', open_cb, (void*)1, FL_MENU_DIVIDER},
|
|
|
|
{"&Save", FL_COMMAND+'s', save_cb, 0},
|
|
|
|
{"Save &As...", FL_COMMAND+FL_SHIFT+'s', save_cb, (void*)1},
|
2005-03-24 19:31:59 +03:00
|
|
|
{"Sa&ve A Copy...", 0, save_cb, (void*)2},
|
|
|
|
{"Save &Template...", 0, save_template_cb},
|
|
|
|
{"&Revert...", 0, revert_cb, 0, FL_MENU_DIVIDER},
|
2006-10-14 08:35:24 +04:00
|
|
|
{"&Print...", FL_COMMAND+'p', print_menu_cb},
|
|
|
|
{"Write &Code...", FL_COMMAND+FL_SHIFT+'c', write_cb, 0},
|
|
|
|
{"&Write Strings...", FL_COMMAND+FL_SHIFT+'w', write_strings_cb, 0, FL_MENU_DIVIDER},
|
|
|
|
{relative_history[0], FL_COMMAND+'0', open_history_cb, absolute_history[0]},
|
|
|
|
{relative_history[1], FL_COMMAND+'1', open_history_cb, absolute_history[1]},
|
|
|
|
{relative_history[2], FL_COMMAND+'2', open_history_cb, absolute_history[2]},
|
|
|
|
{relative_history[3], FL_COMMAND+'3', open_history_cb, absolute_history[3]},
|
|
|
|
{relative_history[4], FL_COMMAND+'4', open_history_cb, absolute_history[4]},
|
|
|
|
{relative_history[5], FL_COMMAND+'5', open_history_cb, absolute_history[5]},
|
|
|
|
{relative_history[6], FL_COMMAND+'6', open_history_cb, absolute_history[6]},
|
|
|
|
{relative_history[7], FL_COMMAND+'7', open_history_cb, absolute_history[7]},
|
|
|
|
{relative_history[8], FL_COMMAND+'8', open_history_cb, absolute_history[8]},
|
|
|
|
{relative_history[9], FL_COMMAND+'9', open_history_cb, absolute_history[9], FL_MENU_DIVIDER},
|
|
|
|
{"&Quit", FL_COMMAND+'q', exit_cb},
|
1998-10-06 22:21:25 +04:00
|
|
|
{0},
|
1999-01-19 22:10:39 +03:00
|
|
|
{"&Edit",0,0,0,FL_SUBMENU},
|
2006-10-14 08:35:24 +04:00
|
|
|
{"&Undo", FL_COMMAND+'z', undo_cb},
|
|
|
|
{"&Redo", FL_COMMAND+FL_SHIFT+'z', redo_cb, 0, FL_MENU_DIVIDER},
|
|
|
|
{"C&ut", FL_COMMAND+'x', cut_cb},
|
|
|
|
{"&Copy", FL_COMMAND+'c', copy_cb},
|
|
|
|
{"&Paste", FL_COMMAND+'v', paste_cb},
|
|
|
|
{"Dup&licate", FL_COMMAND+'u', duplicate_cb},
|
2005-03-20 17:35:18 +03:00
|
|
|
{"&Delete", FL_Delete, delete_cb, 0, FL_MENU_DIVIDER},
|
2006-10-14 08:35:24 +04:00
|
|
|
{"Select &All", FL_COMMAND+'a', select_all_cb},
|
|
|
|
{"Select &None", FL_COMMAND+FL_SHIFT+'a', select_none_cb, 0, FL_MENU_DIVIDER},
|
2005-03-20 17:35:18 +03:00
|
|
|
{"Pr&operties...", FL_F+1, openwidget_cb},
|
2002-05-01 23:17:24 +04:00
|
|
|
{"&Sort",0,sort_cb},
|
|
|
|
{"&Earlier", FL_F+2, earlier_cb},
|
|
|
|
{"&Later", FL_F+3, later_cb},
|
|
|
|
{"&Group", FL_F+7, group_cb},
|
2005-03-20 03:12:21 +03:00
|
|
|
{"Ung&roup", FL_F+8, ungroup_cb,0, FL_MENU_DIVIDER},
|
2006-10-14 08:35:24 +04:00
|
|
|
{"Hide O&verlays",FL_COMMAND+FL_SHIFT+'o',toggle_overlays},
|
2005-11-03 23:43:19 +03:00
|
|
|
{"Show Widget &Bin...",FL_ALT+'b',toggle_widgetbin_cb},
|
|
|
|
{"Show Source Code...",FL_ALT+FL_SHIFT+'s', (Fl_Callback*)toggle_sourceview_cb, 0, FL_MENU_DIVIDER},
|
2005-03-20 04:49:46 +03:00
|
|
|
{"Pro&ject Settings...",FL_ALT+'p',show_project_cb},
|
2010-12-21 01:19:24 +03:00
|
|
|
{"GU&I Settings...",FL_ALT+FL_SHIFT+'p',show_settings_cb,0,FL_MENU_DIVIDER},
|
|
|
|
{"Global &FLTK Settings...",FL_ALT+FL_SHIFT+'g',show_global_settings_cb},
|
1998-10-06 22:21:25 +04:00
|
|
|
{0},
|
1999-01-19 22:10:39 +03:00
|
|
|
{"&New", 0, 0, (void *)New_Menu, FL_SUBMENU_POINTER},
|
2002-05-01 21:35:30 +04:00
|
|
|
{"&Layout",0,0,0,FL_SUBMENU},
|
|
|
|
{"&Align",0,0,0,FL_SUBMENU},
|
|
|
|
{"&Left",0,(Fl_Callback *)align_widget_cb,(void*)10},
|
2002-05-01 23:17:24 +04:00
|
|
|
{"&Center",0,(Fl_Callback *)align_widget_cb,(void*)11},
|
2002-05-01 21:35:30 +04:00
|
|
|
{"&Right",0,(Fl_Callback *)align_widget_cb,(void*)12},
|
|
|
|
{"&Top",0,(Fl_Callback *)align_widget_cb,(void*)13},
|
2002-05-01 23:17:24 +04:00
|
|
|
{"&Middle",0,(Fl_Callback *)align_widget_cb,(void*)14},
|
2002-05-01 21:35:30 +04:00
|
|
|
{"&Bottom",0,(Fl_Callback *)align_widget_cb,(void*)15},
|
|
|
|
{0},
|
|
|
|
{"&Space Evenly",0,0,0,FL_SUBMENU},
|
|
|
|
{"&Across",0,(Fl_Callback *)align_widget_cb,(void*)20},
|
|
|
|
{"&Down",0,(Fl_Callback *)align_widget_cb,(void*)21},
|
|
|
|
{0},
|
|
|
|
{"&Make Same Size",0,0,0,FL_SUBMENU},
|
|
|
|
{"&Width",0,(Fl_Callback *)align_widget_cb,(void*)30},
|
|
|
|
{"&Height",0,(Fl_Callback *)align_widget_cb,(void*)31},
|
|
|
|
{"&Both",0,(Fl_Callback *)align_widget_cb,(void*)32},
|
|
|
|
{0},
|
2005-03-19 07:09:32 +03:00
|
|
|
{"&Center In Group",0,0,0,FL_SUBMENU},
|
2002-05-01 21:35:30 +04:00
|
|
|
{"&Horizontal",0,(Fl_Callback *)align_widget_cb,(void*)40},
|
|
|
|
{"&Vertical",0,(Fl_Callback *)align_widget_cb,(void*)41},
|
|
|
|
{0},
|
2005-09-09 15:36:36 +04:00
|
|
|
{"Set &Widget Size",0,0,0,FL_SUBMENU|FL_MENU_DIVIDER},
|
|
|
|
{"&Tiny",FL_ALT+'1',(Fl_Callback *)widget_size_cb,(void*)8,0,FL_NORMAL_LABEL,FL_HELVETICA,8},
|
|
|
|
{"&Small",FL_ALT+'2',(Fl_Callback *)widget_size_cb,(void*)11,0,FL_NORMAL_LABEL,FL_HELVETICA,11},
|
|
|
|
{"&Normal",FL_ALT+'3',(Fl_Callback *)widget_size_cb,(void*)14,0,FL_NORMAL_LABEL,FL_HELVETICA,14},
|
|
|
|
{"&Medium",FL_ALT+'4',(Fl_Callback *)widget_size_cb,(void*)18,0,FL_NORMAL_LABEL,FL_HELVETICA,18},
|
|
|
|
{"&Large",FL_ALT+'5',(Fl_Callback *)widget_size_cb,(void*)24,0,FL_NORMAL_LABEL,FL_HELVETICA,24},
|
|
|
|
{"&Huge",FL_ALT+'6',(Fl_Callback *)widget_size_cb,(void*)32,0,FL_NORMAL_LABEL,FL_HELVETICA,32},
|
2005-03-19 07:09:32 +03:00
|
|
|
{0},
|
2006-10-14 08:35:24 +04:00
|
|
|
{"&Grid and Size Settings...",FL_COMMAND+'g',show_grid_cb},
|
2002-05-01 21:35:30 +04:00
|
|
|
{0},
|
2002-05-01 14:36:08 +04:00
|
|
|
{"&Shell",0,0,0,FL_SUBMENU},
|
2002-05-01 23:17:24 +04:00
|
|
|
{"Execute &Command...",FL_ALT+'x',(Fl_Callback *)show_shell_window},
|
2005-03-17 10:11:57 +03:00
|
|
|
{"Execute &Again...",FL_ALT+'g',(Fl_Callback *)do_shell_command},
|
2002-05-01 14:36:08 +04:00
|
|
|
{0},
|
1999-01-19 22:10:39 +03:00
|
|
|
{"&Help",0,0,0,FL_SUBMENU},
|
2010-02-28 01:38:25 +03:00
|
|
|
{"&Rapid development with FLUID...",0,help_cb},
|
|
|
|
{"&FLTK Programmers Manual...",0,manual_cb, 0, FL_MENU_DIVIDER},
|
2002-05-01 23:17:24 +04:00
|
|
|
{"&About FLUID...",0,about_cb},
|
1998-10-06 22:21:25 +04:00
|
|
|
{0},
|
|
|
|
{0}};
|
|
|
|
|
|
|
|
#define BROWSERWIDTH 300
|
|
|
|
#define BROWSERHEIGHT 500
|
|
|
|
#define WINWIDTH 300
|
2002-04-28 14:12:41 +04:00
|
|
|
#define MENUHEIGHT 25
|
1998-10-06 22:21:25 +04:00
|
|
|
#define WINHEIGHT (BROWSERHEIGHT+MENUHEIGHT)
|
|
|
|
|
|
|
|
extern void fill_in_New_Menu();
|
|
|
|
|
2005-03-20 03:51:02 +03:00
|
|
|
void scheme_cb(Fl_Choice *, void *) {
|
2005-07-15 13:48:09 +04:00
|
|
|
if (compile_only)
|
|
|
|
return;
|
|
|
|
|
2005-03-20 03:51:02 +03:00
|
|
|
switch (scheme_choice->value()) {
|
|
|
|
case 0 : // Default
|
|
|
|
Fl::scheme(NULL);
|
|
|
|
break;
|
|
|
|
case 1 : // None
|
|
|
|
Fl::scheme("none");
|
|
|
|
break;
|
|
|
|
case 2 : // Plastic
|
|
|
|
Fl::scheme("plastic");
|
|
|
|
break;
|
2006-09-17 18:58:25 +04:00
|
|
|
case 3 : // GTK+
|
|
|
|
Fl::scheme("gtk+");
|
|
|
|
break;
|
2005-03-20 03:51:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
fluid_prefs.set("scheme", scheme_choice->value());
|
|
|
|
}
|
|
|
|
|
2005-03-20 03:12:21 +03:00
|
|
|
void toggle_widgetbin_cb(Fl_Widget *, void *) {
|
|
|
|
if (!widgetbin_panel) {
|
|
|
|
make_widgetbin();
|
|
|
|
if (!position_window(widgetbin_panel,"widgetbin_pos", 1, 320, 30)) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widgetbin_panel->visible()) {
|
|
|
|
widgetbin_panel->hide();
|
2010-02-26 16:03:21 +03:00
|
|
|
widgetbin_item->label("Show Widget &Bin...");
|
2005-03-20 03:12:21 +03:00
|
|
|
} else {
|
|
|
|
widgetbin_panel->show();
|
2010-02-26 16:03:21 +03:00
|
|
|
widgetbin_item->label("Hide Widget &Bin");
|
2005-03-20 03:12:21 +03:00
|
|
|
}
|
|
|
|
}
|
2002-04-30 22:11:49 +04:00
|
|
|
|
2005-03-20 07:00:48 +03:00
|
|
|
|
2005-11-03 23:43:19 +03:00
|
|
|
void toggle_sourceview_cb(Fl_Double_Window *, void *) {
|
|
|
|
if (!sourceview_panel) {
|
|
|
|
make_sourceview();
|
|
|
|
sourceview_panel->callback((Fl_Callback*)toggle_sourceview_cb);
|
|
|
|
Fl_Preferences svp(fluid_prefs, "sourceview");
|
|
|
|
int autorefresh;
|
|
|
|
svp.get("autorefresh", autorefresh, 1);
|
|
|
|
sv_autorefresh->value(autorefresh);
|
|
|
|
int autoposition;
|
|
|
|
svp.get("autoposition", autoposition, 1);
|
|
|
|
sv_autoposition->value(autoposition);
|
|
|
|
int tab;
|
|
|
|
svp.get("tab", tab, 0);
|
|
|
|
if (tab>=0 && tab<sv_tab->children()) sv_tab->value(sv_tab->child(tab));
|
|
|
|
if (!position_window(sourceview_panel,"sourceview_pos", 0, 320, 120, 550, 500)) return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sourceview_panel->visible()) {
|
|
|
|
sourceview_panel->hide();
|
2010-02-26 16:03:21 +03:00
|
|
|
sourceview_item->label("Show Source Code...");
|
2005-11-03 23:43:19 +03:00
|
|
|
} else {
|
|
|
|
sourceview_panel->show();
|
2010-02-26 16:03:21 +03:00
|
|
|
sourceview_item->label("Hide Source Code...");
|
2005-11-03 23:43:19 +03:00
|
|
|
update_sourceview_cb(0,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void toggle_sourceview_b_cb(Fl_Button*, void *) {
|
|
|
|
toggle_sourceview_cb(0,0);
|
|
|
|
}
|
|
|
|
|
2005-03-20 03:12:21 +03:00
|
|
|
void make_main_window() {
|
2009-09-23 23:24:34 +04:00
|
|
|
if (!compile_only) {
|
|
|
|
fluid_prefs.get("snap", snap, 1);
|
|
|
|
fluid_prefs.get("gridx", gridx, 5);
|
|
|
|
fluid_prefs.get("gridy", gridy, 5);
|
|
|
|
fluid_prefs.get("show_guides", show_guides, 0);
|
|
|
|
fluid_prefs.get("widget_size", Fl_Widget_Type::default_size, 14);
|
|
|
|
fluid_prefs.get("show_comments", show_comments, 1);
|
|
|
|
make_layout_window();
|
|
|
|
make_shell_window();
|
|
|
|
}
|
2002-04-30 22:11:49 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
if (!main_window) {
|
|
|
|
Fl_Widget *o;
|
|
|
|
main_window = new Fl_Double_Window(WINWIDTH,WINHEIGHT,"fluid");
|
|
|
|
main_window->box(FL_NO_BOX);
|
|
|
|
o = make_widget_browser(0,MENUHEIGHT,BROWSERWIDTH,BROWSERHEIGHT);
|
|
|
|
o->box(FL_FLAT_BOX);
|
2001-09-30 02:59:45 +04:00
|
|
|
o->tooltip("Double-click to view or change an item.");
|
1998-10-06 22:21:25 +04:00
|
|
|
main_window->resizable(o);
|
2005-03-18 00:57:17 +03:00
|
|
|
main_menubar = new Fl_Menu_Bar(0,0,BROWSERWIDTH,MENUHEIGHT);
|
|
|
|
main_menubar->menu(Main_Menu);
|
2010-02-26 16:03:21 +03:00
|
|
|
// quick access to all dynamic menu items
|
|
|
|
save_item = (Fl_Menu_Item*)main_menubar->find_item(save_cb);
|
|
|
|
history_item = (Fl_Menu_Item*)main_menubar->find_item(open_history_cb);
|
|
|
|
widgetbin_item = (Fl_Menu_Item*)main_menubar->find_item(toggle_widgetbin_cb);
|
|
|
|
sourceview_item = (Fl_Menu_Item*)main_menubar->find_item((Fl_Callback*)toggle_sourceview_cb);
|
2005-03-18 00:57:17 +03:00
|
|
|
main_menubar->global();
|
1998-10-06 22:21:25 +04:00
|
|
|
fill_in_New_Menu();
|
|
|
|
main_window->end();
|
|
|
|
}
|
2010-02-26 16:03:21 +03:00
|
|
|
|
|
|
|
if (!compile_only) {
|
|
|
|
load_history();
|
2010-02-28 01:38:25 +03:00
|
|
|
make_settings_window();
|
2010-12-21 01:19:24 +03:00
|
|
|
make_global_settings_window();
|
2010-02-26 16:03:21 +03:00
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
|
2002-04-30 22:11:49 +04:00
|
|
|
// Load file history from preferences...
|
|
|
|
void load_history() {
|
|
|
|
int i; // Looping var
|
2005-03-24 20:45:50 +03:00
|
|
|
int max_files;
|
2002-04-30 22:11:49 +04:00
|
|
|
|
2005-03-24 20:45:50 +03:00
|
|
|
|
|
|
|
fluid_prefs.get("recent_files", max_files, 5);
|
|
|
|
if (max_files > 10) max_files = 10;
|
|
|
|
|
|
|
|
for (i = 0; i < max_files; i ++) {
|
2002-05-01 02:25:18 +04:00
|
|
|
fluid_prefs.get( Fl_Preferences::Name("file%d", i), absolute_history[i], "", sizeof(absolute_history[i]));
|
2002-04-30 22:11:49 +04:00
|
|
|
if (absolute_history[i][0]) {
|
|
|
|
// Make a relative version of the filename for the menu...
|
|
|
|
fl_filename_relative(relative_history[i], sizeof(relative_history[i]),
|
|
|
|
absolute_history[i]);
|
|
|
|
|
2010-02-26 16:03:21 +03:00
|
|
|
if (i == 9) history_item[i].flags = FL_MENU_DIVIDER;
|
|
|
|
else history_item[i].flags = 0;
|
2005-03-24 20:45:50 +03:00
|
|
|
} else break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; i < 10; i ++) {
|
2010-02-26 16:03:21 +03:00
|
|
|
if (i) history_item[i-1].flags |= FL_MENU_DIVIDER;
|
|
|
|
history_item[i].hide();
|
2002-04-30 22:11:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update file history from preferences...
|
2002-08-10 02:57:00 +04:00
|
|
|
void update_history(const char *flname) {
|
2002-04-30 22:11:49 +04:00
|
|
|
int i; // Looping var
|
2010-12-20 00:20:10 +03:00
|
|
|
char absolute[FL_PATH_MAX];
|
2005-03-24 20:45:50 +03:00
|
|
|
int max_files;
|
|
|
|
|
|
|
|
|
|
|
|
fluid_prefs.get("recent_files", max_files, 5);
|
|
|
|
if (max_files > 10) max_files = 10;
|
2002-04-30 22:11:49 +04:00
|
|
|
|
2002-08-10 02:57:00 +04:00
|
|
|
fl_filename_absolute(absolute, sizeof(absolute), flname);
|
2002-04-30 22:11:49 +04:00
|
|
|
|
2005-03-24 20:45:50 +03:00
|
|
|
for (i = 0; i < max_files; i ++)
|
2002-04-30 22:11:49 +04:00
|
|
|
#if defined(WIN32) || defined(__APPLE__)
|
|
|
|
if (!strcasecmp(absolute, absolute_history[i])) break;
|
|
|
|
#else
|
2002-05-02 01:41:59 +04:00
|
|
|
if (!strcmp(absolute, absolute_history[i])) break;
|
2002-04-30 22:11:49 +04:00
|
|
|
#endif // WIN32 || __APPLE__
|
|
|
|
|
|
|
|
if (i == 0) return;
|
|
|
|
|
2005-03-24 20:45:50 +03:00
|
|
|
if (i >= max_files) i = max_files - 1;
|
2002-04-30 22:11:49 +04:00
|
|
|
|
2002-08-10 02:57:00 +04:00
|
|
|
// Move the other flnames down in the list...
|
2002-04-30 22:11:49 +04:00
|
|
|
memmove(absolute_history + 1, absolute_history,
|
|
|
|
i * sizeof(absolute_history[0]));
|
|
|
|
memmove(relative_history + 1, relative_history,
|
|
|
|
i * sizeof(relative_history[0]));
|
|
|
|
|
|
|
|
// Put the new file at the top...
|
2002-05-16 16:47:44 +04:00
|
|
|
strlcpy(absolute_history[0], absolute, sizeof(absolute_history[0]));
|
2002-04-30 22:11:49 +04:00
|
|
|
|
|
|
|
fl_filename_relative(relative_history[0], sizeof(relative_history[0]),
|
|
|
|
absolute_history[0]);
|
|
|
|
|
|
|
|
// Update the menu items as needed...
|
2005-03-24 20:45:50 +03:00
|
|
|
for (i = 0; i < max_files; i ++) {
|
2002-05-01 02:25:18 +04:00
|
|
|
fluid_prefs.set( Fl_Preferences::Name("file%d", i), absolute_history[i]);
|
2005-03-25 05:39:25 +03:00
|
|
|
if (absolute_history[i][0]) {
|
2010-02-26 16:03:21 +03:00
|
|
|
if (i == 9) history_item[i].flags = FL_MENU_DIVIDER;
|
|
|
|
else history_item[i].flags = 0;
|
2005-03-25 05:39:25 +03:00
|
|
|
} else break;
|
2005-03-24 20:45:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
for (; i < 10; i ++) {
|
|
|
|
fluid_prefs.set( Fl_Preferences::Name("file%d", i), "");
|
2010-02-26 16:03:21 +03:00
|
|
|
if (i) history_item[i-1].flags |= FL_MENU_DIVIDER;
|
|
|
|
history_item[i].hide();
|
2002-04-30 22:11:49 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
// ********** portable process class definition **********
|
2002-05-01 14:36:08 +04:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
class Fl_Process {
|
|
|
|
public:
|
|
|
|
// construction / destruction
|
|
|
|
Fl_Process() {_fpt= NULL;}
|
|
|
|
~Fl_Process() {if (_fpt) close();}
|
2008-11-29 20:06:31 +03:00
|
|
|
|
2010-11-18 23:00:01 +03:00
|
|
|
// FIXME: popen needs the utf8 equivalen fl_popen
|
2008-09-02 16:03:30 +04:00
|
|
|
FILE * popen (const char *cmd, const char *mode="r");
|
2010-11-18 23:00:01 +03:00
|
|
|
//not necessary here: FILE * fl_fopen (const char *file, const char *mode="r");
|
2008-09-02 16:03:30 +04:00
|
|
|
int close();
|
|
|
|
|
|
|
|
FILE * desc() const { return _fpt;} // non null if file is open
|
|
|
|
char * get_line(char * line, size_t s) const {return _fpt ? fgets(line, s, _fpt) : NULL;}
|
|
|
|
|
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
|
|
|
protected:
|
|
|
|
HANDLE pin[2], pout[2], perr[2];
|
|
|
|
char ptmode;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
STARTUPINFO si;
|
|
|
|
|
|
|
|
static bool createPipe(HANDLE * h, BOOL bInheritHnd=TRUE);
|
|
|
|
|
|
|
|
private:
|
|
|
|
FILE * freeHandles() {
|
|
|
|
clean_close(pin[0]); clean_close(pin[1]);
|
|
|
|
clean_close(pout[0]); clean_close(pout[1]);
|
|
|
|
clean_close(perr[0]); clean_close(perr[1]);
|
|
|
|
return NULL; // convenient for error management
|
|
|
|
}
|
|
|
|
static void clean_close(HANDLE& h);
|
|
|
|
#endif
|
2002-05-01 14:36:08 +04:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
protected:
|
|
|
|
FILE * _fpt;
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
|
|
|
bool Fl_Process::createPipe(HANDLE * h, BOOL bInheritHnd) {
|
|
|
|
SECURITY_ATTRIBUTES sa;
|
|
|
|
sa.nLength = sizeof(sa);
|
|
|
|
sa.lpSecurityDescriptor = NULL;
|
2008-11-29 20:06:31 +03:00
|
|
|
sa.bInheritHandle = bInheritHnd;
|
2008-09-02 16:03:30 +04:00
|
|
|
return CreatePipe (&h[0],&h[1],&sa,0) ? true : false;
|
|
|
|
}
|
2008-11-29 20:06:31 +03:00
|
|
|
#endif
|
2008-09-02 16:03:30 +04:00
|
|
|
// portable open process:
|
|
|
|
FILE * Fl_Process::popen(const char *cmd, const char *mode) {
|
2008-11-29 20:06:31 +03:00
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
2008-09-02 16:03:30 +04:00
|
|
|
// PRECONDITIONS
|
|
|
|
if (!mode || !*mode || (*mode!='r' && *mode!='w') ) return NULL;
|
|
|
|
if (_fpt) close(); // close first before reuse
|
2008-11-29 20:06:31 +03:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
ptmode = *mode;
|
|
|
|
pin[0] = pin[1] = pout[0] = pout[1] = perr[0] = perr[1] = INVALID_HANDLE_VALUE;
|
|
|
|
// stderr to stdout wanted ?
|
|
|
|
int fusion = (strstr(cmd,"2>&1") !=NULL);
|
|
|
|
|
|
|
|
// Create windows pipes
|
|
|
|
if (!createPipe(pin) || !createPipe(pout) || (!fusion && !createPipe(perr) ) )
|
|
|
|
return freeHandles(); // error
|
|
|
|
|
|
|
|
// Initialize Startup Info
|
|
|
|
ZeroMemory(&si, sizeof(STARTUPINFO));
|
|
|
|
si.cb = sizeof(STARTUPINFO);
|
|
|
|
si.dwFlags = STARTF_USESTDHANDLES;
|
|
|
|
si.hStdInput = pin[0];
|
|
|
|
si.hStdOutput = pout[1];
|
|
|
|
si.hStdError = fusion ? pout[1] : perr [1];
|
|
|
|
|
|
|
|
if ( CreateProcess(NULL, (LPTSTR) cmd,NULL,NULL,TRUE,
|
|
|
|
DETACHED_PROCESS,NULL,NULL, &si, &pi)) {
|
|
|
|
// don't need theses handles inherited by child process:
|
2008-11-29 20:06:31 +03:00
|
|
|
clean_close(pin[0]); clean_close(pout[1]); clean_close(perr[1]);
|
2008-09-02 16:03:30 +04:00
|
|
|
HANDLE & h = *mode == 'r' ? pout[0] : pin[1];
|
2010-12-08 17:00:35 +03:00
|
|
|
_fpt = _fdopen(_open_osfhandle((fl_intptr_t) h,_O_BINARY),mode);
|
2008-11-29 20:06:31 +03:00
|
|
|
h= INVALID_HANDLE_VALUE; // reset the handle pointer that is shared
|
2008-09-02 16:03:30 +04:00
|
|
|
// with _fpt so we don't free it twice
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_fpt) freeHandles();
|
|
|
|
return _fpt;
|
2008-11-29 20:06:31 +03:00
|
|
|
#else
|
2008-09-02 16:03:30 +04:00
|
|
|
_fpt=::popen(cmd,mode);
|
|
|
|
return _fpt;
|
2008-11-29 20:06:31 +03:00
|
|
|
#endif
|
2008-09-02 16:03:30 +04:00
|
|
|
}
|
2002-05-01 14:36:08 +04:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
int Fl_Process::close() {
|
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
|
|
|
if (_fpt) {
|
|
|
|
fclose(_fpt);
|
|
|
|
clean_close(perr[0]);
|
|
|
|
clean_close(pin[1]);
|
|
|
|
clean_close(pout[0]);
|
|
|
|
_fpt = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return -1;
|
2008-11-29 20:06:31 +03:00
|
|
|
#else
|
2008-09-02 16:03:30 +04:00
|
|
|
int ret = ::pclose(_fpt);
|
|
|
|
_fpt=NULL;
|
|
|
|
return ret;
|
2008-11-29 20:06:31 +03:00
|
|
|
#endif
|
2008-09-02 16:03:30 +04:00
|
|
|
}
|
2003-04-01 23:58:08 +04:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
|
|
|
void Fl_Process::clean_close(HANDLE& h) {
|
|
|
|
if (h!= INVALID_HANDLE_VALUE) CloseHandle(h);
|
|
|
|
h = INVALID_HANDLE_VALUE;
|
2002-05-01 14:36:08 +04:00
|
|
|
}
|
2008-09-02 16:03:30 +04:00
|
|
|
#endif
|
|
|
|
// ********** Fl_Process class end **********
|
2002-05-01 14:36:08 +04:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
static Fl_Process s_proc;
|
2002-05-01 14:36:08 +04:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
// Shell command support...
|
2002-05-01 14:36:08 +04:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
static bool prepare_shell_command(const char * &command) { // common pre-shell command code all platforms
|
2002-05-01 14:36:08 +04:00
|
|
|
shell_window->hide();
|
2008-09-02 16:03:30 +04:00
|
|
|
if (s_proc.desc()) {
|
2002-11-01 03:32:05 +03:00
|
|
|
fl_alert("Previous shell command still running!");
|
2008-09-02 16:03:30 +04:00
|
|
|
return false;
|
2002-11-01 03:32:05 +03:00
|
|
|
}
|
2002-05-01 14:36:08 +04:00
|
|
|
if ((command = shell_command_input->value()) == NULL || !*command) {
|
|
|
|
fl_alert("No shell command entered!");
|
2008-09-02 16:03:30 +04:00
|
|
|
return false;
|
2002-05-01 14:36:08 +04:00
|
|
|
}
|
|
|
|
if (shell_savefl_button->value()) {
|
|
|
|
save_cb(0, 0);
|
|
|
|
}
|
|
|
|
if (shell_writecode_button->value()) {
|
|
|
|
compile_only = 1;
|
|
|
|
write_cb(0, 0);
|
|
|
|
compile_only = 0;
|
|
|
|
}
|
|
|
|
if (shell_writemsgs_button->value()) {
|
|
|
|
compile_only = 1;
|
|
|
|
write_strings_cb(0, 0);
|
|
|
|
compile_only = 0;
|
|
|
|
}
|
2008-09-02 16:03:30 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(__MWERKS__)
|
|
|
|
// Support the full piped shell command...
|
|
|
|
void
|
|
|
|
shell_pipe_cb(int, void*) {
|
|
|
|
char line[1024]=""; // Line from command output...
|
|
|
|
|
|
|
|
if (s_proc.get_line(line, sizeof(line)) != NULL) {
|
|
|
|
// Add the line to the output list...
|
|
|
|
shell_run_buffer->append(line);
|
|
|
|
} else {
|
|
|
|
// End of file; tell the parent...
|
|
|
|
Fl::remove_fd(fileno(s_proc.desc()));
|
|
|
|
s_proc.close();
|
|
|
|
shell_run_buffer->append("... END SHELL COMMAND ...\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
shell_run_display->scroll(shell_run_display->count_lines(0,
|
|
|
|
shell_run_buffer->length(), 1), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
do_shell_command(Fl_Return_Button*, void*) {
|
|
|
|
const char *command=NULL; // Command to run
|
|
|
|
|
|
|
|
if (!prepare_shell_command(command)) return;
|
2002-05-01 14:36:08 +04:00
|
|
|
|
|
|
|
// Show the output window and clear things...
|
2003-04-01 23:58:08 +04:00
|
|
|
shell_run_buffer->text("");
|
|
|
|
shell_run_buffer->append(command);
|
|
|
|
shell_run_buffer->append("\n");
|
2002-05-01 14:36:08 +04:00
|
|
|
shell_run_window->label("Shell Command Running...");
|
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
if (s_proc.popen((char *)command) == NULL) {
|
2002-05-01 14:36:08 +04:00
|
|
|
fl_alert("Unable to run shell command: %s", strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
shell_run_button->deactivate();
|
2003-04-01 23:58:08 +04:00
|
|
|
shell_run_window->hotspot(shell_run_display);
|
2002-05-01 14:36:08 +04:00
|
|
|
shell_run_window->show();
|
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
Fl::add_fd(fileno(s_proc.desc()), shell_pipe_cb);
|
2002-05-01 14:36:08 +04:00
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
while (s_proc.desc()) Fl::wait();
|
2002-05-01 14:36:08 +04:00
|
|
|
|
|
|
|
shell_run_button->activate();
|
|
|
|
shell_run_window->label("Shell Command Complete");
|
|
|
|
fl_beep();
|
|
|
|
|
|
|
|
while (shell_run_window->shown()) Fl::wait();
|
|
|
|
}
|
2002-05-01 14:44:55 +04:00
|
|
|
#else
|
|
|
|
// Just do basic shell command stuff, no status window...
|
|
|
|
void
|
|
|
|
do_shell_command(Fl_Return_Button*, void*) {
|
|
|
|
const char *command; // Command to run
|
|
|
|
int status; // Status from command...
|
|
|
|
|
2008-09-02 16:03:30 +04:00
|
|
|
if (!prepare_shell_command(command)) return;
|
2002-05-01 14:44:55 +04:00
|
|
|
|
|
|
|
if ((status = system(command)) != 0) {
|
|
|
|
fl_alert("Shell command returned status %d!", status);
|
|
|
|
} else if (completion_button->value()) {
|
|
|
|
fl_message("Shell command completed successfully!");
|
|
|
|
}
|
|
|
|
}
|
2008-09-02 16:03:30 +04:00
|
|
|
#endif // !__MWERKS__
|
2002-05-01 14:36:08 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
show_shell_window() {
|
|
|
|
shell_window->hotspot(shell_command_input);
|
|
|
|
shell_window->show();
|
|
|
|
}
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
void set_filename(const char *c) {
|
|
|
|
if (filename) free((void *)filename);
|
2005-03-19 11:38:21 +03:00
|
|
|
filename = c ? strdup(c) : NULL;
|
|
|
|
|
|
|
|
if (filename) update_history(filename);
|
2002-04-30 22:11:49 +04:00
|
|
|
|
2005-03-19 11:38:21 +03:00
|
|
|
set_modflag(modflag);
|
|
|
|
}
|
|
|
|
|
2005-11-03 23:43:19 +03:00
|
|
|
//
|
2008-11-29 20:06:31 +03:00
|
|
|
// The Source View system offers an immediate preview of the code
|
2005-11-03 23:43:19 +03:00
|
|
|
// files that will be generated by FLUID. It also marks the code
|
|
|
|
// generated for the last selected item in the header and the source
|
|
|
|
// file.
|
|
|
|
//
|
|
|
|
// Can we patent this? ;-) - Matt, mm@matthiasm.com
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
// Update the header and source code highlighting depending on the
|
|
|
|
// currently selected object
|
|
|
|
//
|
|
|
|
void update_sourceview_position()
|
|
|
|
{
|
2008-11-29 20:06:31 +03:00
|
|
|
if (!sourceview_panel || !sourceview_panel->visible())
|
2005-11-04 00:04:18 +03:00
|
|
|
return;
|
2008-11-29 20:06:31 +03:00
|
|
|
if (sv_autoposition->value()==0)
|
2005-11-03 23:43:19 +03:00
|
|
|
return;
|
|
|
|
if (sourceview_panel && sourceview_panel->visible() && Fl_Type::current) {
|
|
|
|
int pos0, pos1;
|
|
|
|
if (sv_source->visible_r()) {
|
2010-11-14 18:03:57 +03:00
|
|
|
pos0 = Fl_Type::current->code_position;
|
|
|
|
pos1 = Fl_Type::current->code_position_end;
|
2005-11-03 23:43:19 +03:00
|
|
|
if (pos0>=0) {
|
|
|
|
if (pos1<pos0)
|
|
|
|
pos1 = pos0;
|
|
|
|
sv_source->buffer()->highlight(pos0, pos1);
|
|
|
|
int line = sv_source->buffer()->count_lines(0, pos0);
|
|
|
|
sv_source->scroll(line, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (sv_header->visible_r()) {
|
2010-11-14 18:03:57 +03:00
|
|
|
pos0 = Fl_Type::current->header_position;
|
|
|
|
pos1 = Fl_Type::current->header_position_end;
|
2005-11-03 23:43:19 +03:00
|
|
|
if (pos0>=0) {
|
|
|
|
if (pos1<pos0)
|
|
|
|
pos1 = pos0;
|
|
|
|
sv_header->buffer()->highlight(pos0, pos1);
|
|
|
|
int line = sv_header->buffer()->count_lines(0, pos0);
|
|
|
|
sv_header->scroll(line, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-29 20:06:31 +03:00
|
|
|
void update_sourceview_position_cb(Fl_Tabs*, void*)
|
2005-11-03 23:43:19 +03:00
|
|
|
{
|
|
|
|
update_sourceview_position();
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *sv_source_filename = 0;
|
|
|
|
static char *sv_header_filename = 0;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Generate a header and source file in a temporary directory and
|
|
|
|
// load those into the Code Viewer widgets.
|
|
|
|
//
|
2008-11-29 20:06:31 +03:00
|
|
|
void update_sourceview_cb(Fl_Button*, void*)
|
2005-11-03 23:43:19 +03:00
|
|
|
{
|
2008-11-29 20:06:31 +03:00
|
|
|
if (!sourceview_panel || !sourceview_panel->visible())
|
2005-11-04 00:04:18 +03:00
|
|
|
return;
|
2005-11-03 23:43:19 +03:00
|
|
|
// generate space for the source and header file filenames
|
|
|
|
if (!sv_source_filename) {
|
|
|
|
sv_source_filename = (char*)malloc(FL_PATH_MAX);
|
|
|
|
fluid_prefs.getUserdataPath(sv_source_filename, FL_PATH_MAX);
|
|
|
|
strlcat(sv_source_filename, "source_view_tmp.cxx", FL_PATH_MAX);
|
|
|
|
}
|
|
|
|
if (!sv_header_filename) {
|
|
|
|
sv_header_filename = (char*)malloc(FL_PATH_MAX);
|
|
|
|
fluid_prefs.getUserdataPath(sv_header_filename, FL_PATH_MAX);
|
|
|
|
strlcat(sv_header_filename, "source_view_tmp.h", FL_PATH_MAX);
|
|
|
|
}
|
2005-11-04 18:16:24 +03:00
|
|
|
|
|
|
|
strlcpy(i18n_program, fl_filename_name(sv_source_filename), sizeof(i18n_program));
|
|
|
|
fl_filename_setext(i18n_program, sizeof(i18n_program), "");
|
|
|
|
const char *code_file_name_bak = code_file_name;
|
|
|
|
code_file_name = sv_source_filename;
|
|
|
|
const char *header_file_name_bak = header_file_name;
|
|
|
|
header_file_name = sv_header_filename;
|
|
|
|
|
2005-11-03 23:43:19 +03:00
|
|
|
// generate the code and load the files
|
2005-11-04 00:04:18 +03:00
|
|
|
write_sourceview = 1;
|
|
|
|
// generate files
|
2008-11-29 20:06:31 +03:00
|
|
|
if (write_code(sv_source_filename, sv_header_filename))
|
2005-11-03 23:43:19 +03:00
|
|
|
{
|
2005-11-04 00:04:18 +03:00
|
|
|
// load file into source editor
|
|
|
|
int pos = sv_source->top_line();
|
|
|
|
sv_source->buffer()->loadfile(sv_source_filename);
|
|
|
|
sv_source->scroll(pos, 0);
|
|
|
|
// load file into header editor
|
|
|
|
pos = sv_header->top_line();
|
|
|
|
sv_header->buffer()->loadfile(sv_header_filename);
|
|
|
|
sv_header->scroll(pos, 0);
|
|
|
|
// update the source code highlighting
|
|
|
|
update_sourceview_position();
|
|
|
|
}
|
|
|
|
write_sourceview = 0;
|
2005-11-04 18:16:24 +03:00
|
|
|
|
|
|
|
code_file_name = code_file_name_bak;
|
|
|
|
header_file_name = header_file_name_bak;
|
2005-11-03 23:43:19 +03:00
|
|
|
}
|
|
|
|
|
2008-11-29 20:06:31 +03:00
|
|
|
void update_sourceview_timer(void*)
|
2005-11-03 23:43:19 +03:00
|
|
|
{
|
|
|
|
update_sourceview_cb(0,0);
|
|
|
|
}
|
|
|
|
|
2005-03-19 11:38:21 +03:00
|
|
|
// Set the "modified" flag and update the title of the main window...
|
|
|
|
void set_modflag(int mf) {
|
|
|
|
const char *basename;
|
2010-12-20 00:20:10 +03:00
|
|
|
static char title[FL_PATH_MAX];
|
2005-03-19 11:38:21 +03:00
|
|
|
|
|
|
|
modflag = mf;
|
|
|
|
|
|
|
|
if (main_window) {
|
|
|
|
if (!filename) basename = "Untitled.fl";
|
|
|
|
else if ((basename = strrchr(filename, '/')) != NULL) basename ++;
|
2008-11-29 20:06:31 +03:00
|
|
|
#if defined(WIN32) || defined(__EMX__)
|
2005-03-19 11:38:21 +03:00
|
|
|
else if ((basename = strrchr(filename, '\\')) != NULL) basename ++;
|
|
|
|
#endif // WIN32 || __EMX__
|
|
|
|
else basename = filename;
|
|
|
|
|
|
|
|
if (modflag) {
|
|
|
|
snprintf(title, sizeof(title), "%s (modified)", basename);
|
|
|
|
main_window->label(title);
|
|
|
|
} else main_window->label(basename);
|
|
|
|
}
|
2005-11-03 23:43:19 +03:00
|
|
|
// if the UI was modified in any way, update the Source View panel
|
|
|
|
if (sourceview_panel && sourceview_panel->visible() && sv_autorefresh->value())
|
|
|
|
{
|
|
|
|
// we will only update ealiest 0.5 seconds after the last change, and only
|
|
|
|
// if no other change was made, so dragging a widget will not generate any
|
|
|
|
// CPU load
|
|
|
|
Fl::remove_timeout(update_sourceview_timer, 0);
|
|
|
|
Fl::add_timeout(0.5, update_sourceview_timer, 0);
|
|
|
|
}
|
2005-03-20 03:12:21 +03:00
|
|
|
|
2005-03-20 07:00:48 +03:00
|
|
|
// Enable/disable the Save menu item...
|
2010-02-26 16:03:21 +03:00
|
|
|
if (modflag) save_item->activate();
|
|
|
|
else save_item->deactivate();
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static int arg(int argc, char** argv, int& i) {
|
|
|
|
if (argv[i][1] == 'c' && !argv[i][2]) {compile_only = 1; i++; return 1;}
|
2000-06-08 12:26:45 +04:00
|
|
|
if (argv[i][1] == 'c' && argv[i][2] == 's' && !argv[i][3]) {compile_only = 1; compile_strings = 1; i++; return 1;}
|
1998-10-06 22:21:25 +04:00
|
|
|
if (argv[i][1] == 'o' && !argv[i][2] && i+1 < argc) {
|
1999-03-04 21:10:01 +03:00
|
|
|
code_file_name = argv[i+1];
|
|
|
|
code_file_set = 1;
|
|
|
|
i += 2;
|
|
|
|
return 2;
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
if (argv[i][1] == 'h' && !argv[i][2]) {
|
1999-03-04 21:10:01 +03:00
|
|
|
header_file_name = argv[i+1];
|
|
|
|
header_file_set = 1;
|
|
|
|
i += 2;
|
|
|
|
return 2;
|
|
|
|
}
|
2010-01-24 03:20:26 +03:00
|
|
|
Fl_Plugin_Manager pm("commandline");
|
|
|
|
int j, n = pm.plugins();
|
|
|
|
for (j=0; j<n; j++) {
|
|
|
|
Fl_Commandline_Plugin *pi = (Fl_Commandline_Plugin*)pm.plugin(j);
|
|
|
|
int r = pi->arg(argc, argv, i);
|
|
|
|
if (r) return r;
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-30 00:59:15 +03:00
|
|
|
#if ! (defined(WIN32) && !defined (__CYGWIN__))
|
1998-10-06 22:21:25 +04:00
|
|
|
|
2005-03-20 07:00:48 +03:00
|
|
|
int quit_flag = 0;
|
1998-10-06 22:21:25 +04:00
|
|
|
#include <signal.h>
|
|
|
|
#ifdef _sigargs
|
|
|
|
#define SIGARG _sigargs
|
|
|
|
#else
|
|
|
|
#ifdef __sigargs
|
|
|
|
#define SIGARG __sigargs
|
|
|
|
#else
|
|
|
|
#define SIGARG int // you may need to fix this for older systems
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2000-08-20 08:35:17 +04:00
|
|
|
extern "C" {
|
1998-10-06 22:21:25 +04:00
|
|
|
static void sigint(SIGARG) {
|
|
|
|
signal(SIGINT,sigint);
|
2005-03-20 07:00:48 +03:00
|
|
|
quit_flag = 1;
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
2000-08-20 08:35:17 +04:00
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
#endif
|
|
|
|
|
2010-01-24 03:20:26 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
int main(int argc,char **argv) {
|
|
|
|
int i = 1;
|
2010-01-24 03:20:26 +03:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
if (!Fl::args(argc,argv,i,arg) || i < argc-1) {
|
2011-01-07 00:36:04 +03:00
|
|
|
static const char *msg =
|
|
|
|
"usage: %s <switches> name.fl\n"
|
|
|
|
" -c : write .cxx and .h and exit\n"
|
|
|
|
" -cs : write .cxx and .h and strings and exit\n"
|
|
|
|
" -o <name> : .cxx output filename, or extension if <name> starts with '.'\n"
|
|
|
|
" -h <name> : .h output filename, or extension if <name> starts with '.'\n";
|
|
|
|
int len = strlen(msg) + strlen(argv[0]) + strlen(Fl::help);
|
2010-01-24 03:20:26 +03:00
|
|
|
Fl_Plugin_Manager pm("commandline");
|
|
|
|
int i, n = pm.plugins();
|
|
|
|
for (i=0; i<n; i++) {
|
|
|
|
Fl_Commandline_Plugin *pi = (Fl_Commandline_Plugin*)pm.plugin(i);
|
2011-01-07 00:36:04 +03:00
|
|
|
if (pi) len += strlen(pi->help());
|
2010-01-24 03:20:26 +03:00
|
|
|
}
|
2011-01-07 00:36:04 +03:00
|
|
|
char *buf = (char*)malloc(len+1);
|
|
|
|
sprintf(buf, msg, argv[0]);
|
|
|
|
for (i=0; i<n; i++) {
|
|
|
|
Fl_Commandline_Plugin *pi = (Fl_Commandline_Plugin*)pm.plugin(i);
|
|
|
|
if (pi) strcat(buf, pi->help());
|
|
|
|
}
|
|
|
|
strcat(buf, Fl::help);
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
fl_message("%s\n", buf);
|
|
|
|
#else
|
|
|
|
fprintf(stderr, "%s\n", buf);
|
|
|
|
#endif
|
|
|
|
free(buf);
|
1998-10-06 22:21:25 +04:00
|
|
|
return 1;
|
|
|
|
}
|
2010-01-24 03:20:26 +03:00
|
|
|
if (exit_early)
|
|
|
|
exit(0);
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
const char *c = argv[i];
|
2002-08-17 00:10:21 +04:00
|
|
|
|
|
|
|
fl_register_images();
|
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
make_main_window();
|
2002-09-02 14:41:51 +04:00
|
|
|
|
2003-06-01 04:23:57 +04:00
|
|
|
|
1998-10-06 22:21:25 +04:00
|
|
|
if (c) set_filename(c);
|
|
|
|
if (!compile_only) {
|
2010-12-01 21:31:23 +03:00
|
|
|
#ifdef __APPLE__
|
|
|
|
fl_open_callback(apple_open_cb);
|
|
|
|
#endif // __APPLE__
|
1998-10-06 22:21:25 +04:00
|
|
|
Fl::visual((Fl_Mode)(FL_DOUBLE|FL_INDEX));
|
2001-09-30 02:59:45 +04:00
|
|
|
Fl_File_Icon::load_system_icons();
|
1998-10-06 22:21:25 +04:00
|
|
|
main_window->callback(exit_cb);
|
2002-11-03 03:01:21 +03:00
|
|
|
position_window(main_window,"main_window_pos", 1, 10, 30, WINWIDTH, WINHEIGHT );
|
1998-10-06 22:21:25 +04:00
|
|
|
main_window->show(argc,argv);
|
2002-11-03 03:01:21 +03:00
|
|
|
toggle_widgetbin_cb(0,0);
|
2005-11-03 23:43:19 +03:00
|
|
|
toggle_sourceview_cb(0,0);
|
2002-04-30 22:11:49 +04:00
|
|
|
if (!c && openlast_button->value() && absolute_history[0][0]) {
|
|
|
|
// Open previous file when no file specified...
|
|
|
|
open_history_cb(0, absolute_history[0]);
|
|
|
|
}
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_suspend();
|
1998-10-06 22:21:25 +04:00
|
|
|
if (c && !read_file(c,0)) {
|
|
|
|
if (compile_only) {
|
|
|
|
fprintf(stderr,"%s : %s\n", c, strerror(errno));
|
|
|
|
exit(1);
|
|
|
|
}
|
1998-11-05 19:04:53 +03:00
|
|
|
fl_message("Can't read %s: %s", c, strerror(errno));
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_resume();
|
2002-05-01 23:17:24 +04:00
|
|
|
if (compile_only) {
|
|
|
|
if (compile_strings) write_strings_cb(0,0);
|
|
|
|
write_cb(0,0);
|
|
|
|
exit(0);
|
|
|
|
}
|
2005-03-19 11:38:21 +03:00
|
|
|
set_modflag(0);
|
2005-03-20 07:00:48 +03:00
|
|
|
undo_clear();
|
1998-10-06 22:21:25 +04:00
|
|
|
#ifndef WIN32
|
|
|
|
signal(SIGINT,sigint);
|
|
|
|
#endif
|
2002-05-01 23:17:24 +04:00
|
|
|
|
|
|
|
grid_cb(horizontal_input, 0); // Makes sure that windows get snap params...
|
|
|
|
|
2005-03-20 07:00:48 +03:00
|
|
|
#ifdef WIN32
|
|
|
|
Fl::run();
|
|
|
|
#else
|
|
|
|
while (!quit_flag) Fl::wait();
|
|
|
|
|
|
|
|
if (quit_flag) exit_cb(0,0);
|
|
|
|
#endif // WIN32
|
|
|
|
|
|
|
|
undo_clear();
|
|
|
|
|
|
|
|
return (0);
|
1998-10-06 22:21:25 +04:00
|
|
|
}
|
1998-10-21 20:29:01 +04:00
|
|
|
|
|
|
|
//
|
2005-02-06 19:28:36 +03:00
|
|
|
// End of "$Id$".
|
1998-10-21 20:29:01 +04:00
|
|
|
//
|