summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>1999-01-04 19:25:40 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>1999-01-04 19:25:40 +0000
commitb95db33f2cbd30213cadd4859f567e1dae32ef47 (patch)
treea28848521b20e06870490ebacf7bd22e3aa6dedc /src
parentea2cbbd5530915c508e86fed9a437adb0b2149f8 (diff)
Lots of changes:
- Added #defines for Visual C++ to speed up compiles. - Added FLTK.DLL project to visualc directory. - Added editor project to visualc directory. - Added icon() method to Fl_Window class. - Implemented xclass() method for WIN32. - Fixed extern declaration of fl_send_extra_move in Fl_Menu_Window.cxx. - scandir_win32.c needed to include <stdlib.h>. - Added fix from Bill for fl_width() bug. - Updated fix for Fl_Input to default to FL_DOWN_BOX. - Added visible() check for children of Fl_Pack. - Added WinMain() function to library. - Now show console window in debug mode. - Fixed demo.menu and demo.cxx to work under WIN32. git-svn-id: file:///fltk/svn/fltk/trunk@180 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Input.cxx5
-rw-r--r--src/Fl_Input_.cxx6
-rw-r--r--src/Fl_Menu_Window.cxx6
-rw-r--r--src/Fl_Pack.cxx66
-rw-r--r--src/Fl_Window.cxx5
-rw-r--r--src/Fl_win32.cxx105
-rw-r--r--src/Fl_x.cxx13
-rw-r--r--src/dummymain.c33
-rw-r--r--src/fl_font.cxx6
-rw-r--r--src/scandir_win32.c5
10 files changed, 167 insertions, 83 deletions
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx
index 4f3a7aa98..bdf1c5877 100644
--- a/src/Fl_Input.cxx
+++ b/src/Fl_Input.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Input.cxx,v 1.6 1998/12/29 14:30:23 mike Exp $"
+// "$Id: Fl_Input.cxx,v 1.7 1999/01/04 19:24:59 mike Exp $"
//
// Input widget for the Fast Light Tool Kit (FLTK).
//
@@ -320,9 +320,8 @@ int Fl_Input::handle(int event) {
Fl_Input::Fl_Input(int x, int y, int w, int h, const char *l)
: Fl_Input_(x, y, w, h, l) {
- box(FL_DOWN_BOX);
}
//
-// End of "$Id: Fl_Input.cxx,v 1.6 1998/12/29 14:30:23 mike Exp $".
+// End of "$Id: Fl_Input.cxx,v 1.7 1999/01/04 19:24:59 mike Exp $".
//
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index c40e76027..22a37a080 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Input_.cxx,v 1.11 1998/12/29 14:05:12 mike Exp $"
+// "$Id: Fl_Input_.cxx,v 1.12 1999/01/04 19:24:59 mike Exp $"
//
// Common input widget routines for the Fast Light Tool Kit (FLTK).
//
@@ -632,7 +632,7 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) {
Fl_Input_::Fl_Input_(int x, int y, int w, int h, const char* l)
: Fl_Widget(x, y, w, h, l) {
- box(FL_NO_BOX);
+ box(FL_DOWN_BOX);
color(FL_WHITE, FL_SELECTION_COLOR);
align(FL_ALIGN_LEFT);
textsize_ = FL_NORMAL_SIZE;
@@ -728,5 +728,5 @@ Fl_Input_::~Fl_Input_() {
}
//
-// End of "$Id: Fl_Input_.cxx,v 1.11 1998/12/29 14:05:12 mike Exp $".
+// End of "$Id: Fl_Input_.cxx,v 1.12 1999/01/04 19:24:59 mike Exp $".
//
diff --git a/src/Fl_Menu_Window.cxx b/src/Fl_Menu_Window.cxx
index 031d777d3..9442342d2 100644
--- a/src/Fl_Menu_Window.cxx
+++ b/src/Fl_Menu_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Menu_Window.cxx,v 1.5 1998/12/15 15:38:16 mike Exp $"
+// "$Id: Fl_Menu_Window.cxx,v 1.6 1999/01/04 19:25:00 mike Exp $"
//
// Menu window code for the Fast Light Tool Kit (FLTK).
//
@@ -137,7 +137,7 @@ void Fl::grab(Fl_Window& w) {
#endif
}
-extern fl_send_extra_move(); // in Fl.cxx
+extern void fl_send_extra_move(); // in Fl.cxx
void Fl::release() {
grab_ = 0;
@@ -156,5 +156,5 @@ void Fl::release() {
}
//
-// End of "$Id: Fl_Menu_Window.cxx,v 1.5 1998/12/15 15:38:16 mike Exp $".
+// End of "$Id: Fl_Menu_Window.cxx,v 1.6 1999/01/04 19:25:00 mike Exp $".
//
diff --git a/src/Fl_Pack.cxx b/src/Fl_Pack.cxx
index 6ee605d6b..e5717c1c5 100644
--- a/src/Fl_Pack.cxx
+++ b/src/Fl_Pack.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Pack.cxx,v 1.4 1998/10/21 14:20:16 mike Exp $"
+// "$Id: Fl_Pack.cxx,v 1.5 1999/01/04 19:25:01 mike Exp $"
//
// Packing widget for the Fast Light Tool Kit (FLTK).
//
@@ -50,37 +50,40 @@ void Fl_Pack::draw() {
Fl_Widget*const* a = array();
for (int i = children(); i--;) {
Fl_Widget* o = *a++;
- int X,Y,W,H;
- if (horizontal()) {
- X = current_position;
- W = o->w();
- Y = ty;
- H = th;
- } else {
- X = tx;
- W = tw;
- Y = current_position;
- H = o->h();
+ if (o->visible()) {
+ int X,Y,W,H;
+ if (horizontal()) {
+ X = current_position;
+ W = o->w();
+ Y = ty;
+ H = th;
+ } else {
+ X = tx;
+ W = tw;
+ Y = current_position;
+ H = o->h();
+ }
+ if (spacing_ && current_position>maximum_position &&
+ (X != o->x() || Y != o->y() || d&FL_DAMAGE_ALL)) {
+ fl_color(color());
+ if (horizontal())
+ fl_rectf(maximum_position, ty, spacing_, th);
+ else
+ fl_rectf(tx, maximum_position, tw, spacing_);
+ }
+ if (X != o->x() || Y != o->y() || W != o->w() || H != o->h()) {
+ o->resize(X,Y,W,H);
+ o->clear_damage(FL_DAMAGE_ALL);
+ }
+ if (d&FL_DAMAGE_ALL) draw_child(*o); else update_child(*o);
+ // child's draw() can change it's size, so use new size:
+ current_position += (horizontal() ? o->w() : o->h());
+ if (current_position > maximum_position)
+ maximum_position = current_position;
+ current_position += spacing_;
}
- if (spacing_ && current_position>maximum_position &&
- (X != o->x() || Y != o->y() || d&FL_DAMAGE_ALL)) {
- fl_color(color());
- if (horizontal())
- fl_rectf(maximum_position, ty, spacing_, th);
- else
- fl_rectf(tx, maximum_position, tw, spacing_);
- }
- if (X != o->x() || Y != o->y() || W != o->w() || H != o->h()) {
- o->resize(X,Y,W,H);
- o->clear_damage(FL_DAMAGE_ALL);
- }
- if (d&FL_DAMAGE_ALL) draw_child(*o); else update_child(*o);
- // child's draw() can change it's size, so use new size:
- current_position += (horizontal() ? o->w() : o->h());
- if (current_position > maximum_position)
- maximum_position = current_position;
- current_position += spacing_;
}
+
if (horizontal()) {
if (maximum_position < tx+tw) {
fl_color(color());
@@ -94,6 +97,7 @@ void Fl_Pack::draw() {
}
th = maximum_position-ty;
}
+
tw += Fl::box_dw(box()); if (tw <= 0) tw = 1;
th += Fl::box_dh(box()); if (th <= 0) th = 1;
if (tw != w() || th != h()) {Fl_Widget::resize(x(),y(),tw,th); d = FL_DAMAGE_ALL;}
@@ -101,5 +105,5 @@ void Fl_Pack::draw() {
}
//
-// End of "$Id: Fl_Pack.cxx,v 1.4 1998/10/21 14:20:16 mike Exp $".
+// End of "$Id: Fl_Pack.cxx,v 1.5 1999/01/04 19:25:01 mike Exp $".
//
diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx
index 137173afa..fa5628de5 100644
--- a/src/Fl_Window.cxx
+++ b/src/Fl_Window.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Window.cxx,v 1.3 1998/10/21 14:20:27 mike Exp $"
+// "$Id: Fl_Window.cxx,v 1.4 1999/01/04 19:25:02 mike Exp $"
//
// Window widget class for the Fast Light Tool Kit (FLTK).
//
@@ -37,6 +37,7 @@ void Fl_Window::_Fl_Window() {
labeltype(FL_NO_LABEL);
i = 0;
xclass_ = 0;
+ icon_ = 0;
iconlabel_ = 0;
resizable(0);
size_range_set = 0;
@@ -101,5 +102,5 @@ void Fl_Window::default_callback(Fl_Window* window, void* v) {
}
//
-// End of "$Id: Fl_Window.cxx,v 1.3 1998/10/21 14:20:27 mike Exp $".
+// End of "$Id: Fl_Window.cxx,v 1.4 1999/01/04 19:25:02 mike Exp $".
//
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 31583d2c4..2ac90f890 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_win32.cxx,v 1.19 1998/12/08 21:08:50 mike Exp $"
+// "$Id: Fl_win32.cxx,v 1.20 1999/01/04 19:25:02 mike Exp $"
//
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
//
@@ -32,6 +32,8 @@
#include <FL/win32.H>
#include <FL/Fl_Window.H>
#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
////////////////////////////////////////////////////////////////
// interface to poll/select call:
@@ -508,28 +510,29 @@ int fl_disable_transient_for; // secret method of removing TRANSIENT_FOR
Fl_X* Fl_X::make(Fl_Window* w) {
Fl_Group::current(0); // get rid of very common user bug: forgot end()
- static char* class_name;
- if (!class_name) { // create a single WNDCLASS used for everything:
- class_name = "FLTK";
- WNDCLASSEX wc;
- // Documentation states a device context consumes about 800 bytes
- // of memory... so who cares? If 800 bytes per window is what it
- // takes to speed things up, I'm game.
- //wc.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC | CS_DBLCLKS;
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
- wc.lpfnWndProc = (WNDPROC)WndProc;
- wc.cbClsExtra = wc.cbWndExtra = 0;
- wc.hInstance = fl_display;
- wc.hIcon = wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = fl_default_cursor = LoadCursor(NULL, IDC_ARROW);
- //uchar r,g,b; Fl::get_color(FL_GRAY,r,g,b);
- //wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(r,g,b));
- wc.hbrBackground = NULL;
- wc.lpszMenuName = NULL;
- wc.lpszClassName = class_name;
- wc.cbSize = sizeof(WNDCLASSEX);
- RegisterClassEx(&wc);
- }
+ const char* class_name = w->xclass();
+ if (!class_name) class_name = "FLTK"; // create a "FLTK" WNDCLASS
+
+ WNDCLASSEX wc;
+ // Documentation states a device context consumes about 800 bytes
+ // of memory... so who cares? If 800 bytes per window is what it
+ // takes to speed things up, I'm game.
+ //wc.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC | CS_DBLCLKS;
+ wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS;
+ wc.lpfnWndProc = (WNDPROC)WndProc;
+ wc.cbClsExtra = wc.cbWndExtra = 0;
+ wc.hInstance = fl_display;
+ if (!w->icon())
+ w->icon((void *)LoadIcon(NULL, IDI_APPLICATION));
+ wc.hIcon = wc.hIconSm = (HICON)w->icon();
+ wc.hCursor = fl_default_cursor = LoadCursor(NULL, IDC_ARROW);
+ //uchar r,g,b; Fl::get_color(FL_GRAY,r,g,b);
+ //wc.hbrBackground = (HBRUSH)CreateSolidBrush(RGB(r,g,b));
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = class_name;
+ wc.cbSize = sizeof(WNDCLASSEX);
+ RegisterClassEx(&wc);
HWND parent;
DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
@@ -615,8 +618,6 @@ Fl_X* Fl_X::make(Fl_Window* w) {
x->next = Fl_X::first;
Fl_X::first = x;
- // use w->xclass() to set the icon...
-
x->wait_for_expose = 1;
w->set_visible();
w->handle(FL_SHOW); // get child windows to appear
@@ -632,18 +633,54 @@ Fl_X* Fl_X::make(Fl_Window* w) {
////////////////////////////////////////////////////////////////
-HINSTANCE fl_display;
+HINSTANCE fl_display = 0;
+
+extern "C" {
+extern int __argc;
+extern char **__argv;
+extern int main(int argc, char *argv[]);
+extern int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine, int nCmdShow);
+}
+
+//
+// This WinMain() function can be overridden by an application and
+// is provided for compatibility with programs written for other
+// operating systems that conform to the ANSI standard entry point
+// "main()". This will allow you to build a WIN32 Application
+// without any special settings.
+//
+// Currently the debug version of this library will create a
+// console window for your application so you can put printf()
+// statements for debugging or informational purposes. Ultimately
+// we want to update this to always use the parent's console,
+// but at present we have not identified a function or API in
+// Microsoft(r) Windows(r) that allows for it.
+//
-int Fl_WinMain(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow,
- int (*mainp)(int, char**)) {
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine, int nCmdShow) {
+ // Save the current instance in the fl_display variable...
fl_display = hInstance;
- int argc;
- char **argv;
- // test version for now:
- argc = 1; char* testargv[] = {"test", 0}; argv = testargv;
+#ifdef _DEBUG
+ // If we are using compiling in debug mode, open a console window so
+ // we can see any printf's, etc...
+ //
+ // While we can detect if the program was run from the command-line -
+ // look at the CMDLINE environment variable, it will be "WIN" for
+ // programs started from the GUI - the shell seems to run all WIN32
+ // applications in the background anyways...
+
+ AllocConsole();
+ freopen("conin$", "r", stdin);
+ freopen("conout$", "w", stdout);
+ freopen("conout$", "w", stderr);
+#endif // _DEBUG
+
+ // Run the standard main entry point function...
- return mainp(argc, argv);
+ return main(__argc, __argv);
}
////////////////////////////////////////////////////////////////
@@ -760,5 +797,5 @@ void Fl_Window::make_current() {
}
//
-// End of "$Id: Fl_win32.cxx,v 1.19 1998/12/08 21:08:50 mike Exp $".
+// End of "$Id: Fl_win32.cxx,v 1.20 1999/01/04 19:25:02 mike Exp $".
//
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index 6f2383afd..49613f267 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_x.cxx,v 1.17 1998/12/29 14:08:07 mike Exp $"
+// "$Id: Fl_x.cxx,v 1.18 1999/01/04 19:25:03 mike Exp $"
//
// X specific code for the Fast Light Tool Kit (FLTK).
//
@@ -656,6 +656,15 @@ void Fl_X::make_xid(Fl_Window* w, XVisualInfo *visual, Colormap colormap)
(unsigned char *)buffer, p-buffer-1);
}
+ // Set the icon pixmap as needed:
+ if (w->icon()) {
+ XWMHints hints;
+
+ hints.icon_pixmap = (Pixmap)w->icon();
+ hints.flags = IconPixmapHint;
+ XSetWMHints(fl_display, x->xid, &hints);
+ }
+
if (w->non_modal() && x->next && !fl_disable_transient_for) {
// find some other window to be "transient for":
Fl_Window* w = x->next->w;
@@ -818,5 +827,5 @@ void Fl_Window::make_current() {
#endif
//
-// End of "$Id: Fl_x.cxx,v 1.17 1998/12/29 14:08:07 mike Exp $".
+// End of "$Id: Fl_x.cxx,v 1.18 1999/01/04 19:25:03 mike Exp $".
//
diff --git a/src/dummymain.c b/src/dummymain.c
new file mode 100644
index 000000000..004f4d491
--- /dev/null
+++ b/src/dummymain.c
@@ -0,0 +1,33 @@
+/*
+ * "$Id: dummymain.c,v 1.1 1999/01/04 19:25:04 mike Exp $"
+ *
+ * Dummy main() entry routine for the Fast Light Tool Kit (FLTK).
+ * This is only used to build the WIN32 DLL.
+ *
+ * Copyright 1998 by Bill Spitzak and others.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ *
+ * Please report all bugs and problems to "fltk-bugs@easysw.com".
+ */
+
+#ifdef WIN32
+int main(int argc, char **argv) { return 0; }
+#endif /* WIN32 */
+
+/*
+ * End of "$Id: dummymain.c,v 1.1 1999/01/04 19:25:04 mike Exp $".
+ */
diff --git a/src/fl_font.cxx b/src/fl_font.cxx
index 63a2d33d3..883f15c24 100644
--- a/src/fl_font.cxx
+++ b/src/fl_font.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_font.cxx,v 1.7 1998/12/07 13:36:26 mike Exp $"
+// "$Id: fl_font.cxx,v 1.8 1999/01/04 19:25:05 mike Exp $"
//
// Font selection code for the Fast Light Tool Kit (FLTK).
//
@@ -272,7 +272,7 @@ double fl_width(uchar c) {
int a = fl_xfont->min_char_or_byte2;
int b = fl_xfont->max_char_or_byte2 - a;
int x = c-a;
- if (x >= 0 && x <= b) return p[c].width;
+ if (x >= 0 && x <= b) return p[x].width;
}
return fl_xfont->min_bounds.width;
}
@@ -292,5 +292,5 @@ void fl_draw(const char* str, int x, int y) {
#endif
//
-// End of "$Id: fl_font.cxx,v 1.7 1998/12/07 13:36:26 mike Exp $".
+// End of "$Id: fl_font.cxx,v 1.8 1999/01/04 19:25:05 mike Exp $".
//
diff --git a/src/scandir_win32.c b/src/scandir_win32.c
index 9280a76f1..191973637 100644
--- a/src/scandir_win32.c
+++ b/src/scandir_win32.c
@@ -1,5 +1,5 @@
//
-// "$Id: scandir_win32.c,v 1.9 1998/12/08 22:07:30 mike Exp $"
+// "$Id: scandir_win32.c,v 1.10 1999/01/04 19:25:06 mike Exp $"
//
// WIN32 scandir function for the Fast Light Tool Kit (FLTK).
//
@@ -28,6 +28,7 @@
#include <config.h>
#include <string.h>
#include <windows.h>
+#include <stdlib.h>
struct dirent { char d_name[1]; };
@@ -97,5 +98,5 @@ int alphasort (struct dirent **a, struct dirent **b) {
}
//
-// End of "$Id: scandir_win32.c,v 1.9 1998/12/08 22:07:30 mike Exp $".
+// End of "$Id: scandir_win32.c,v 1.10 1999/01/04 19:25:06 mike Exp $".
//