[go: up one dir, main page]

File: flinternal.h

package info (click to toggle)
libforms 1.2.3-1.3
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 10,736 kB
  • ctags: 9,015
  • sloc: ansic: 97,669; sh: 11,156; makefile: 951
file content (1115 lines) | stat: -rw-r--r-- 31,844 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
/*
 *  This file is part of the XForms library package.
 *
 *  XForms is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU Lesser General Public License as
 *  published by the Free Software Foundation; either version 2.1, or
 *  (at your option) any later version.
 *
 *  XForms 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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with XForms. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 *  \file flinternal.h
 *
 *  This file is part of the XForms library package.
 *  Copyright (c) 1996-1998  T.C. Zhao and Mark Overmars
 *  All rights reserved.
 *
 * Internal routines used by the Forms Library. An application should
 * not use any of this since there is no guarantee that exactly some
 * thing will exist in future versions of XForms.
 */

#ifndef FLINTERNAL_H
#define FLINTERNAL_H

#include <stdlib.h>
#include <signal.h>
#include "local.h"
#include "ulib.h"


/*  macros  and constants */

/* FL_DEBUG controls some conditional compilations. Even if the code
 * is compiled in, it still needs -debug level on the command line
 * to activate the message output. FL_DEBUG less than ML_ERR probably
 * is not a good idea. Only when making real production executables
 * should FL_DEBUG be less than ML_ERR (say ML_ERR-1)
 *
 *   ML_ERR    -- print some error messages
 *   ML_WARN    -- print some error messages
 *   ML_INFO1  -- some messages
 *   ML_INFO2  -- more messages
 *   ML_DEBUG  -- debugging code compiled in
 *   ML_TRACE  -- can be unbearable
 */

#ifndef FL_DEBUG
#define FL_DEBUG   ML_WARN
#endif


/* Mask for all possible events */

#define AllEventsMask   ( ( OwnerGrabButtonMask << 1 ) - 1 )


/* There are two ways to handle interaction. One is to process object
 * Q only if there are no more event pending. This can result in
 * an event entered into object Q more than once if the connection
 * is slow and clicking is rapid. If subsequently the object is
 * hidden or deleted/freed, problem occurs as the callback will
 * still be processed. To fix this, need to flush the object Q
 * when hiding/deleting objects. Also if an object is entered
 * multiple times, and its status changed each time, when the
 * Q is handled, we get wrong status.
 *
 * The other way to handle the interaction is to process object
 * Q as soon as the status of the object is changed. This is
 * the correct behavior. However, a change in status is typically
 * preceeded by a redraw (say mouse release on button), and due to
 * the X buffering mechnism, the redraw probably not get shown yet
 * when the callback is evoked. To fix this, an explicit flush
 * is needed. This can be time consuming. Also objects that do
 * not have callbacks may be handled out of order (after the one's
 * having callbacks). */

#if 1
#define DELAYED_ACTION
#endif


/* If we want to have gamma correction as a built-in feature.
 * Probably useless */

#define DO_GAMMA_CORRECTION


/* XForms internal colormap */

typedef struct {
    const char     * name;
    FL_COLOR         index;
    unsigned short   r;
    unsigned short   g;
    unsigned short   b;
    unsigned short   a;
    int              grayval;
} FLI_IMAP;

#define BadPixel  FL_NoColor

#define Clamp( v, vmin, vmax ) ( ( v ) < ( vmin ) ? \
                                 ( vmin ) : ( ( v ) > ( vmax ) ? \
                                              ( vmax ) :( v ) ) )

#define IsValidClass( o, c ) ( ( o ) && ( o )->objclass == ( c ) )

#define fli_safe_free( p )   \
    do { if ( p ) {          \
             fl_free( p );   \
             p = NULL;       \
          }                  \
       } while( 0 )

#define fli_class( i )     fl_state[ i ].vclass
#define fli_depth( i )     fl_state[ i ].depth
#define fli_visual( i )    fl_state[ i ].xvinfo->visual
#define fli_colormap( i )  fl_state[ i ].colormap
#define fli_map( i )       fl_state[ i ].colormap
#define fli_dithered( i )  fl_state[ i ].dithered

enum {
    FLI_FIND_INPUT,
    FLI_FIND_AUTOMATIC,
    FLI_FIND_MOUSE,
    FLI_FIND_CANVAS,
    FLI_FIND_KEYSPECIAL,
    FLI_FIND_RETURN
};

/* events.c or event related */

FL_OBJECT * fli_handled_obj;
FL_OBJECT * fli_handled_parent;

void fli_obj_queue_delete( void );

void fli_event_queue_delete( void );

void fli_object_qenter( FL_OBJECT *,
                        int );

void fli_filter_returns( FL_OBJECT * );

FL_OBJECT * fli_object_qread( void );

void fli_object_qflush( FL_FORM * );

void fli_object_qflush_object( FL_OBJECT * );

FL_OBJECT *fli_object_qtest( void );

void fli_treat_user_events( void );

void fli_treat_interaction_events( int );

void fli_compress_event( XEvent *,
                         unsigned long );

const char *fli_event_name( int );

XEvent * fli_xevent_name( const char *,
                          const XEvent * );

void fli_handle_idling( XEvent * xev,
                        long     msec,
                        int      do_idle_cb );

/* Variables defined in handling.c */

extern FL_FORM * mouseform;         /* the current form under mouse */
extern FL_FORM * keyform;           /* keyboard focus form */

extern FL_OBJECT * fli_pushobj;
extern FL_OBJECT * fli_mouseobj;

extern FL_Coord fli_mousex,
                fli_mousey;
extern unsigned int fli_keymask;

extern unsigned int fli_query_age;


/* Misc. utilitnes */

FL_FORM * fli_find_event_form( XEvent * );

void fli_print_version( int );

/* from forms.c and object.c */

void fli_scale_form( FL_FORM *,
                     double,
                     double );

void fli_handle_form( FL_FORM *,
                      int, int,
                      XEvent * );

FL_OBJECT *fli_end_group( void );

void fli_handle_object( FL_OBJECT *,
                        int,
                        FL_Coord,
                        FL_Coord,
                        int,
                        XEvent *,
                        int );

FL_OBJECT * fli_find_first( FL_FORM *,
                            int,
                            FL_Coord,
                            FL_Coord );

void fli_show_object( FL_OBJECT * );

void fli_recalc_intersections( FL_FORM * );

FL_OBJECT * fli_find_last( FL_FORM *,
                           int,
                           FL_Coord,
                           FL_Coord );

FL_OBJECT *fli_find_object( FL_OBJECT *,
                            int,
                            FL_Coord,
                            FL_Coord );

FL_OBJECT *fli_find_object_backwards( FL_OBJECT *,
                                      int,
                                      FL_Coord,
                                      FL_Coord );

void fli_insert_object( FL_OBJECT *,
                        FL_OBJECT * );

void fli_scale_object( FL_OBJECT *,
                       double     ,
                       double );

void fli_set_object_visibility( FL_OBJECT * obj,
                                int         vis );


int fli_mouse_wheel_to_keypress( int       * ev,
                                 int       * key,
                                 void      * xev );

void fli_notify_object( FL_OBJECT * obj,
                        int         reason );

/* double buffering etc. */

void fli_free_flpixmap( FL_pixmap * );

void fli_create_object_pixmap( FL_OBJECT * );

void fli_show_object_pixmap( FL_OBJECT * );

void fli_create_form_pixmap( FL_FORM * );

void fli_show_form_pixmap( FL_FORM * );

/* windowing support */

void fli_default_xswa( void );

Window fli_cmap_winopen( Window,
                         Colormap,
                         const char * );

Window fli_create_window( Window,
                          Colormap,
                          const char * );

void fli_create_gc( Window );

enum {
    FLI_COMMAND_PROP = 1,
    FLI_PROP_SET     = ( 1 << 10 )  /* really set */
};

void fli_set_winproperty( Window,
                          unsigned int );

/* graphics related */

void fli_init_colormap( int );

void fli_free_colormap( int );

void fli_dump_state_info( int,
                          const char * );

void fli_init_stipples( void );

void fli_draw_button( FL_OBJECT * );

/* for fdesign */

const char * fli_query_colorname( FL_COLOR );

long fli_query_namedcolor( const char *s );

void fli_free_xtext_workmem( void );

int fli_get_pos_in_string( int,
                           FL_Coord,
                           FL_Coord,
                           FL_Coord,
                           FL_Coord,
                           int,
                           int,
                           FL_Coord,
                           FL_Coord,
                           const char *,
                           int *,
                           int *,
                           int * );

int fli_drw_stringTAB( Window,
                       GC,
                       int,
                       int,
                       int,
                       int,
                       const char *,
                       int,
                       int );

int fli_drw_string( int,
                    FL_Coord,
                    FL_Coord,
                    FL_Coord,
                    FL_Coord,
                    int,
                    FL_COLOR,
                    FL_COLOR,
                    FL_COLOR,
                    int,
                    int,
                    int,
                    int,
                    int,
                    const char *,
                    int,
                    int,
                    int,
                    FL_COLOR );

int fli_get_maxpixel_line( void );

int fli_get_string_widthTABfs( XFontStruct *,
                               const char *,
                               int );

void fli_init_font( void );

void fli_canonicalize_rect( FL_Coord *,
                            FL_Coord *,
                            FL_Coord *,
                            FL_Coord * );

void fli_get_goodie_title( FL_FORM *,
                           const char * );

void fli_add_q_icon( FL_Coord,
                     FL_Coord,
                     FL_Coord,
                     FL_Coord );

void fli_add_warn_icon( FL_Coord,
                        FL_Coord,
                        FL_Coord,
                        FL_Coord );

void fli_check_key_focus( const char *,
                          Window );

void fli_free_cmdline_args( void );

FL_RECT * fli_get_underline_rect( XFontStruct *,
                                  FL_Coord,
                                  FL_Coord,
                                  const char *,
                                  int );


/* Group some WM stuff into a structure for easy maintainance */

typedef struct {
    unsigned int pos_request;   /* USPOSITION or PPOSITION            */
} FLI_WM_STUFF;


/* Routines in sldraw.c. */

typedef struct {
    FL_Coord x;
    FL_Coord y;
    FL_Coord w;
    FL_Coord h;
} FLI_SCROLLBAR_KNOB;

enum {
    FLI_SLIDER_NONE = 0,
    FLI_SLIDER_BOX  = 1,
    FLI_SLIDER_KNOB = 2,
    FLI_SLIDER_ALL  = 3
};


void fli_calc_slider_size( FL_OBJECT *,
                           FLI_SCROLLBAR_KNOB * );

void fli_drw_slider( FL_OBJECT *,
                     FL_COLOR,
                     FL_COLOR,
                     const char *,
                     int );

void fli_drw_checkbox( int      type,
                       FL_Coord x,
                       FL_Coord y,
                       FL_Coord w,
                       FL_Coord h,
                       FL_COLOR col,
                       int      bw );

void fli_set_global_clipping( FL_Coord,
                              FL_Coord,
                              FL_Coord,
                              FL_Coord );

void fli_unset_global_clipping( void );

void fli_set_additional_clipping( FL_Coord,
                                  FL_Coord,
                                  FL_Coord,
                                  FL_Coord );

FL_RECT * fli_get_global_clip_rect( void );


/* Application windows */

typedef struct fli_win_ {
    struct fli_win_ * next;
    Window            win;
    FL_APPEVENT_CB    pre_emptive;      /* always gets called first if set */
    FL_APPEVENT_CB    callback[ LASTEvent ];
    void            * pre_emptive_data;
    void            * user_data[ LASTEvent ];
    FL_APPEVENT_CB    default_callback;
    unsigned long     mask;
} FLI_WIN;

extern FLI_WIN * fl_app_win;

void fli_set_form_window( FL_FORM * );

void fli_unmap_canvas_window( FL_OBJECT * );

FL_APPEVENT_CB fli_set_preemptive_callback( Window,
                                            FL_APPEVENT_CB,
                                            void * );

unsigned long fli_xevent_to_mask( int );

int fli_initialize_program_visual( void );


#define FLI_TIMER_RES           50  /* resolution of FL_STEP event */


/* Currently only one idle procedure is permitted, so the next
 * field is of no much use */

typedef struct fli_idle_cb_ {
    FL_APPEVENT_CB        callback;
    void                * data;
} FLI_IDLE_REC;

typedef struct fli_io_event_ {
    struct fli_io_event_ * next;
    FL_IO_CALLBACK         callback;
    void                 * data;
    unsigned int           mask;
    int                    source;
} FLI_IO_REC;


/* signals */

#if ! defined HAVE_SIGACTION
typedef RETSIGTYPE ( * FLI_OSSIG_HANDLER )( int );
#endif

typedef struct fli_signallist_ {
    struct fli_signallist_ * next;
    FL_SIGNAL_HANDLER        callback;
#if defined HAVE_SIGACTION
    struct sigaction         old_sigact;
#else
    FLI_OSSIG_HANDLER        ocallback; /* default OS signal handler */
#endif
    void                   * data;
    int                      signum;
    int                      caught;
} FLI_SIGNAL_REC;

void fli_remove_all_signal_callbacks( void );

/* timeouts */

typedef struct fli_timeout_ {
    int                    id;
    struct fli_timeout_  * next;
    struct fli_timeout_  * prev;
    long                   start_sec,
                           start_usec;
    long                   ms_to_wait;
    FL_TIMEOUT_CALLBACK    callback;
    void                 * data;
} FLI_TIMEOUT_REC;

void fli_remove_all_timeouts( void );

/*
 *  Intenal controls.
 */

typedef struct fli_context_ {
    FL_FORM_ATCLOSE      atclose;           /* what to do if WM_DELETE_WINDOW */
    void               * close_data;
    FLI_IDLE_REC       * idle_rec;          /* idle callback record   */
    FLI_IO_REC         * io_rec;            /* async IO record        */
    FLI_SIGNAL_REC     * signal_rec;        /* list of app signals    */
    FLI_TIMEOUT_REC    * timeout_rec;       /* timeout callbacks      */
    int                  idle_delta;        /* timer resolution       */
    int                  last_event;        /* last event received    */
    long                 mouse_button;      /* push/release record    */
    int                  pup_id;            /* current active pup id  */
    FL_FORM            * modal;             /* current modal form     */
    long                 max_request_size;  /* max protocol size      */
    int                  num_io;
    int                  hscb,
                         vscb;              /* default scrollbar      */
    long                 ext_request_size;  /* extended request size  */
    int                  tooltip_time;
#ifdef XlibSpecificationRelease
    XIM                  xim;               /* input method           */
    XIC                  xic;               /* input context          */
#else
    void               * xim;
    void               * xic;
#endif
    unsigned int         navigate_mask;     /* input field            */
    long                 reserverd[ 6 ];
} FLI_CONTEXT;

/* Some X info that helps to make the windowing system independent
 * API work (fl_color() etc. */

typedef struct {
    Display       * display;
    Window          win;
    GC              gc,
                    textgc;
    GC              miscgc;
    int             isRGBColor;
    int             isMBFont;       /* multi-byte font       */
    unsigned long   bktextcolor;
    int             newpix;
    int             fdesc;          /* font descent          */
    int             fasc;           /* font ascent           */
    int             fheight;        /* font height           */
    Colormap        colormap;
    XFontStruct   * fs;
    unsigned long   color;          /* last color. cache     */
    unsigned long   textcolor;      /* last textcolor. cache */
    unsigned long   bkcolor;
    int             screen;
} FLI_TARGET;


typedef struct {
    FL_FORM      ** forms;             /* all forms, visible and hidden */
    int             formnumb;          /* number of visible forms */
    int             hidden_formnumb;   /* number of hidden forms */
    size_t          auto_count;
    int             unmanaged_count;

    FL_Coord        mousex,            /* last recorded mouse position */
                    mousey;
    unsigned int    keymask;           /* state of buttons and modifier keys */
    unsigned int    query_age;         /* age of recorded information */

    FL_FORM       * mouseform;         /* the current form under the mouse */
    FL_FORM       * keyform;           /* keyboard focus form */

    FL_OBJECT * pushobj;               /* latest pushed object */
    FL_OBJECT * mouseobj;              /* object under the mouse */
} FLI_INTERNAL;

extern FLI_INTERNAL fli_int;


void fli_init_context( void );


#include "extern.h"


void fli_watch_io( FLI_IO_REC *,
                   long );

int fli_do_shortcut( FL_FORM *,
                     int,
                     FL_Coord,
                     FL_Coord,
                     XEvent * );

int fli_test_lalign( int          align,
                     const char * txt );

void fli_get_hv_align( int,
                       int *,
                       int * );

void fli_get_outside_align( int,
                            int,
                            int,
                            int,
                            int,
                            int *,
                            int *,
                            int * );

void fli_init_symbols( void );

void fli_release_symbols( void );

int fli_handle_event_callbacks( XEvent * );


/* Some macros to test how an object can be moved or resized, depending on
   its gravity settings (ULC = uppler left hand cornner, LRC = lower right
   hand corner) */

#define ULC_POS_LEFT_FIXED( obj )                \
    (    ( obj )->nwgravity == FL_NorthWest      \
      || ( obj )->nwgravity == FL_West           \
      || ( obj )->nwgravity == FL_SouthWest )

#define ULC_POS_RIGHT_FIXED( obj )               \
    (    ( obj )->nwgravity == FL_NorthEast      \
      || ( obj )->nwgravity == FL_East           \
      || ( obj )->nwgravity == FL_SouthEast )

#define LRC_POS_LEFT_FIXED( obj )                \
    (    ( obj )->segravity == FL_NorthWest      \
      || ( obj )->segravity == FL_West           \
      || ( obj )->segravity == FL_SouthWest )

#define LRC_POS_RIGHT_FIXED( obj )               \
    (    ( obj )->segravity == FL_NorthEast      \
      || ( obj )->segravity == FL_East           \
      || ( obj )->segravity == FL_SouthEast )

#define HAS_FIXED_HORI_ULC_POS( obj )                             \
    ( ULC_POS_LEFT_FIXED( obj ) || ULC_POS_RIGHT_FIXED( obj ) )

#define HAS_FIXED_HORI_LRC_POS( obj )                             \
    ( LRC_POS_LEFT_FIXED( obj ) || LRC_POS_RIGHT_FIXED( obj ) )

#define HAS_FIXED_WIDTH( obj )                                          \
    ( HAS_FIXED_HORI_ULC_POS( obj ) && HAS_FIXED_HORI_LRC_POS( obj ) ) 


#define ULC_POS_TOP_FIXED( obj )                 \
    (    ( obj )->nwgravity == FL_NorthWest      \
      || ( obj )->nwgravity == FL_North          \
      || ( obj )->nwgravity == FL_NorthEast )

#define ULC_POS_BOTTOM_FIXED( obj )              \
    (    ( obj )->nwgravity == FL_SouthWest      \
      || ( obj )->nwgravity == FL_South          \
      || ( obj )->nwgravity == FL_SouthEast )

#define LRC_POS_TOP_FIXED( obj )                 \
    (    ( obj )->segravity == FL_NorthWest      \
      || ( obj )->segravity == FL_North          \
      || ( obj )->segravity == FL_NorthEast )

#define LRC_POS_BOTTOM_FIXED( obj )              \
    (    ( obj )->segravity == FL_SouthWest      \
      || ( obj )->segravity == FL_South          \
      || ( obj )->segravity == FL_SouthEast )

#define HAS_FIXED_VERT_ULC_POS( obj )                             \
    ( ULC_POS_TOP_FIXED( obj ) || ULC_POS_BOTTOM_FIXED( obj ) )

#define HAS_FIXED_VERT_LRC_POS( obj )                             \
    ( LRC_POS_TOP_FIXED( obj ) || LRC_POS_BOTTOM_FIXED( obj ) )

#define HAS_FIXED_HEIGHT( obj )                                         \
    ( HAS_FIXED_VERT_ULC_POS( obj ) && HAS_FIXED_VERT_LRC_POS( obj ) ) 



#define XK_PageUp    XK_Prior
#define XK_PageDn    XK_Next

#define XK_PageUp    XK_Prior
#define XK_PageDn    XK_Next


/* some header has XK_XP_Left etc */

#if XlibSpecificationRelease >= 6

#define IsHome( k )     ( k == XK_Home  || k == XK_Begin || k == XK_KP_Home )
#define IsLeft( k )     ( k == XK_Left  || k == XK_KP_Left )
#define IsRight( k )    ( k == XK_Right || k == XK_KP_Right )
#define IsUp( k )       ( k == XK_Up    || k == XK_KP_Up )
#define IsDown( k )     ( k == XK_Down  || k == XK_KP_Down )
#define IsEnd( k )      ( k == XK_End   || k == XK_KP_End )
#define IsPageDown( k ) ( k == XK_Next  || k == XK_Page_Down || k == XK_KP_Page_Down )
#define IsPageUp( k )   ( k == XK_Prior || k == XK_Page_Up || k==XK_KP_Page_Up)

#else

#define IsHome( k )     ( k == XK_Home  || k == XK_Begin )
#define IsLeft( k )     ( k == XK_Left )
#define IsRight( k )    ( k == XK_Right )
#define IsDown( k )     ( k == XK_Down )
#define IsUp( k )       ( k == XK_Up )
#define IsEnd( k )      ( k == XK_End )
#define IsPageDown( k ) ( k == XK_Next )
#define IsPageUp( k )   ( k == XK_Prior )

#endif

#define FLI_HALFPAGE_UP        0x10000000
#define FLI_HALFPAGE_DOWN      0x20000000
#define FLI_NLINES_UP          0x30000000
#define FLI_NLINES_DOWN        0x40000000
#define FLI_1LINE_UP           0x50000000
#define FLI_1LINE_DOWN         0x60000000
#define IsHalfPageUp( k )      ( ( k ) == FLI_HALFPAGE_UP )
#define IsHalfPageDown( k )    ( ( k ) == FLI_HALFPAGE_DOWN )
#define IsNLinesUp( k )        ( ( k ) == FLI_NLINES_UP )
#define IsNLinesDown( k )      ( ( k ) == FLI_NLINES_DOWN )
#define Is1LineUp( k )         ( ( k ) == FLI_1LINE_UP )
#define Is1LineDown( k )       ( ( k ) == FLI_1LINE_DOWN )


void fli_hide_and_get_region( FL_OBJECT *,
                              Region    * );

int fli_convert_shortcut( const char *,
                          long * );

int fli_get_underline_pos( const char *,
                           const char * );

int fli_get_visible_forms_index( FL_FORM * );

void fli_recount_auto_objects( void );

int fli_get_tabpixels( XFontStruct * );

int fli_get_default_scrollbarsize( FL_OBJECT * );

void fli_set_app_name( const char *,
                       const char * );

void fli_hide_composite( FL_OBJECT *,
                         Region    * );

void fli_show_composite( FL_OBJECT * );

void fli_deactivate_composite( FL_OBJECT * );

void fli_activate_composite( FL_OBJECT * );

void fli_delete_composite( FL_OBJECT * ob );

void fli_free_composite( FL_OBJECT * ob );

void fli_set_composite_gravity( FL_OBJECT *,
                                unsigned int,
                                unsigned int );

void fli_set_composite_resize( FL_OBJECT *,
                               unsigned int );

void fli_composite_has_been_resized( FL_OBJECT * );

void fli_parse_goodies_label( FL_OBJECT *,
                              const char * );

int fli_goodies_preemptive( FL_FORM *,
                            void * );

void fli_get_goodies_font( int *,
                           int * );

void fli_handle_goodie_font( FL_OBJECT *,
                             FL_OBJECT * );

void fli_goodies_cleanup( void );

void fli_msg_cleanup( void );

void fli_alert_cleanup( void );

void fli_choice_cleanup( void );

void fli_question_cleanup( void );

void fli_input_cleanup( void );

void fli_sinput_cleanup( void );

void fli_handle_timeouts( long * );

#define FL_IS_NONSQRBOX( t ) (    t == FL_SHADOW_BOX          \
                               || t == FL_NO_BOX              \
                               || t == FL_RFLAT_BOX           \
                               || t == FL_ROUNDED_BOX         \
                               || t == FL_OVAL_BOX            \
                               || t == FL_ROUNDED3D_UPBOX     \
                               || t == FL_ROUNDED3D_DOWNBOX )

enum {
    FLI_TRIANGLE_UPBOX1,
    FLI_TRIANGLE_UPBOX2,
    FLI_TRIANGLE_UPBOX3,
    FLI_TRIANGLE_UPBOX4,
    FLI_TRIANGLE_UPBOX6,
    FLI_TRIANGLE_UPBOX7,
    FLI_TRIANGLE_UPBOX8,
    FLI_TRIANGLE_UPBOX9,
    FLI_TRIANGLE_DOWNBOX1,
    FLI_TRIANGLE_DOWNBOX2,
    FLI_TRIANGLE_DOWNBOX3,
    FLI_TRIANGLE_DOWNBOX4,
    FLI_TRIANGLE_DOWNBOX6,
    FLI_TRIANGLE_DOWNBOX7,
    FLI_TRIANGLE_DOWNBOX8,
    FLI_TRIANGLE_DOWNBOX9
};

FL_RECT * fli_intersect_rects( const FL_RECT *,
                               const FL_RECT * );

void fli_xyplot_nice_label( float,
                            int,
                            float,
                                   char * );

void fli_xyplot_compute_data_bounds( FL_OBJECT *,
                                     int *,
                                     int *,
                                     int );

int fli_xyplot_interpolate( FL_OBJECT *,
                            int,
                            int,
                            int );

void fli_insert_composite_after( FL_OBJECT *,
                                 FL_OBJECT * );

void fli_add_composite( FL_OBJECT * );

void fli_insert_composite( FL_OBJECT *,
                           FL_OBJECT * );

int fli_is_watched_io( int );

const char * fli_object_class_name( FL_OBJECT * );

char * fli_read_line( FILE * fp );

char * fli_sstrcpy( char       * dest,
                    const char * src,
                    size_t       n );

void fli_set_form_icon_data( FL_FORM *,
                             char ** );

char *fli_getcwd( char *,
                  int );

void fli_replacepup_text( int,
                          int,
                          const char * );

int fli_valuator_handle_drag( FL_OBJECT *,
                              double );

int fli_valuator_handle_release( FL_OBJECT *,
                                 double );

void *fli_init_valuator( FL_OBJECT * );

double fli_valuator_round_and_clamp( FL_OBJECT *,
                                     double );

double fli_clamp( double,
                  double,
                  double );

void fli_inherit_attributes( FL_OBJECT *,
                             FL_OBJECT * );

int fli_boxtype2frametype( int );

void fli_xvisual2flstate( FL_State *,
                          XVisualInfo * );

int fli_find_closest_color( int,
                            int,
                            int,
                            XColor *,
                            int,
                            unsigned long * );

void fli_rgbmask_to_shifts( unsigned long,
                            unsigned int *,
                            unsigned int * );

void fli_show_tooltip( const char *,
                       int,
                       int );

void fli_hide_tooltip( void );

int fli_is_tooltip_form( FL_FORM * );

void fli_do_radio_push( FL_OBJECT *,
                        FL_Coord,
                        FL_Coord,
                        int,
                        void *,
                        int );

long fli_getpid( void );

void fli_xlinestyle( Display *,
                     GC,
                     int );

#define FLI_BROKEN_BOX  ( 1 << 10 )

FLI_TARGET * fli_internal_init( void );

void fli_switch_target( FLI_TARGET * );

void fli_restore_target( void );

void fli_draw_text_inside( int align,
                           FL_Coord,
                           FL_Coord,
                           FL_Coord,
                           FL_Coord,
                           const char *,
                           int,
                           int,
                           FL_COLOR,
                           FL_COLOR,
                           int );

/* Misc. stuff */

void fli_add_vertex( FL_Coord x,
                     FL_Coord y );

void fli_add_float_vertex( float x,
                           float y );

void fli_reset_vertex( void );

void fli_endpolygon( void );

void fli_endclosedline( void );

void fli_endline( void );

const char * fli_get_xevent_name( const XEvent * );

void fli_set_input_navigate( unsigned int mask );

void fli_adjust_browser_scrollbar( FL_OBJECT * );

FL_POPUP * fli_popup_add( Window,
                          const char *,
                          const char * );

FL_POPUP_ENTRY * fli_popup_add_entries( FL_POPUP *,
                                        const char *,
                                        va_list,
                                        const char *,
                                        int );

FL_POPUP_ENTRY * fli_popup_insert_entries( FL_POPUP *,
                                           FL_POPUP_ENTRY *,
                                           const char *,
                                           va_list,
                                           const char *,
                                           int );

FL_POPUP_ENTRY * fli_popup_insert_items( FL_POPUP       *,
                                         FL_POPUP_ENTRY *,
                                         FL_POPUP_ITEM  *,
                                         const char * );

void fli_popup_init( void );

void fli_popup_finish( void );

int fli_check_popup_exists( FL_POPUP * );

int fli_check_popup_entry_exists( FL_POPUP_ENTRY * );

FL_POPUP_RETURN * fli_set_popup_return( FL_POPUP_ENTRY * );

void fli_popup_reset_counter( FL_POPUP * );

void fli_free_cursors( void );

void fli_free_fselectors( void );


/*  Some utility stuff */

typedef struct {
    int          val;
    const char * name;
} FLI_VN_PAIR;

int fli_get_vn_value( FLI_VN_PAIR * vn_pair,
                      const char  * name );

const char * fli_get_vn_name( FLI_VN_PAIR * vn_pair,
                              int           val );

#if XlibSpecificationRelease == 6

#  define IsTab( ksym )  ( ksym == XK_ISO_Left_Tab || ksym== XK_Tab )

#else

#  define IsTab( ksym )  ( ksym == XK_Tab )

#endif

void fli_set_tab_color( FL_OBJECT * obj,
                        FL_COLOR    col1,
                        FL_COLOR    col2 );

void fli_set_tab_lcolor( FL_OBJECT * obj,
                         FL_COLOR    lcol );

void fli_set_tab_lsize( FL_OBJECT * obj,
                        int         lsize );

void fli_set_tab_lstyle( FL_OBJECT * obj,
                         int         lstyle );

void fli_set_tab_lalign( FL_OBJECT * obj,
                         int         align );

void fli_set_tab_bw( FL_OBJECT * obj,
                     int         bw );
void fli_textcolor( FL_COLOR col );

void fli_bk_textcolor( FL_COLOR col );

char * fli_fix_dirname( char * dir );

Cursor fli_get_cursor_byname( int name );

void fli_hide_canvas( FL_OBJECT * ob );

const char * fli_vclass_name( int n );

int fli_vclass_val( const char * v );

void fli_set_ul_property( int prop,
                          int thickness );

int fli_is_valid_dir( const char * name );


#endif /* ! defined FL_INTERNAL_H */


/*
 * Local variables:
 * tab-width: 4
 * indent-tabs-mode: nil
 * End:
 */