mirror of https://github.com/fltk/fltk
Put Fl::grab() into it's own source file. Rewritten as suggested so that
it takes a window pointer, and grab(0) releases. You can now call grab repeatedly with the same or different values without it failing. The old Fl::grab() and Fl::release() are emulated in inline functions in Fl.H Added Fl_Menu_::copy(Fl_Menu_Item*), which will be useful for fluid, although that use is nyi. Fixes and cleanup to the code for Fl_Menu_::add(...). git-svn-id: file:///fltk/svn/fltk/trunk@268 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
0434a826d5
commit
8009fef12c
9
FL/Fl.H
9
FL/Fl.H
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl.H,v 1.4 1999/01/07 19:16:50 mike Exp $"
|
||||
// "$Id: Fl.H,v 1.5 1999/02/03 08:43:29 bill Exp $"
|
||||
//
|
||||
// Main header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -104,8 +104,7 @@ public:
|
|||
static Fl_Window* next_window(const Fl_Window*);
|
||||
static Fl_Window* modal() {return modal_;}
|
||||
static Fl_Window* grab() {return grab_;}
|
||||
static void grab(Fl_Window&);
|
||||
static void release();
|
||||
static void grab(Fl_Window*);
|
||||
|
||||
// event information:
|
||||
static int event_x() {return e_x;}
|
||||
|
@ -192,11 +191,13 @@ public:
|
|||
static int event_button2() {return e_state&FL_BUTTON2;}
|
||||
static int event_button3() {return e_state&FL_BUTTON3;}
|
||||
static void set_idle(void (*cb)()) {idle = cb;}
|
||||
static void grab(Fl_Window&w) {grab(&w);}
|
||||
static void release() {grab(0);}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl.H,v 1.4 1999/01/07 19:16:50 mike Exp $".
|
||||
// End of "$Id: Fl.H,v 1.5 1999/02/03 08:43:29 bill Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_Menu_.H,v 1.5 1999/01/07 19:16:57 mike Exp $"
|
||||
// "$Id: Fl_Menu_.H,v 1.6 1999/02/03 08:43:30 bill Exp $"
|
||||
//
|
||||
// Menu base class header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -55,6 +55,7 @@ public:
|
|||
|
||||
const Fl_Menu_Item *menu() const {return menu_;}
|
||||
void menu(const Fl_Menu_Item *m);
|
||||
void copy(const Fl_Menu_Item *m, void* user_data = 0);
|
||||
int add(const char*, int shortcut, Fl_Callback*, void* = 0, int = 0);
|
||||
int add(const char* a, const char* b, Fl_Callback* c,
|
||||
void* d = 0, int e = 0) {return add(a,fl_old_shortcut(b),c,d,e);}
|
||||
|
@ -92,5 +93,5 @@ public:
|
|||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu_.H,v 1.5 1999/01/07 19:16:57 mike Exp $".
|
||||
// End of "$Id: Fl_Menu_.H,v 1.6 1999/02/03 08:43:30 bill Exp $".
|
||||
//
|
||||
|
|
22
FL/fl_draw.H
22
FL/fl_draw.H
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: fl_draw.H,v 1.6 1999/01/07 19:17:06 mike Exp $"
|
||||
// "$Id: fl_draw.H,v 1.7 1999/02/03 08:43:30 bill Exp $"
|
||||
//
|
||||
// Portable drawing function header file for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -42,6 +42,24 @@ void fl_pop_clip();
|
|||
int fl_not_clipped(int x, int y, int w, int h);
|
||||
int fl_clip_box(int, int, int, int, int& x, int& y, int& w, int& h);
|
||||
|
||||
// line style:
|
||||
// Enumerations chosen so zero is the default, unfortunatly this does
|
||||
// not match values for either X or Windows...
|
||||
enum Fl_LineStyle {
|
||||
FL_SOLID = 0,
|
||||
FL_DASH = 1,
|
||||
FL_DOT = 2,
|
||||
FL_DASHDOT = 3,
|
||||
FL_DASHDOTDOT = 4,
|
||||
FL_CAP_FLAT = 0x0100,
|
||||
FL_CAP_ROUND = 0x0200,
|
||||
FL_CAP_SQUARE = 0x0300,
|
||||
FL_JOIN_MITER = 0x1000,
|
||||
FL_JOIN_ROUND = 0x2000,
|
||||
FL_JOIN_BEVEL = 0x3000,
|
||||
};
|
||||
void fl_line_style(int style, int width = 0, char* dashes = 0);
|
||||
|
||||
// points:
|
||||
void fl_point(int x, int y);
|
||||
|
||||
|
@ -158,5 +176,5 @@ int fl_add_symbol(const char* name, void (*drawit)(Fl_Color), int scalable);
|
|||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: fl_draw.H,v 1.6 1999/01/07 19:17:06 mike Exp $".
|
||||
// End of "$Id: fl_draw.H,v 1.7 1999/02/03 08:43:30 bill Exp $".
|
||||
//
|
||||
|
|
|
@ -40,20 +40,21 @@ methods to build it dynamically. </P>
|
|||
</UL>
|
||||
</TD><TD align=left valign=top>
|
||||
<UL>
|
||||
<LI><A href=#Fl_Menu_.copy>copy</A></LI>
|
||||
<LI><A href=#Fl_Menu_.down_box>down_box</A></LI>
|
||||
<LI><A href=#Fl_Menu_.global>global</A></LI>
|
||||
<LI><A href=#Fl_Menu_.menu>menu</A></LI>
|
||||
<LI><A href=#Fl_Menu_.mode>mode</A></LI>
|
||||
</UL>
|
||||
</TD><TD align=left valign=top>
|
||||
<UL>
|
||||
<LI><A href=#Fl_Menu_.mode>mode</A></LI>
|
||||
<LI><A href=#Fl_Menu_.remove>remove</A></LI>
|
||||
<LI><A href=#Fl_Menu_.replace>replace</A></LI>
|
||||
<LI><A href=#Fl_Menu_.shortcut>shortcut</A></LI>
|
||||
<LI><A href=#Fl_Menu_.size>size</A></LI>
|
||||
</UL>
|
||||
</TD><TD align=left valign=top>
|
||||
<UL>
|
||||
<LI><A href=#Fl_Menu_.size>size</A></LI>
|
||||
<LI><A href=#Fl_Menu_.test_shortcut>test_shortcut</A></LI>
|
||||
<LI><A href=#Fl_Menu_.text>text</A></LI>
|
||||
<LI><A href=#Fl_Menu_.textcolor>textcolor</A></LI>
|
||||
|
@ -77,6 +78,9 @@ and label string. The default boxtype is <TT>FL_NO_BOX</TT>.
|
|||
<BR> void Fl_Menu_::menu(const Fl_Menu_Item*)</A></H4>
|
||||
Get or set the menu array directly. Setting it to <TT>NULL</TT>
|
||||
indicates that you want the widget to allocate its own array.
|
||||
<H4><A name=Fl_Menu_.copy>void Fl_Menu_::copy(const Fl_Menu_Item*)</A></H4>
|
||||
Set the menu array to a copy of the passed array. This copy will be
|
||||
deleted when the Fl_Menu_ is deleted.
|
||||
<H4><A name=Fl_Menu_.value>int Fl_Menu_::value() const
|
||||
<BR> int Fl_Menu_::value(int)
|
||||
<BR> int Fl_Menu_::value(const Fl_Menu_Item*)</A></H4>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_Menu_.cxx,v 1.5 1999/01/07 19:17:22 mike Exp $"
|
||||
// "$Id: Fl_Menu_.cxx,v 1.6 1999/02/03 08:43:32 bill Exp $"
|
||||
//
|
||||
// Common menu code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -32,9 +32,9 @@
|
|||
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/Fl_Menu_.H>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
int Fl_Menu_::value(const Fl_Menu_Item* m) {
|
||||
clear_changed();
|
||||
if (value_ != m) {value_ = m; return 1;}
|
||||
|
@ -105,15 +105,37 @@ int Fl_Menu_::size() const {
|
|||
}
|
||||
|
||||
void Fl_Menu_::menu(const Fl_Menu_Item* m) {
|
||||
// if (alloc) clear();
|
||||
alloc = 0;
|
||||
clear();
|
||||
value_ = menu_ = (Fl_Menu_Item*)m;
|
||||
}
|
||||
|
||||
void Fl_Menu_::copy(const Fl_Menu_Item* m, void* user_data) {
|
||||
int n = m->size()+1;
|
||||
Fl_Menu_Item* newMenu = new Fl_Menu_Item[n];
|
||||
memcpy(newMenu, m, n*sizeof(Fl_Menu_Item));
|
||||
menu(newMenu);
|
||||
alloc = 1; // make destructor free it
|
||||
// for convienence, provide way to change all the user data pointers:
|
||||
if (user_data) for (; n--;) {
|
||||
if (newMenu->callback_) newMenu->user_data_ = user_data;
|
||||
newMenu++;
|
||||
}
|
||||
}
|
||||
|
||||
Fl_Menu_::~Fl_Menu_() {
|
||||
// if (alloc) clear();
|
||||
clear();
|
||||
}
|
||||
|
||||
void Fl_Menu_::clear() {
|
||||
if (alloc) {
|
||||
if (alloc>1) for (int i = size(); i--;)
|
||||
if (menu_[i].text) free((void*)menu_[i].text);
|
||||
delete[] menu_;
|
||||
menu_ = 0;
|
||||
alloc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu_.cxx,v 1.5 1999/01/07 19:17:22 mike Exp $".
|
||||
// End of "$Id: Fl_Menu_.cxx,v 1.6 1999/02/03 08:43:32 bill Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_Menu_Window.cxx,v 1.7 1999/01/07 19:17:23 mike Exp $"
|
||||
// "$Id: Fl_Menu_Window.cxx,v 1.8 1999/02/03 08:43:33 bill Exp $"
|
||||
//
|
||||
// Menu window code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -96,65 +96,6 @@ Fl_Menu_Window::~Fl_Menu_Window() {
|
|||
hide();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// "Grab" is done while menu systems are up. This has several effects:
|
||||
// Events are all sent to the "grab window", which does not even
|
||||
// have to be displayed (and in the case of Fl_Menu.C it isn't).
|
||||
// Under X override_redirect and save_under is done to new windows.
|
||||
// The system is also told to "grab" events and send them to this app.
|
||||
|
||||
extern void fl_fix_focus();
|
||||
|
||||
#ifdef WIN32
|
||||
// We have to keep track of whether we have captured the mouse, since
|
||||
// MSWindows shows little respect for this... Grep for fl_capture to
|
||||
// see where and how this is used.
|
||||
HWND fl_capture;
|
||||
#endif
|
||||
|
||||
void Fl::grab(Fl_Window& w) {
|
||||
grab_ = &w;
|
||||
#ifdef WIN32
|
||||
SetActiveWindow(fl_capture = fl_xid(first_window()));
|
||||
SetCapture(fl_capture);
|
||||
#else
|
||||
XGrabPointer(fl_display,
|
||||
fl_xid(first_window()),
|
||||
1,
|
||||
ButtonPressMask|ButtonReleaseMask|
|
||||
ButtonMotionMask|PointerMotionMask,
|
||||
GrabModeAsync,
|
||||
GrabModeAsync,
|
||||
None,
|
||||
0,
|
||||
fl_event_time);
|
||||
XGrabKeyboard(fl_display,
|
||||
fl_xid(first_window()),
|
||||
1,
|
||||
GrabModeAsync,
|
||||
GrabModeAsync,
|
||||
fl_event_time);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern void fl_send_extra_move(); // in Fl.cxx
|
||||
|
||||
void Fl::release() {
|
||||
grab_ = 0;
|
||||
#ifdef WIN32
|
||||
fl_capture = 0;
|
||||
ReleaseCapture();
|
||||
#else
|
||||
XUngrabKeyboard(fl_display, fl_event_time);
|
||||
XUngrabPointer(fl_display, fl_event_time);
|
||||
// this flush is done in case the picked menu item goes into
|
||||
// an infinite loop, so we don't leave the X server locked up:
|
||||
XFlush(fl_display);
|
||||
#endif
|
||||
fl_send_extra_move();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu_Window.cxx,v 1.7 1999/01/07 19:17:23 mike Exp $".
|
||||
// End of "$Id: Fl_Menu_Window.cxx,v 1.8 1999/02/03 08:43:33 bill Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_Menu_add.cxx,v 1.6 1999/01/29 16:56:48 carl Exp $"
|
||||
// "$Id: Fl_Menu_add.cxx,v 1.7 1999/02/03 08:43:33 bill Exp $"
|
||||
//
|
||||
// Menu utilities for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -41,20 +41,44 @@
|
|||
// always allocate this much initially:
|
||||
#define INITIAL_MENU_SIZE 15
|
||||
|
||||
// as menu array size passes through each power of two, the memory
|
||||
// array allocated is doubled in size:
|
||||
static Fl_Menu_Item* incr_array(Fl_Menu_Item* array, int size) {
|
||||
if (size < INITIAL_MENU_SIZE) return array;
|
||||
if ((size+1) & size) return array; // not a power of 2
|
||||
Fl_Menu_Item* newarray = new Fl_Menu_Item[size*2+1];
|
||||
for (int i = 0; i <= size; i++) newarray[i] = array[i];
|
||||
delete[] array;
|
||||
return newarray;
|
||||
}
|
||||
|
||||
// if this local pointer is set, array is reallocated and put here:
|
||||
static Fl_Menu_Item** alloc;
|
||||
|
||||
// Insert a single Fl_Menu_Item into an array at offset n. If ::alloc
|
||||
// is not zero, the array may be reallocated. This is done each time
|
||||
// it's size passes through a power of 2. The new (or old) array is
|
||||
// returned.
|
||||
// Notice that size does not count the trailing null item, so one more
|
||||
// item than you think must be copied.
|
||||
static Fl_Menu_Item* insert(
|
||||
Fl_Menu_Item* array, int size,
|
||||
int n,
|
||||
const char *text,
|
||||
int flags) {
|
||||
// If new size is a power of two, we reallocate to the next power
|
||||
// of two:
|
||||
if (alloc && size >= INITIAL_MENU_SIZE && !((size+1)&size)) {
|
||||
Fl_Menu_Item* newarray = new Fl_Menu_Item[(size+1)*2];
|
||||
memcpy(newarray, array, (size+1)*sizeof(Fl_Menu_Item));
|
||||
delete[] array;
|
||||
*alloc = array = newarray;
|
||||
}
|
||||
// move all the later items:
|
||||
memmove(array+n+1, array+n, sizeof(Fl_Menu_Item)*(size-n+1));
|
||||
// create the new item:
|
||||
Fl_Menu_Item* m = array+n;
|
||||
m->text = text ? strdup(text) : 0;
|
||||
m->shortcut_ = 0;
|
||||
m->callback_ = 0;
|
||||
m->user_data_ = 0;
|
||||
m->flags = flags;
|
||||
m->labeltype_ = m->labelfont_ = m->labelsize_ = m->labelcolor_ = 0;
|
||||
return array;
|
||||
}
|
||||
|
||||
// Add an item. The text is split at '/' characters to automatically
|
||||
// produce submenus (actually a totally unnecessary feature as you can
|
||||
// now add submenu titles directly by setting SUBMENU in the flags):
|
||||
int Fl_Menu_Item::add(
|
||||
const char *text,
|
||||
int shortcut,
|
||||
|
@ -85,27 +109,17 @@ int Fl_Menu_Item::add(
|
|||
|
||||
/* find a matching menu title: */
|
||||
for (; m->text; m = m->next())
|
||||
if (m->flags&FL_SUBMENU && !strcmp(item,m->text)) break;
|
||||
if (m->flags&FL_SUBMENU && !strcmp(item, m->text)) break;
|
||||
|
||||
if (!m->text) { /* create a new menu */
|
||||
if (alloc) {
|
||||
int n = m-array;
|
||||
array = incr_array(array,size);
|
||||
array = incr_array(array,size+1);
|
||||
*alloc = array;
|
||||
m = array+n;
|
||||
}
|
||||
memmove(m+2,m,sizeof(Fl_Menu_Item)*(array+size-m));
|
||||
m->text = strdup(item);
|
||||
m->shortcut_ = 0;
|
||||
m->callback_ = 0;
|
||||
m->user_data_ = 0;
|
||||
m->flags = FL_SUBMENU|flags1;
|
||||
m->labeltype_ = m->labelfont_ = m->labelsize_ = m->labelcolor_ = 0;
|
||||
(m+1)->text = 0;
|
||||
size += 2;
|
||||
int n = m-array;
|
||||
array = insert(array, size, n, item, FL_SUBMENU|flags1);
|
||||
size++;
|
||||
array = insert(array, size, n+1, 0, 0);
|
||||
size++;
|
||||
m = array+n;
|
||||
}
|
||||
m++; /* go into the menu */
|
||||
m++; /* go into the submenu */
|
||||
flags1 = 0;
|
||||
}
|
||||
|
||||
|
@ -114,22 +128,20 @@ int Fl_Menu_Item::add(
|
|||
if (!strcmp(m->text,item)) break;
|
||||
|
||||
if (!m->text) { /* add a new menu item */
|
||||
if (alloc) {
|
||||
int n = m-array;
|
||||
*alloc = array = incr_array(array,size);
|
||||
m = array+n;
|
||||
}
|
||||
memmove(m+1,m,sizeof(Fl_Menu_Item)*(array+size-m));
|
||||
int n = m-array;
|
||||
array = insert(array, size, n, item, flags|flags1);
|
||||
size++;
|
||||
m->text = strdup(item);
|
||||
if (flags & FL_SUBMENU) { // add submenu delimiter
|
||||
array = insert(array, size, n+1, 0, 0);
|
||||
size++;
|
||||
}
|
||||
m = array+n;
|
||||
}
|
||||
|
||||
/* fill it in */
|
||||
m->shortcut_ = shortcut;
|
||||
m->callback_ = cb;
|
||||
m->user_data_ = data;
|
||||
m->flags = flags|flags1;
|
||||
m->labeltype_ = m->labelfont_ = m->labelsize_ = m->labelcolor_ = 0;
|
||||
|
||||
return m-array;
|
||||
}
|
||||
|
@ -137,8 +149,8 @@ int Fl_Menu_Item::add(
|
|||
int Fl_Menu_::add(const char *t, int s, Fl_Callback *c,void *v,int f) {
|
||||
int n = value_ ? value_ - menu_ : 0;
|
||||
if (!menu_) {
|
||||
alloc = 1;
|
||||
menu_ = new Fl_Menu_Item[INITIAL_MENU_SIZE];
|
||||
alloc = 2; // indicates that the strings can be freed
|
||||
menu_ = new Fl_Menu_Item[INITIAL_MENU_SIZE+1];
|
||||
menu_[0].text = 0;
|
||||
}
|
||||
if (alloc) ::alloc = &menu_;
|
||||
|
@ -148,6 +160,8 @@ int Fl_Menu_::add(const char *t, int s, Fl_Callback *c,void *v,int f) {
|
|||
return r;
|
||||
}
|
||||
|
||||
// This is a Forms (and SGI GL library) compatable add function, it
|
||||
// adds strings of the form "name\tshortcut|name\tshortcut|..."
|
||||
int Fl_Menu_::add(const char *str) {
|
||||
char buf[128];
|
||||
int r = 0;
|
||||
|
@ -167,30 +181,20 @@ int Fl_Menu_::add(const char *str) {
|
|||
|
||||
void Fl_Menu_::replace(int i, const char *str) {
|
||||
if (i<0 || i>=size()) return;
|
||||
if (alloc) free((void *)menu_[i].text);
|
||||
menu_[i].text = strdup(str);
|
||||
if (alloc > 1) {
|
||||
free((void *)menu_[i].text);
|
||||
str = strdup(str);
|
||||
}
|
||||
menu_[i].text = str;
|
||||
}
|
||||
|
||||
void Fl_Menu_::remove(int i) {
|
||||
int n = size();
|
||||
if (i<0 || i>=n) return;
|
||||
if (alloc) free((void *)menu_[i].text);
|
||||
if (alloc > 1) free((void *)menu_[i].text);
|
||||
memmove(&menu_[i],&menu_[i+1],(n-i)*sizeof(Fl_Menu_Item));
|
||||
}
|
||||
|
||||
void Fl_Menu_::clear() {
|
||||
for (int i = size(); i--;)
|
||||
if (menu_[i].text) free((void*)menu_[i].text);
|
||||
if (alloc) {
|
||||
delete[] menu_;
|
||||
menu_ = 0;
|
||||
alloc = 0;
|
||||
} else if (menu_) {
|
||||
menu_[0].text = 0;
|
||||
value_ = menu_;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_Menu_add.cxx,v 1.6 1999/01/29 16:56:48 carl Exp $".
|
||||
// End of "$Id: Fl_Menu_add.cxx,v 1.7 1999/02/03 08:43:33 bill Exp $".
|
||||
//
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
//
|
||||
// "$Id: Fl_grab.cxx,v 1.1 1999/02/03 08:43:33 bill Exp $"
|
||||
//
|
||||
// Grab/release code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-1999 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Library General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Library General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
// USA.
|
||||
//
|
||||
// Please report all bugs and problems to "fltk-bugs@easysw.com".
|
||||
//
|
||||
|
||||
#include <config.h>
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/x.H>
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// "Grab" is done while menu systems are up. This has several effects:
|
||||
// Events are all sent to the "grab window", which does not even
|
||||
// have to be displayed (and in the case of Fl_Menu.C it isn't).
|
||||
// The system is also told to "grab" events and send them to this app.
|
||||
// This also modifies how Fl_Window::show() works, on X it turns on
|
||||
// override_redirect, it does similar things on WIN32.
|
||||
|
||||
extern void fl_send_extra_move(); // in Fl.cxx
|
||||
|
||||
#ifdef WIN32
|
||||
// We have to keep track of whether we have captured the mouse, since
|
||||
// MSWindows shows little respect for this... Grep for fl_capture to
|
||||
// see where and how this is used.
|
||||
extern HWND fl_capture;
|
||||
#endif
|
||||
|
||||
void Fl::grab(Fl_Window* w) {
|
||||
if (w) {
|
||||
if (!grab_) {
|
||||
#ifdef WIN32
|
||||
SetActiveWindow(fl_capture = fl_xid(first_window()));
|
||||
SetCapture(fl_capture);
|
||||
#else
|
||||
XGrabPointer(fl_display,
|
||||
fl_xid(first_window()),
|
||||
1,
|
||||
ButtonPressMask|ButtonReleaseMask|
|
||||
ButtonMotionMask|PointerMotionMask,
|
||||
GrabModeAsync,
|
||||
GrabModeAsync,
|
||||
None,
|
||||
0,
|
||||
fl_event_time);
|
||||
XGrabKeyboard(fl_display,
|
||||
fl_xid(first_window()),
|
||||
1,
|
||||
GrabModeAsync,
|
||||
GrabModeAsync,
|
||||
fl_event_time);
|
||||
#endif
|
||||
}
|
||||
grab_ = w;
|
||||
} else {
|
||||
if (grab_) {
|
||||
#ifdef WIN32
|
||||
fl_capture = 0;
|
||||
ReleaseCapture();
|
||||
#else
|
||||
XUngrabKeyboard(fl_display, fl_event_time);
|
||||
XUngrabPointer(fl_display, fl_event_time);
|
||||
// this flush is done in case the picked menu item goes into
|
||||
// an infinite loop, so we don't leave the X server locked up:
|
||||
XFlush(fl_display);
|
||||
#endif
|
||||
grab_ = 0;
|
||||
fl_send_extra_move();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_grab.cxx,v 1.1 1999/02/03 08:43:33 bill Exp $".
|
||||
//
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_win32.cxx,v 1.26 1999/01/29 07:52:21 bill Exp $"
|
||||
// "$Id: Fl_win32.cxx,v 1.27 1999/02/03 08:43:33 bill Exp $"
|
||||
//
|
||||
// WIN32-specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -176,7 +176,7 @@ void fl_fix_focus(); // in Fl.C
|
|||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
extern HWND fl_capture;
|
||||
HWND fl_capture;
|
||||
|
||||
static int mouse_event(Fl_Window *window, int what, int button,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
|
@ -862,5 +862,5 @@ void Fl_Window::make_current() {
|
|||
}
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_win32.cxx,v 1.26 1999/01/29 07:52:21 bill Exp $".
|
||||
// End of "$Id: Fl_win32.cxx,v 1.27 1999/02/03 08:43:33 bill Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: Fl_x.cxx,v 1.22 1999/01/27 17:52:25 mike Exp $"
|
||||
// "$Id: Fl_x.cxx,v 1.23 1999/02/03 08:43:34 bill Exp $"
|
||||
//
|
||||
// X specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -373,9 +373,12 @@ int fl_handle(const XEvent& xevent)
|
|||
|
||||
case Expose:
|
||||
Fl_X::i(window)->wait_for_expose = 0;
|
||||
#if 0
|
||||
// try to keep windows on top even if WM_TRANSIENT_FOR does not work:
|
||||
// opaque move/resize window managers do not like this, so I disabled it.
|
||||
if (Fl::first_window()->non_modal() && window != Fl::first_window())
|
||||
Fl::first_window()->show();
|
||||
#endif
|
||||
|
||||
case GraphicsExpose:
|
||||
window->damage(FL_DAMAGE_EXPOSE, xevent.xexpose.x, xevent.xexpose.y,
|
||||
|
@ -818,5 +821,5 @@ void Fl_Window::make_current() {
|
|||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id: Fl_x.cxx,v 1.22 1999/01/27 17:52:25 mike Exp $".
|
||||
// End of "$Id: Fl_x.cxx,v 1.23 1999/02/03 08:43:34 bill Exp $".
|
||||
//
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# "$Id: Makefile,v 1.10 1999/01/31 07:43:15 bill Exp $"
|
||||
# "$Id: Makefile,v 1.11 1999/02/03 08:43:34 bill Exp $"
|
||||
#
|
||||
# Library makefile for the Fast Light Tool Kit (FLTK).
|
||||
#
|
||||
|
@ -87,6 +87,7 @@ CPPFILES = \
|
|||
Fl_display.cxx \
|
||||
Fl_get_key.cxx \
|
||||
Fl_get_system_colors.cxx \
|
||||
Fl_grab.cxx \
|
||||
Fl_own_colormap.cxx \
|
||||
Fl_visual.cxx \
|
||||
Fl_x.cxx \
|
||||
|
@ -112,6 +113,7 @@ CPPFILES = \
|
|||
fl_file_chooser.cxx \
|
||||
fl_font.cxx \
|
||||
fl_labeltype.cxx \
|
||||
fl_line_style.cxx \
|
||||
fl_oval_box.cxx \
|
||||
fl_overlay.cxx \
|
||||
fl_overlay_visual.cxx \
|
||||
|
@ -182,5 +184,5 @@ install: ../lib/$(LIBNAME)
|
|||
-ln -s FL $(includedir)/Fl
|
||||
|
||||
#
|
||||
# End of "$Id: Makefile,v 1.10 1999/01/31 07:43:15 bill Exp $".
|
||||
# End of "$Id: Makefile,v 1.11 1999/02/03 08:43:34 bill Exp $".
|
||||
#
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// "$Id: subwindow.cxx,v 1.4 1999/01/07 19:18:01 mike Exp $"
|
||||
// "$Id: subwindow.cxx,v 1.5 1999/02/03 08:43:35 bill Exp $"
|
||||
//
|
||||
// Nested window test program for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
|
@ -101,18 +101,56 @@ int testwindow::handle(int e) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char* bigmess =
|
||||
#if 1
|
||||
"this|is|only|a test"
|
||||
#else
|
||||
"item1|item2|item3|item4|item5|"
|
||||
"submenu/item1|submenu/item2|submenu/item3|submenu/item4|"
|
||||
"submenu/sub/item1|submenu/sub/item2|submenu/sub/item3|"
|
||||
"item6|item7|item8|item9|item10|"
|
||||
"item21|item22|item23|item24|item25|"
|
||||
"submenu/item21|submenu/item22|submenu/item23|submenu/item24|"
|
||||
"submenu/sub/item21|submenu/sub/item22|submenu/sub/item23|"
|
||||
"item36|item37|item38|item39|item310|"
|
||||
"item31|item32|item33|item34|item35|"
|
||||
"submenu/item31|submenu/item32|submenu/item33|submenu/item34|"
|
||||
"submenu/sub/item31|submenu/sub/item32|submenu/sub/item33|"
|
||||
"item46|item47|item48|item49|item410|"
|
||||
"item41|item42|item43|item44|item45|"
|
||||
"submenu/item41|submenu/item42|submenu/item43|submenu/item44|"
|
||||
"submenu/sub/item41|submenu/sub/item42|submenu/sub/item43|"
|
||||
"item26|item27|item28|item29|item210|"
|
||||
"submenu2/item1|submenu2/item2|submenu2/item3|submenu2/item4|"
|
||||
"submenu2/sub/item1|submenu2/sub/item2|submenu2/sub/item3|"
|
||||
"item6|item7|item8|item9|item10|"
|
||||
"item21|item22|item23|item24|item25|"
|
||||
"submenu2/item21|submenu2/item22|submenu2/item23|submenu2/item24|"
|
||||
"submenu2/sub/item21|submenu2/sub/item22|submenu2/sub/item23|"
|
||||
"item36|item37|item38|item39|item310|"
|
||||
"item31|item32|item33|item34|item35|"
|
||||
"submenu2/item31|submenu2/item32|submenu2/item33|submenu2/item34|"
|
||||
"submenu2/sub/item31|submenu2/sub/item32|submenu2/sub/item33|"
|
||||
"item46|item47|item48|item49|item410|"
|
||||
"item41|item42|item43|item44|item45|"
|
||||
"submenu2/item41|submenu2/item42|submenu2/item43|submenu2/item44|"
|
||||
"submenu2/sub/item41|submenu2/sub/item42|submenu2/sub/item43|"
|
||||
"item26|item27|item28|item29|item210|"
|
||||
#endif
|
||||
;
|
||||
|
||||
int main(int, char **) {
|
||||
testwindow *window =
|
||||
new testwindow(FL_UP_BOX,400,400,"outer");
|
||||
new Fl_Toggle_Button(310,310,80,80,"&outer");
|
||||
new EnterExit(10,310,80,80,"enterexit");
|
||||
new Fl_Input(150,310,150,25,"input:");
|
||||
(new Fl_Menu_Button(5,150,80,25,"menu&1"))->add("this|is|only|a test");
|
||||
(new Fl_Menu_Button(5,150,80,25,"menu&1"))->add(bigmess);
|
||||
testwindow *subwindow =
|
||||
new testwindow(FL_DOWN_BOX,100,100,200,200,"inner");
|
||||
new Fl_Toggle_Button(110,110,80,80,"&inner");
|
||||
new EnterExit(10,110,80,80,"enterexit");
|
||||
(new Fl_Menu_Button(50,50,80,25,"menu&2"))->add("this|is|only|a test");
|
||||
(new Fl_Menu_Button(50,50,80,25,"menu&2"))->add(bigmess);
|
||||
new Fl_Input(45,80,150,25,"input:");
|
||||
subwindow->resizable(subwindow);
|
||||
window->resizable(subwindow);
|
||||
|
@ -132,5 +170,5 @@ int main(int, char **) {
|
|||
}
|
||||
|
||||
//
|
||||
// End of "$Id: subwindow.cxx,v 1.4 1999/01/07 19:18:01 mike Exp $".
|
||||
// End of "$Id: subwindow.cxx,v 1.5 1999/02/03 08:43:35 bill Exp $".
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue