~ubuntu-branches/ubuntu/raring/lmms/raring-proposed

« back to all changes in this revision

Viewing changes to plugins/zynaddsubfx/fltk/src/Fl.cxx

  • Committer: Charlie Smotherman
  • Date: 2012-12-05 22:08:38 UTC
  • mfrom: (33.1.7 lmms_0.4.13)
  • Revision ID: cjsmo@cableone.net-20121205220838-09pjfzew9m5023hr
* New  Upstream release.
  - Minor tweaking to ZynAddSubFX, CALF, SWH plugins  and Stefan Fendt's RC
    filters.
  - Added UI fixes: Magnentic effect of knobs and Piano-roll fixes
  - Updated German localization and copyright year
* debian/lmms-common.install:
  - added /usr/share/applications so the lmms.desktop file will correctly
    install (LP: #863366)
  - This should also fix the Software Center not displaying lmms in sound
    and video (LP: #824231)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: Fl.cxx 7354 2010-03-29 11:07:29Z matt $"
 
2
// "$Id: Fl.cxx 8723 2011-05-23 16:49:02Z manolo $"
3
3
//
4
4
// Main event handling code for the Fast Light Tool Kit (FLTK).
5
5
//
6
 
// Copyright 1998-2009 by Bill Spitzak and others.
 
6
// Copyright 1998-2010 by Bill Spitzak and others.
7
7
//
8
8
// This library is free software; you can redistribute it and/or
9
9
// modify it under the terms of the GNU Library General Public
27
27
 
28
28
 
29
29
// warning: the Apple Quartz version still uses some Quickdraw calls,
30
 
//          mostly to get around the single active context in QD and 
 
30
//          mostly to get around the single active context in QD and
31
31
//          to implement clipping. This should be changed into pure
32
32
//          Quartz calls in the near future.
33
 
#include "config.h"
 
33
#include <config.h>
 
34
 
 
35
/* We require Windows 2000 features (e.g. VK definitions) */
 
36
#if defined(WIN32)
 
37
# if !defined(WINVER) || (WINVER < 0x0500)
 
38
#  ifdef WINVER
 
39
#   undef WINVER
 
40
#  endif
 
41
#  define WINVER 0x0500
 
42
# endif
 
43
# if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500)
 
44
#  ifdef _WIN32_WINNT
 
45
#   undef _WIN32_WINNT
 
46
#  endif
 
47
#  define _WIN32_WINNT 0x0500
 
48
# endif
 
49
#endif
 
50
 
 
51
// recent versions of MinGW warn: "Please include winsock2.h before windows.h",
 
52
// hence we must include winsock2.h before FL/Fl.H (A.S. Dec. 2010, IMM May 2011)
 
53
#if defined(WIN32) && !defined(__CYGWIN__)
 
54
#  include <winsock2.h>
 
55
#endif
 
56
 
34
57
#include <FL/Fl.H>
35
58
#include <FL/Fl_Window.H>
 
59
#include <FL/Fl_Tooltip.H>
36
60
#include <FL/x.H>
37
 
#include <FL/Fl_Tooltip.H>
 
61
 
38
62
#include <ctype.h>
39
63
#include <stdio.h>
40
64
#include <stdlib.h>
41
65
#include "flstring.h"
42
66
 
43
 
#if defined(__APPLE__)
44
 
#import <Cocoa/Cocoa.h>
45
 
#endif
46
 
 
47
67
#if defined(DEBUG) || defined(DEBUG_WATCH)
48
68
#  include <stdio.h>
49
69
#endif // DEBUG || DEBUG_WATCH
55
75
void fl_cleanup_pens(void);
56
76
void fl_release_dc(HWND,HDC);
57
77
void fl_cleanup_dc_list(void);
 
78
#elif defined(__APPLE__)
 
79
extern double fl_mac_flush_and_wait(double time_to_wait, char in_idle);
58
80
#endif // WIN32
59
81
 
60
82
//
61
83
// Globals...
62
84
//
 
85
#if defined(__APPLE__) || defined(FL_DOXYGEN)
 
86
const char *Fl_Mac_App_Menu::about = "About ";
 
87
const char *Fl_Mac_App_Menu::print = "Print Front Window";
 
88
const char *Fl_Mac_App_Menu::services = "Services";
 
89
const char *Fl_Mac_App_Menu::hide = "Hide ";
 
90
const char *Fl_Mac_App_Menu::hide_others = "Hide Others";
 
91
const char *Fl_Mac_App_Menu::show = "Show All";
 
92
const char *Fl_Mac_App_Menu::quit = "Quit ";
 
93
#endif // __APPLE__
63
94
#ifndef FL_DOXYGEN
64
95
Fl_Widget       *Fl::belowmouse_,
65
96
                *Fl::pushed_,
82
113
 
83
114
char            *Fl::e_text = (char *)"";
84
115
int             Fl::e_length;
85
 
int             Fl::visible_focus_ = 1,
86
 
                Fl::dnd_text_ops_ = 1;
 
116
 
 
117
Fl_Event_Dispatch Fl::e_dispatch = 0;
 
118
 
 
119
unsigned char   Fl::options_[] = { 0, 0 };
 
120
unsigned char   Fl::options_read_ = 0;
 
121
 
87
122
 
88
123
Fl_Window *fl_xfocus;   // which window X thinks has focus
89
124
Fl_Window *fl_xmousewin;// which window X thinks has FL_ENTER
106
141
}
107
142
 
108
143
/**
109
 
  Gets the default scrollbar size used by 
 
144
  Gets the default scrollbar size used by
110
145
  Fl_Browser_,
111
146
  Fl_Help_View,
112
147
  Fl_Scroll, and
130
165
}
131
166
 
132
167
 
133
 
/**
134
 
    Returns whether or not the mouse event is inside the given rectangle.
135
 
    Returns non-zero if the current event_x and event_y
136
 
    put it inside the widget or inside an arbitrary bounding box.  You
137
 
    should always call this rather than doing your own comparison so you
138
 
    are consistent about edge effects.
 
168
/** Returns whether or not the mouse event is inside the given rectangle.
 
169
 
 
170
    Returns non-zero if the current Fl::event_x() and Fl::event_y()
 
171
    put it inside the given arbitrary bounding box.
 
172
 
 
173
    You should always call this rather than doing your own comparison
 
174
    so you are consistent about edge effects.
 
175
 
 
176
    To find out, whether the event is inside a child widget of the
 
177
    current window, you can use Fl::event_inside(const Fl_Widget *).
 
178
 
 
179
    \param[in] xx,yy,ww,hh      bounding box
 
180
    \return                     non-zero, if mouse event is inside
139
181
*/
140
182
int Fl::event_inside(int xx,int yy,int ww,int hh) /*const*/ {
141
183
  int mx = e_x - xx;
143
185
  return (mx >= 0 && mx < ww && my >= 0 && my < hh);
144
186
}
145
187
 
146
 
/** Returns whether or not the mouse event is inside the given widget.
147
 
    Returns non-zero if the current event_x and event_y
148
 
    put it inside the widget or inside an arbitrary bounding box.  You
149
 
    should always call this rather than doing your own comparison so you
150
 
    are consistent about edge effects.
 
188
/** Returns whether or not the mouse event is inside a given child widget.
 
189
 
 
190
    Returns non-zero if the current Fl::event_x() and Fl::event_y()
 
191
    put it inside the given child widget's bounding box.
 
192
 
 
193
    This method can only be used to check whether the mouse event is
 
194
    inside a \b child widget of the window that handles the event, and
 
195
    there must not be an intermediate subwindow (i.e. the widget must
 
196
    not be inside a subwindow of the current window). However, it is
 
197
    valid if the widget is inside a nested Fl_Group.
 
198
 
 
199
    You must not use it with the window itself as the \p o argument
 
200
    in a window's handle() method.
 
201
 
 
202
    \note The mentioned restrictions are necessary, because this method
 
203
    does not transform coordinates of child widgets, and thus the given
 
204
    widget \p o must be within the \e same window that is handling the
 
205
    current event. Otherwise the results are undefined.
 
206
 
 
207
    You should always call this rather than doing your own comparison
 
208
    so you are consistent about edge effects.
 
209
 
 
210
    \see Fl::event_inside(int, int, int, int)
 
211
 
 
212
    \param[in] o        child widget to be tested
 
213
    \return             non-zero, if mouse event is inside the widget
151
214
*/
152
215
int Fl::event_inside(const Fl_Widget *o) /*const*/ {
153
216
  int mx = e_x - o->x();
162
225
 
163
226
#ifdef WIN32
164
227
 
165
 
/// implementation in Fl_win32.cxx
 
228
// implementation in Fl_win32.cxx
166
229
 
167
230
#elif defined(__APPLE__)
168
231
 
169
 
/// implementation in Fl_mac.cxx
 
232
// implementation in Fl_mac.cxx
170
233
 
171
234
#else
172
235
 
175
238
//
176
239
 
177
240
 
178
 
////////////////////////////////////////////////////////////////
179
 
// Timeouts are stored in a sorted list, so only the first one needs
180
 
// to be checked to see if any should be called.
181
 
  
 
241
////////////////////////////////////////////////////////////////////////
 
242
// Timeouts are stored in a sorted list (*first_timeout), so only the
 
243
// first one needs to be checked to see if any should be called.
 
244
// Allocated, but unused (free) Timeout structs are stored in another
 
245
// linked list (*free_timeout).
 
246
 
182
247
struct Timeout {
183
248
  double time;
184
249
  void (*cb)(void*);
186
251
  Timeout* next;
187
252
};
188
253
static Timeout* first_timeout, *free_timeout;
189
 
static int first_timeout_count, free_timeout_count;
190
254
 
191
255
#include <sys/time.h>
192
256
 
193
257
// I avoid the overhead of getting the current time when we have no
194
258
// timeouts by setting this flag instead of getting the time.
195
259
// In this case calling elapse_timeouts() does nothing, but records
196
 
// the current time, and the next call will actualy elapse time.
 
260
// the current time, and the next call will actually elapse time.
197
261
static char reset_clock = 1;
198
262
 
199
263
static void elapse_timeouts() {
227
291
  Timeout* t = free_timeout;
228
292
  if (t) {
229
293
      free_timeout = t->next;
230
 
      --free_timeout_count;
231
294
  } else {
232
295
      t = new Timeout;
233
296
  }
235
298
  t->cb = cb;
236
299
  t->arg = argp;
237
300
  // insert-sort the new timeout:
238
 
  Timeout** p = &first_timeout; 
 
301
  Timeout** p = &first_timeout;
239
302
  while (*p && (*p)->time <= time) p = &((*p)->next);
240
303
  t->next = *p;
241
304
  *p = t;
253
316
/**
254
317
  Removes a timeout callback. It is harmless to remove a timeout
255
318
  callback that no longer exists.
 
319
 
 
320
  \note This version removes all matching timeouts, not just the first one.
 
321
        This may change in the future.
256
322
*/
257
323
void Fl::remove_timeout(Fl_Timeout_Handler cb, void *argp) {
258
 
  // This version removes all matching timeouts, not just the first one.
259
 
  // This may change in the future.
260
324
  for (Timeout** p = &first_timeout; *p;) {
261
325
    Timeout* t = *p;
262
326
    if (t->cb == cb && (t->arg == argp || !argp)) {
275
339
// Checks are just stored in a list. They are called in the reverse
276
340
// order that they were added (this may change in the future).
277
341
// This is a bit messy because I want to allow checks to be added,
278
 
// removed, and have wait() called from inside them, to do this
 
342
// removed, and have wait() called from inside them. To do this
279
343
// next_check points at the next unprocessed one for the outermost
280
344
// call to Fl::wait().
281
345
 
291
355
  waits for events.  This is different than an idle callback because it
292
356
  is only called once, then FLTK calls the system and tells it not to
293
357
  return until an event happens.
294
 
  
 
358
 
295
359
  This can be used by code that wants to monitor the
296
360
  application's state, such as to keep a display up to date. The
297
361
  advantage of using a check callback is that it is called only when no
298
362
  events are pending. If events are coming in quickly, whole blocks of
299
363
  them will be processed before this is called once. This can save
300
364
  significant time and avoid the application falling behind the events.
301
 
  
 
365
 
302
366
  Sample code:
303
 
  
 
367
 
304
368
  \code
305
369
  bool state_changed; // anything that changes the display turns this on
306
 
  
 
370
 
307
371
  void callback(void*) {
308
372
   if (!state_changed) return;
309
373
   state_changed = false;
310
374
   do_expensive_calculation();
311
375
   widget-&gt;redraw();
312
376
  }
313
 
  
 
377
 
314
378
  main() {
315
379
   Fl::add_check(callback);
316
380
   return Fl::run();
382
446
////////////////////////////////////////////////////////////////
383
447
// wait/run/check/ready:
384
448
 
385
 
void (*Fl::idle)(); // see Fl_add_idle.cxx for the add/remove functions
 
449
void (*Fl::idle)(); // see Fl::add_idle.cxx for the add/remove functions
386
450
 
387
451
extern int fl_ready(); // in Fl_<platform>.cxx
388
452
extern int fl_wait(double time); // in Fl_<platform>.cxx
389
453
 
390
454
/**
391
 
  See int wait()
 
455
  See int Fl::wait()
392
456
*/
393
457
double Fl::wait(double time_to_wait) {
394
458
  // delete all widgets that were listed during callbacks
410
474
    // the idle function may turn off idle, we can then wait:
411
475
    if (idle) time_to_wait = 0.0;
412
476
  }
413
 
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
414
 
  flush();
415
 
  if (idle && !in_idle) // 'idle' may have been set within flush()
416
 
    time_to_wait = 0.0;
417
 
  double retval = fl_wait(time_to_wait);
418
 
  [pool release];
419
 
  return retval;
 
477
  return fl_mac_flush_and_wait(time_to_wait, in_idle);
420
478
 
421
479
#else
422
480
 
433
491
      first_timeout = t->next;
434
492
      t->next = free_timeout;
435
493
      free_timeout = t;
436
 
      ++free_timeout_count;
437
 
      --first_timeout_count;
438
494
      // Now it is safe for the callback to do add_timeout:
439
495
      cb(argp);
440
496
    }
484
540
}
485
541
 
486
542
#ifdef WIN32
 
543
 
 
544
// Function to initialize COM/OLE for usage. This must be done only once.
 
545
// We define a flag to register whether we called it:
 
546
static char oleInitialized = 0;
 
547
 
 
548
// This calls the Windows function OleInitialize() exactly once.
 
549
void fl_OleInitialize() {
 
550
  if (!oleInitialized) {
 
551
    OleInitialize(0L);
 
552
    oleInitialized = 1;
 
553
  }
 
554
}
 
555
 
 
556
// This calls the Windows function OleUninitialize() only, if
 
557
// OleInitialize has been called before.
 
558
void fl_OleUninitialize() {
 
559
  if (oleInitialized) {
 
560
    OleUninitialize();
 
561
    oleInitialized = 0;
 
562
  }
 
563
}
 
564
 
487
565
class Fl_Win32_At_Exit {
488
566
public:
489
567
  Fl_Win32_At_Exit() { }
490
568
  ~Fl_Win32_At_Exit() {
491
569
    fl_free_fonts();        // do some WIN32 cleanup
492
570
    fl_cleanup_pens();
493
 
    OleUninitialize();
 
571
    fl_OleUninitialize();
494
572
    fl_brush_action(1);
495
573
    fl_cleanup_dc_list();
496
574
  }
505
583
  repeatedly to "run" your program.  You can also check what happened
506
584
  each time after this returns, which is quite useful for managing
507
585
  program state.
508
 
  
 
586
 
509
587
  What this really does is call all idle callbacks, all elapsed
510
588
  timeouts, call Fl::flush() to get the screen to update, and
511
589
  then wait some time (zero if there are idle callbacks, the shortest of
512
590
  all pending timeouts, or infinity), for any events from the user or
513
591
  any Fl::add_fd() callbacks.  It then handles the events and
514
592
  calls the callbacks and then returns.
515
 
  
516
 
  The return value of the first form is non-zero if there are
517
 
  any visible windows - this may change in future versions of
518
 
  FLTK.
519
 
  
520
 
  The second form waits a maximum of <i>time</i>
521
 
  seconds.  <i>It can return much sooner if something happens.</i>
522
 
  
 
593
 
 
594
  The return value of Fl::wait() is non-zero if there are any
 
595
  visible windows - this may change in future versions of FLTK.
 
596
 
 
597
  Fl::wait(time) waits a maximum of \e time seconds.
 
598
  <i>It can return much sooner if something happens.</i>
 
599
 
523
600
  The return value is positive if an event or fd happens before the
524
601
  time elapsed.  It is zero if nothing happens (on Win32 this will only
525
 
  return zero if <i>time</i> is zero).  It is negative if an error
 
602
  return zero if \e time is zero).  It is negative if an error
526
603
  occurs (this will happen on UNIX if a signal happens).
527
604
*/
528
605
int Fl::wait() {
534
611
/**
535
612
  Same as Fl::wait(0).  Calling this during a big calculation
536
613
  will keep the screen up to date and the interface responsive:
537
 
  
 
614
 
538
615
  \code
539
616
  while (!calculation_done()) {
540
617
  calculate();
542
619
  if (user_hit_abort_button()) break;
543
620
  }
544
621
  \endcode
545
 
  
546
 
  The returns non-zero if any windows are displayed, and 0 if no
 
622
 
 
623
  This returns non-zero if any windows are displayed, and 0 if no
547
624
  windows are displayed (this is likely to change in future versions of
548
625
  FLTK).
549
626
*/
558
635
  program is in a state where such callbacks are illegal.  This returns
559
636
  true if Fl::check() would do anything (it will continue to
560
637
  return true until you call Fl::check() or Fl::wait()).
561
 
  
 
638
 
562
639
  \code
563
640
  while (!calculation_done()) {
564
 
  calculate();
565
 
  if (Fl::ready()) {
566
 
    do_expensive_cleanup();
567
 
    Fl::check();
568
 
    if (user_hit_abort_button()) break;
569
 
  }
 
641
    calculate();
 
642
    if (Fl::ready()) {
 
643
      do_expensive_cleanup();
 
644
      Fl::check();
 
645
      if (user_hit_abort_button()) break;
 
646
    }
570
647
  }
571
648
  \endcode
572
649
*/
593
670
  Fl_X *window;
594
671
  for (Fl_X **pp = &Fl_X::first; (window = *pp); pp = &window->next)
595
672
#if defined(WIN32) || defined(USE_X11)
596
 
   if (window->xid == xid) 
 
673
   if (window->xid == xid)
597
674
#elif defined(__APPLE_QUARTZ__)
598
 
   if (window->xid == xid && !window->w->window()) 
 
675
   if (window->xid == xid && !window->w->window())
599
676
#else
600
677
# error unsupported platform
601
678
#endif // __APPLE__
616
693
  Returns the first top-level window in the list of shown() windows.  If
617
694
  a modal() window is shown this is the top-most modal window, otherwise
618
695
  it is the most recent window to get an event.
619
 
  
620
 
  The second form sets the window that is returned by
621
 
  first_window.  The window is removed from wherever it is in the
622
 
  list and inserted at the top.  This is not done if Fl::modal()
623
 
  is on or if the window is not shown(). Because the first window
624
 
  is used to set the "parent" of modal windows, this is often
625
 
  useful.
626
696
*/
627
697
Fl_Window* Fl::first_window() {
628
698
  Fl_X* i = Fl_X::first;
630
700
}
631
701
 
632
702
/**
633
 
  Returns the next top-level window in the list of shown() windows.  You can
634
 
  use this call to iterate through all the windows that are shown().
 
703
  Returns the next top-level window in the list of shown() windows.
 
704
  You can use this call to iterate through all the windows that are shown().
 
705
  \param[in] window     must be shown and not NULL
635
706
*/
636
707
Fl_Window* Fl::next_window(const Fl_Window* window) {
637
708
  Fl_X* i = Fl_X::i(window)->next;
639
710
}
640
711
 
641
712
/**
642
 
  See Fl_Window* first_window()
643
 
*/
 
713
 Sets the window that is returned by first_window().
 
714
 The window is removed from wherever it is in the
 
715
 list and inserted at the top.  This is not done if Fl::modal()
 
716
 is on or if the window is not shown(). Because the first window
 
717
 is used to set the "parent" of modal windows, this is often
 
718
 useful.
 
719
 */
644
720
void Fl::first_window(Fl_Window* window) {
645
721
  if (!window || !window->shown()) return;
646
 
  fl_find(fl_xid(window));
 
722
  fl_find( Fl_X::i(window)->xid );
647
723
}
648
724
 
649
725
/**
656
732
/**
657
733
  Causes all the windows that need it to be redrawn and graphics forced
658
734
  out through the pipes.
659
 
  
 
735
 
660
736
  This is what wait() does before looking for events.
661
737
 
662
738
  Note: in multi-threaded applications you should only call Fl::flush()
688
764
#endif
689
765
}
690
766
 
 
767
 
691
768
////////////////////////////////////////////////////////////////
692
769
// Event handlers:
693
770
 
 
771
 
694
772
struct handler_link {
695
773
  int (*handle)(int);
696
774
  handler_link *next;
697
775
};
698
776
 
 
777
 
699
778
static handler_link *handlers = 0;
700
779
 
 
780
 
701
781
/**
702
782
  Install a function to parse unrecognized events.  If FLTK cannot
703
783
  figure out what to do with an event, it calls each of these functions
704
784
  (most recent first) until one of them returns non-zero.  If none of
705
 
  them returns non zero then the event is ignored.  Events that cause
 
785
  them returns non-zero then the event is ignored.  Events that cause
706
786
  this to be called are:
707
 
  
708
 
  - FL_SHORTCUT events that are not recognized by any  widget.
 
787
 
 
788
  - FL_SHORTCUT events that are not recognized by any widget.
709
789
    This lets you provide global shortcut keys.
710
790
  - System events that FLTK does not recognize.  See fl_xevent.
711
 
  - \e Some other events when the widget FLTK selected  returns
712
 
    zero from its handle() method.  Exactly which  ones may change
 
791
  - \e Some other events when the widget FLTK selected returns
 
792
    zero from its handle() method.  Exactly which ones may change
713
793
    in future versions, however.
 
794
 
 
795
 \see Fl::remove_handler(Fl_Event_Handler)
 
796
 \see Fl::event_dispatch(Fl_Event_Dispatch d)
 
797
 \see Fl::handle(int, Fl_Window*)
714
798
*/
715
799
void Fl::add_handler(Fl_Event_Handler ha) {
716
800
  handler_link *l = new handler_link;
719
803
  handlers = l;
720
804
}
721
805
 
 
806
 
722
807
/**
723
 
  Removes a previously added event handler.
 
808
 Removes a previously added event handler.
 
809
 \see Fl::handle(int, Fl_Window*)
724
810
*/
725
811
void Fl::remove_handler(Fl_Event_Handler ha) {
726
812
  handler_link *l, *p;
752
838
 
753
839
/**
754
840
    Sets the widget that will receive FL_KEYBOARD events.
755
 
    
 
841
 
756
842
    If you change Fl::focus(), the previous widget and all
757
843
    parents (that don't contain the new widget) are sent FL_UNFOCUS
758
844
    events.  Changing the focus does \e not send FL_FOCUS to
759
845
    this or any widget, because sending FL_FOCUS is supposed to
760
846
    \e test if the widget wants the focus (by it returning non-zero from
761
847
    handle()).
762
 
    
763
 
    \sa Fl_Widget::take_focus()
 
848
 
 
849
    \see Fl_Widget::take_focus()
764
850
*/
765
851
void Fl::focus(Fl_Widget *o) {
766
852
  if (o && !o->visible_focus()) return;
772
858
    // make sure that fl_xfocus is set to the top level window
773
859
    // of this widget, or fl_fix_focus will clear our focus again
774
860
    if (o) {
775
 
      Fl_Window *win = 0, *w1 = o->window();
 
861
      Fl_Window *win = 0, *w1 = o->as_window();
 
862
      if (!w1) w1 = o->window();
776
863
      while (w1) { win=w1; w1=win->window(); }
777
 
      if (win) fl_xfocus = win;
 
864
      if (win) {
 
865
#ifdef __APPLE__
 
866
        if (fl_xfocus != win) {
 
867
          Fl_X *x = Fl_X::i(win);
 
868
          if (x) x->set_key_window();
 
869
          }
 
870
#endif
 
871
        fl_xfocus = win;
 
872
        }
778
873
    }
779
874
    // take focus from the old focused window
780
875
    fl_oldfocus = 0;
792
887
 
793
888
/**
794
889
    Sets the widget that is below the mouse.  This is for
795
 
    highlighting buttons.  It is not used to send FL_PUSH or 
 
890
    highlighting buttons.  It is not used to send FL_PUSH or
796
891
    FL_MOVE directly, for several obscure reasons, but those events
797
 
    typically go to this widget.  This is also the first widget tried for 
 
892
    typically go to this widget.  This is also the first widget tried for
798
893
    FL_SHORTCUT events.
799
 
    
 
894
 
800
895
    If you change the belowmouse widget, the previous one and all
801
896
    parents (that don't contain the new widget) are sent FL_LEAVE
802
897
    events.  Changing this does \e not send FL_ENTER to this
803
898
    or any widget, because sending FL_ENTER is supposed to \e test
804
 
    if the widget wants the mouse (by it returning non-zero from 
 
899
    if the widget wants the mouse (by it returning non-zero from
805
900
    handle()).
806
901
*/
807
902
void Fl::belowmouse(Fl_Widget *o) {
819
914
}
820
915
 
821
916
/**
822
 
    Sets the widget that is being pushed. FL_DRAG or 
 
917
    Sets the widget that is being pushed. FL_DRAG or
823
918
    FL_RELEASE (and any more FL_PUSH) events will be sent to
824
919
    this widget.
825
 
    
 
920
 
826
921
    If you change the pushed widget, the previous one and all parents
827
922
    (that don't contain the new widget) are sent FL_RELEASE
828
923
    events.  Changing this does \e not send FL_PUSH to this
829
924
    or any widget, because sending FL_PUSH is supposed to \e test
830
 
    if the widget wants the mouse (by it returning non-zero from 
 
925
    if the widget wants the mouse (by it returning non-zero from
831
926
    handle()).
832
927
*/
833
928
 void Fl::pushed(Fl_Widget *o) {
895
990
  }
896
991
}
897
992
 
898
 
#ifndef WIN32
 
993
#if !(defined(WIN32) || defined(__APPLE__))
899
994
extern Fl_Widget *fl_selection_requestor; // from Fl_x.cxx
900
995
#endif
901
996
 
902
 
// This function is called by ~Fl_Widget() and by Fl_Widget::deactivate
 
997
// This function is called by ~Fl_Widget() and by Fl_Widget::deactivate()
903
998
// and by Fl_Widget::hide().  It indicates that the widget does not want
904
999
// to receive any more events, and also removes all global variables that
905
1000
// point at the widget.
913
1008
#endif // DEBUG
914
1009
 
915
1010
  if (o->contains(Fl::pushed())) Fl::pushed_ = 0;
916
 
#ifndef WIN32
 
1011
#if !(defined(WIN32) || defined(__APPLE__))
917
1012
  if (o->contains(fl_selection_requestor)) fl_selection_requestor = 0;
918
1013
#endif
919
1014
  if (o->contains(Fl::belowmouse())) Fl::belowmouse_ = 0;
927
1022
 
928
1023
////////////////////////////////////////////////////////////////
929
1024
 
930
 
// Call to->handle but first replace the mouse x/y with the correct
931
 
// values to account for nested X windows. 'window' is the outermost
932
 
// window the event was posted to by X:
 
1025
// Call to->handle(), but first replace the mouse x/y with the correct
 
1026
// values to account for nested windows. 'window' is the outermost
 
1027
// window the event was posted to by the system:
933
1028
static int send(int event, Fl_Widget* to, Fl_Window* window) {
934
1029
  int dx, dy;
935
1030
  int old_event = Fl::e_number;
950
1045
  return ret;
951
1046
}
952
1047
 
 
1048
 
 
1049
/**
 
1050
 \brief Set a new event dispatch function.
 
1051
 
 
1052
 The event dispatch function is called after native events are converted to
 
1053
 FLTK events, but before they are handled by FLTK. If the dispatch function
 
1054
 Fl_Event_Dispatch \p d is set, it is up to the dispatch function to call
 
1055
 Fl::handle_(int, Fl_Window*) or to ignore the event.
 
1056
 
 
1057
 The dispatch function itself must return 0 if it ignored the event,
 
1058
 or non-zero if it used the event. If you call Fl::handle_(), then
 
1059
 this will return the correct value.
 
1060
 
 
1061
 The event dispatch can be used to handle exceptions in FLTK events and
 
1062
 callbacks before they reach the native event handler:
 
1063
 
 
1064
 \code
 
1065
 int myHandler(int e, Fl_Window *w) {
 
1066
   try {
 
1067
     return Fl::handle_(e, w);
 
1068
   } catch () {
 
1069
     ...
 
1070
   }
 
1071
 }
 
1072
 
 
1073
 main() {
 
1074
   Fl::event_dispatch(myHandler);
 
1075
   ...
 
1076
   Fl::run();
 
1077
 }
 
1078
 \endcode
 
1079
 
 
1080
 \param d new dispatch function, or NULL
 
1081
 \see Fl::add_handler(Fl_Event_Handler)
 
1082
 \see Fl::handle(int, Fl_Window*)
 
1083
 \see Fl::handle_(int, Fl_Window*)
 
1084
 */
 
1085
void Fl::event_dispatch(Fl_Event_Dispatch d)
 
1086
{
 
1087
  e_dispatch = d;
 
1088
}
 
1089
 
 
1090
 
 
1091
/**
 
1092
 \brief Return the current event dispatch function.
 
1093
 */
 
1094
Fl_Event_Dispatch Fl::event_dispatch()
 
1095
{
 
1096
  return e_dispatch;
 
1097
}
 
1098
 
 
1099
 
 
1100
/**
 
1101
 \brief Handle events from the window system.
 
1102
 
 
1103
 This is called from the native event dispatch after native events have been
 
1104
 converted to FLTK notation. This function calls Fl::handle_(int, Fl_Window*)
 
1105
 unless the user sets a dispatch function. If a user dispatch function is set,
 
1106
 the user must make sure that Fl::handle_() is called, or the event will be
 
1107
 ignored.
 
1108
 
 
1109
 \param e the event type (Fl::event_number() is not yet set)
 
1110
 \param window the window that caused this event
 
1111
 \return 0 if the event was not handled
 
1112
 
 
1113
 \see Fl::add_handler(Fl_Event_Handler)
 
1114
 \see Fl::event_dispatch(Fl_Event_Dispatch)
 
1115
 */
953
1116
int Fl::handle(int e, Fl_Window* window)
 
1117
{
 
1118
  if (e_dispatch) {
 
1119
    return e_dispatch(e, window);
 
1120
  } else {
 
1121
    return handle_(e, window);
 
1122
  }
 
1123
}
 
1124
 
 
1125
 
954
1126
/**
955
 
  Sends the event to a window for processing.  Returns non-zero if any
956
 
  widget uses the event.
957
 
*/
 
1127
 \brief Handle events from the window system.
 
1128
 
 
1129
 This function is called from the native event dispatch, unless the user sets
 
1130
 another dispatch function. In that case, the user dispatch function must
 
1131
 decide when to call Fl::handle_(int, Fl_Window*)
 
1132
 
 
1133
 \param e the event type (Fl::event_number() is not yet set)
 
1134
 \param window the window that caused this event
 
1135
 \return 0 if the event was not handled
 
1136
 
 
1137
 \see Fl::event_dispatch(Fl_Event_Dispatch)
 
1138
 */
 
1139
int Fl::handle_(int e, Fl_Window* window)
958
1140
{
959
1141
  e_number = e;
960
1142
  if (fl_local_grab) return fl_local_grab(e);
964
1146
  switch (e) {
965
1147
 
966
1148
  case FL_CLOSE:
967
 
    if (grab() || modal() && window != modal()) return 0;
 
1149
    if ( grab() || (modal() && window != modal()) ) return 0;
968
1150
    wi->do_callback();
969
1151
    return 1;
970
1152
 
1016
1198
    }
1017
1199
    if (modal() && wi != modal()) wi = 0;
1018
1200
    if (grab()) wi = grab();
1019
 
    {Fl_Widget* pbm = belowmouse();
1020
 
    int ret = (wi && send(e, wi, window));
1021
 
    if (pbm != belowmouse()) {
 
1201
    { int ret;
 
1202
      Fl_Widget* pbm = belowmouse();
 
1203
#ifdef __APPLE__
 
1204
      if (fl_mac_os_version < 100500) {
 
1205
        // before 10.5, mouse moved events aren't sent to borderless windows such as tooltips
 
1206
        Fl_Window *tooltip = Fl_Tooltip::current_window();
 
1207
        int inside = 0;
 
1208
        if (tooltip && tooltip->shown() ) { // check if a tooltip window is currently opened
 
1209
          // check if mouse is inside the tooltip
 
1210
          inside = (Fl::event_x_root() >= tooltip->x() && Fl::event_x_root() < tooltip->x() + tooltip->w() &&
 
1211
          Fl::event_y_root() >= tooltip->y() && Fl::event_y_root() < tooltip->y() + tooltip->h() );
 
1212
        }
 
1213
        // if inside, send event to tooltip window instead of background window
 
1214
        if (inside) ret = send(e, tooltip, window);
 
1215
        else ret = (wi && send(e, wi, window));
 
1216
      } else
 
1217
#endif
 
1218
      ret = (wi && send(e, wi, window));
 
1219
   if (pbm != belowmouse()) {
1022
1220
#ifdef DEBUG
1023
1221
      printf("Fl::handle(e=%d, window=%p);\n", e, window);
1024
1222
#endif // DEBUG
1049
1247
    return 1;
1050
1248
 
1051
1249
  case FL_KEYUP:
1052
 
    // Send the key-up to the current focus. This is not 
 
1250
    // Send the key-up to the current focus widget. This is not
1053
1251
    // always the same widget that received the corresponding
1054
1252
    // FL_KEYBOARD event because focus may have changed.
1055
1253
    // Sending the KEYUP to the right KEYDOWN is possible, but
1056
 
    // would require that we track the KEYDOWN for every possible 
1057
 
    // key stroke (users may hold down multiple keys!) and then 
 
1254
    // would require that we track the KEYDOWN for every possible
 
1255
    // key stroke (users may hold down multiple keys!) and then
1058
1256
    // make sure that the widget still exists before sending
1059
1257
    // a KEYUP there. I believe that the current solution is
1060
1258
    // "close enough".
1178
1376
  for (; *pp != ip; pp = &(*pp)->next) if (!*pp) return;
1179
1377
  *pp = ip->next;
1180
1378
#ifdef __APPLE__
1181
 
  MacUnlinkWindow(ip);
 
1379
  ip->unlink();
1182
1380
  // MacOS X manages a single pointer per application. Make sure that hiding
1183
1381
  // a toplevel window will not leave us with some random pointer shape, or
1184
1382
  // worst case, an invisible pointer
1225
1423
      fl_release_dc(fl_window, fl_gc);
1226
1424
      fl_window = (HWND)-1;
1227
1425
      fl_gc = 0;
1228
 
# ifdef USE_CAIRO
 
1426
# ifdef FLTK_USE_CAIRO
1229
1427
      if (Fl::cairo_autolink_context()) Fl::cairo_make_current((Fl_Window*) 0);
1230
1428
# endif
1231
1429
    }
1241
1439
# if USE_XFT
1242
1440
  fl_destroy_xft_draw(ip->xid);
1243
1441
# endif
1244
 
  XDestroyWindow(fl_display, ip->xid);
 
1442
  // this test makes sure ip->xid has not been destroyed already
 
1443
  if (ip->xid) XDestroyWindow(fl_display, ip->xid);
1245
1444
#elif defined(WIN32)
1246
1445
  // this little trickery seems to avoid the popup window stacking problem
1247
1446
  HWND p = GetForegroundWindow();
1251
1450
  }
1252
1451
  XDestroyWindow(fl_display, ip->xid);
1253
1452
#elif defined(__APPLE_QUARTZ__)
1254
 
  MacDestroyWindow(this, ip->xid);
 
1453
  ip->destroy();
1255
1454
#else
1256
1455
# error unsupported platform
1257
1456
#endif
1258
 
  
 
1457
 
1259
1458
#ifdef WIN32
1260
1459
  // Try to stop the annoying "raise another program" behavior
1261
1460
  if (non_modal() && Fl::first_window() && Fl::first_window()->shown())
1266
1465
 
1267
1466
Fl_Window::~Fl_Window() {
1268
1467
  hide();
 
1468
  if (xclass_) {
 
1469
    free(xclass_);
 
1470
  }
1269
1471
}
1270
1472
 
1271
1473
// FL_SHOW and FL_HIDE are called whenever the visibility of this widget
1286
1488
#if defined(USE_X11) || defined(WIN32)
1287
1489
        XMapWindow(fl_display, fl_xid(this)); // extra map calls are harmless
1288
1490
#elif defined(__APPLE_QUARTZ__)
1289
 
        MacMapWindow(this, i->xid);
 
1491
        i->map();
1290
1492
#else
1291
1493
# error unsupported platform
1292
1494
#endif // __APPLE__
1294
1496
      break;
1295
1497
    case FL_HIDE:
1296
1498
      if (shown()) {
1297
 
        // Find what really turned invisible, if is was a parent window
 
1499
        // Find what really turned invisible, if it was a parent window
1298
1500
        // we do nothing.  We need to avoid unnecessary unmap calls
1299
1501
        // because they cause the display to blink when the parent is
1300
1502
        // remapped.  However if this or any intermediate non-window
1308
1510
#if defined(USE_X11) || defined(WIN32)
1309
1511
        XUnmapWindow(fl_display, fl_xid(this));
1310
1512
#elif defined(__APPLE_QUARTZ__)
1311
 
        MacUnmapWindow(this, i->xid);
 
1513
        i->unmap();
1312
1514
#else
1313
1515
# error platform unsupported
1314
1516
#endif
1330
1532
    NULL, without changing the actual text of the
1331
1533
    selection. FL_SELECTIONCLEAR is sent to the previous
1332
1534
    selection owner, if any.
1333
 
    
 
1535
 
1334
1536
    <i>Copying the buffer every time the selection is changed is
1335
1537
    obviously wasteful, especially for large selections.  An interface will
1336
1538
    probably be added in a future version to allow the selection to be made
1351
1553
  Fl::copy(text, len, 0);
1352
1554
}
1353
1555
 
1354
 
/** Backward compatibility only:
1355
 
  Set things up so the receiver widget will be called with an  FL_PASTE event some
1356
 
  time in the future for the specified clipboard. The reciever
1357
 
  should be prepared to be called \e directly by this, or for
1358
 
  it to happen \e later, or possibly <i>not at all</i>.  This
1359
 
  allows the window system to take as long as necessary to retrieve
1360
 
  the paste buffer (or even to screw up completely) without complex
1361
 
  and error-prone synchronization code in FLTK.
 
1556
/** Backward compatibility only.
 
1557
  This calls Fl::paste(receiver, 0);
1362
1558
  \see Fl::paste(Fl_Widget &receiver, int clipboard)
1363
1559
*/
1364
1560
void Fl::paste(Fl_Widget &receiver) {
1392
1588
      W += 5; // Add a little to the size of the label to cover overflow
1393
1589
      H += 5;
1394
1590
 
1395
 
      if (align() & FL_ALIGN_BOTTOM) {
1396
 
        window()->damage(FL_DAMAGE_EXPOSE, x(), y() + h(), w(), H);
1397
 
      } else if (align() & FL_ALIGN_TOP) {
1398
 
        window()->damage(FL_DAMAGE_EXPOSE, x(), y() - H, w(), H);
1399
 
      } else if (align() & FL_ALIGN_LEFT) {
1400
 
        window()->damage(FL_DAMAGE_EXPOSE, x() - W, y(), W, h());
1401
 
      } else if (align() & FL_ALIGN_RIGHT) {
1402
 
        window()->damage(FL_DAMAGE_EXPOSE, x() + w(), y(), W, h());
1403
 
      } else {
1404
 
        window()->damage(FL_DAMAGE_ALL);
 
1591
      // FIXME:
 
1592
      // This assumes that measure() returns the correct outline, which it does
 
1593
      // not in all possible cases of alignment combinedwith image and symbols.
 
1594
      switch (align() & 0x0f) {
 
1595
        case FL_ALIGN_TOP_LEFT:
 
1596
          window()->damage(FL_DAMAGE_EXPOSE, x(), y()-H, W, H); break;
 
1597
        case FL_ALIGN_TOP:
 
1598
          window()->damage(FL_DAMAGE_EXPOSE, x()+(w()-W)/2, y()-H, W, H); break;
 
1599
        case FL_ALIGN_TOP_RIGHT:
 
1600
          window()->damage(FL_DAMAGE_EXPOSE, x()+w()-W, y()-H, W, H); break;
 
1601
        case FL_ALIGN_LEFT_TOP:
 
1602
          window()->damage(FL_DAMAGE_EXPOSE, x()-W, y(), W, H); break;
 
1603
        case FL_ALIGN_RIGHT_TOP:
 
1604
          window()->damage(FL_DAMAGE_EXPOSE, x()+w(), y(), W, H); break;
 
1605
        case FL_ALIGN_LEFT:
 
1606
          window()->damage(FL_DAMAGE_EXPOSE, x()-W, y()+(h()-H)/2, W, H); break;
 
1607
        case FL_ALIGN_RIGHT:
 
1608
          window()->damage(FL_DAMAGE_EXPOSE, x()+w(), y()+(h()-H)/2, W, H); break;
 
1609
        case FL_ALIGN_LEFT_BOTTOM:
 
1610
          window()->damage(FL_DAMAGE_EXPOSE, x()-W, y()+h()-H, W, H); break;
 
1611
        case FL_ALIGN_RIGHT_BOTTOM:
 
1612
          window()->damage(FL_DAMAGE_EXPOSE, x()+w(), y()+h()-H, W, H); break;
 
1613
        case FL_ALIGN_BOTTOM_LEFT:
 
1614
          window()->damage(FL_DAMAGE_EXPOSE, x(), y()+h(), W, H); break;
 
1615
        case FL_ALIGN_BOTTOM:
 
1616
          window()->damage(FL_DAMAGE_EXPOSE, x()+(w()-W)/2, y()+h(), W, H); break;
 
1617
        case FL_ALIGN_BOTTOM_RIGHT:
 
1618
          window()->damage(FL_DAMAGE_EXPOSE, x()+w()-W, y()+h(), W, H); break;
 
1619
        default:
 
1620
          window()->damage(FL_DAMAGE_ALL); break;
1405
1621
      }
1406
1622
    } else {
1407
1623
      // The label is inside the widget, so just redraw the widget itself...
1492
1708
 
1493
1709
#ifdef WIN32
1494
1710
#  include "Fl_win32.cxx"
1495
 
#elif defined(__APPLE__)
1496
 
#  include "Fl_cocoa.mm"
 
1711
//#elif defined(__APPLE__)
1497
1712
#endif
1498
1713
 
1499
1714
//
1504
1719
static int              num_dwidgets = 0, alloc_dwidgets = 0;
1505
1720
static Fl_Widget        **dwidgets = 0;
1506
1721
 
1507
 
/** 
 
1722
/**
1508
1723
  Schedules a widget for deletion at the next call to the event loop.
1509
1724
  Use this method to delete a widget inside a callback function.
1510
1725
 
1544
1759
  num_dwidgets ++;
1545
1760
}
1546
1761
 
1547
 
/** 
 
1762
/**
1548
1763
    Deletes widgets previously scheduled for deletion.
1549
 
    
 
1764
 
1550
1765
    This is for internal use only. You should never call this directly.
1551
1766
 
1552
1767
    Fl::do_widget_deletion() is called from the FLTK event loop or whenever
1570
1785
 
1571
1786
/**
1572
1787
  Adds a widget pointer to the widget watch list.
1573
 
  
 
1788
 
1574
1789
  \note Internal use only, please use class Fl_Widget_Tracker instead.
1575
1790
 
1576
1791
  This can be used, if it is possible that a widget might be deleted during
1613
1828
 
1614
1829
   \see class Fl_Widget_Tracker
1615
1830
*/
1616
 
void Fl::watch_widget_pointer(Fl_Widget *&w) 
 
1831
void Fl::watch_widget_pointer(Fl_Widget *&w)
1617
1832
{
1618
1833
  Fl_Widget **wp = &w;
1619
1834
  int i;
1637
1852
 
1638
1853
  This is used to remove a widget pointer that has been added to the watch list
1639
1854
  with Fl::watch_widget_pointer(), when it is not needed anymore.
1640
 
  
 
1855
 
1641
1856
  \note Internal use only, please use class Fl_Widget_Tracker instead.
1642
1857
 
1643
1858
  \see Fl::watch_widget_pointer()
1681
1896
  \see Fl::watch_widget_pointer()
1682
1897
  \see class Fl_Widget_Tracker
1683
1898
*/
1684
 
void Fl::clear_widget_pointer(Fl_Widget const *w) 
 
1899
void Fl::clear_widget_pointer(Fl_Widget const *w)
1685
1900
{
1686
1901
  if (w==0L) return;
1687
1902
  int i;
1692
1907
  }
1693
1908
}
1694
1909
 
 
1910
 
 
1911
/**
 
1912
 \brief FLTK library options management.
 
1913
 
 
1914
 This function needs to be documented in more detail. It can be used for more
 
1915
 optional settings, such as using a native file chooser instead of the FLTK one
 
1916
 wherever possible, disabling tooltips, disabling visible focus, disabling
 
1917
 FLTK file chooser preview, etc. .
 
1918
 
 
1919
 There should be a command line option interface.
 
1920
 
 
1921
 There should be an application that manages options system wide, per user, and
 
1922
 per application.
 
1923
 
 
1924
 \note As of FLTK 1.3.0, options can be managed within fluid, using the menu
 
1925
 <i>Edit/Global FLTK Settings</i>.
 
1926
 
 
1927
 \param opt which option
 
1928
 \return true or false
 
1929
 \see enum Fl::Fl_Option
 
1930
 \see Fl::option(Fl_Option, bool)
 
1931
 
 
1932
 \since FLTK 1.3.0
 
1933
 */
 
1934
bool Fl::option(Fl_Option opt)
 
1935
{
 
1936
  if (!options_read_) {
 
1937
    int tmp;
 
1938
    { // first, read the system wide preferences
 
1939
      Fl_Preferences prefs(Fl_Preferences::SYSTEM, "fltk.org", "fltk");
 
1940
      Fl_Preferences opt_prefs(prefs, "options");
 
1941
      opt_prefs.get("ArrowFocus", tmp, 0);                      // default: off
 
1942
      options_[OPTION_ARROW_FOCUS] = tmp;
 
1943
      //opt_prefs.get("NativeFilechooser", tmp, 1);             // default: on
 
1944
      //options_[OPTION_NATIVE_FILECHOOSER] = tmp;
 
1945
      //opt_prefs.get("FilechooserPreview", tmp, 1);            // default: on
 
1946
      //options_[OPTION_FILECHOOSER_PREVIEW] = tmp;
 
1947
      opt_prefs.get("VisibleFocus", tmp, 1);                    // default: on
 
1948
      options_[OPTION_VISIBLE_FOCUS] = tmp;
 
1949
      opt_prefs.get("DNDText", tmp, 1);                         // default: on
 
1950
      options_[OPTION_DND_TEXT] = tmp;
 
1951
      opt_prefs.get("ShowTooltips", tmp, 1);                    // default: on
 
1952
      options_[OPTION_SHOW_TOOLTIPS] = tmp;
 
1953
    }
 
1954
    { // next, check the user preferences
 
1955
      // override system options only, if the option is set ( >= 0 )
 
1956
      Fl_Preferences prefs(Fl_Preferences::USER, "fltk.org", "fltk");
 
1957
      Fl_Preferences opt_prefs(prefs, "options");
 
1958
      opt_prefs.get("ArrowFocus", tmp, -1);
 
1959
      if (tmp >= 0) options_[OPTION_ARROW_FOCUS] = tmp;
 
1960
      //opt_prefs.get("NativeFilechooser", tmp, -1);
 
1961
      //if (tmp >= 0) options_[OPTION_NATIVE_FILECHOOSER] = tmp;
 
1962
      //opt_prefs.get("FilechooserPreview", tmp, -1);
 
1963
      //if (tmp >= 0) options_[OPTION_FILECHOOSER_PREVIEW] = tmp;
 
1964
      opt_prefs.get("VisibleFocus", tmp, -1);
 
1965
      if (tmp >= 0) options_[OPTION_VISIBLE_FOCUS] = tmp;
 
1966
      opt_prefs.get("DNDText", tmp, -1);
 
1967
      if (tmp >= 0) options_[OPTION_DND_TEXT] = tmp;
 
1968
      opt_prefs.get("ShowTooltips", tmp, -1);
 
1969
      if (tmp >= 0) options_[OPTION_SHOW_TOOLTIPS] = tmp;
 
1970
    }
 
1971
    { // now, if the developer has registered this app, we could as for per-application preferences
 
1972
    }
 
1973
    options_read_ = 1;
 
1974
  }
 
1975
  if (opt<0 || opt>=OPTION_LAST)
 
1976
    return false;
 
1977
  return (bool)(options_[opt]!=0);
 
1978
}
 
1979
 
 
1980
/**
 
1981
 \brief Override an option while the application is running.
 
1982
 
 
1983
 This function does not change any system or user settings.
 
1984
 
 
1985
 \param opt which option
 
1986
 \param val set to true or false
 
1987
 \see enum Fl::Fl_Option
 
1988
 \see bool Fl::option(Fl_Option)
 
1989
 */
 
1990
void Fl::option(Fl_Option opt, bool val)
 
1991
{
 
1992
  if (opt<0 || opt>=OPTION_LAST)
 
1993
    return;
 
1994
  if (!options_read_) {
 
1995
    // first read this option, so we don't override our setting later
 
1996
    option(opt);
 
1997
  }
 
1998
  options_[opt] = val;
 
1999
}
 
2000
 
 
2001
 
1695
2002
// Helper class Fl_Widget_Tracker
1696
2003
 
1697
2004
/**
1698
2005
  The constructor adds a widget to the watch list.
1699
2006
*/
1700
 
Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi) {
1701
 
 
 
2007
Fl_Widget_Tracker::Fl_Widget_Tracker(Fl_Widget *wi)
 
2008
{
1702
2009
  wp_ = wi;
1703
2010
  Fl::watch_widget_pointer(wp_); // add pointer to watch list
1704
2011
}
1706
2013
/**
1707
2014
  The destructor removes a widget from the watch list.
1708
2015
*/
1709
 
Fl_Widget_Tracker::~Fl_Widget_Tracker() {
1710
 
 
 
2016
Fl_Widget_Tracker::~Fl_Widget_Tracker()
 
2017
{
1711
2018
  Fl::release_widget_pointer(wp_); // remove pointer from watch list
1712
2019
}
1713
2020
 
 
2021
 
1714
2022
//
1715
 
// End of "$Id: Fl.cxx 7354 2010-03-29 11:07:29Z matt $".
 
2023
// End of "$Id: Fl.cxx 8723 2011-05-23 16:49:02Z manolo $".
1716
2024
//