1 /* coollocal.h  - header for internel usage
2    Copyright (C) 1996-2017 Paul Sheer
3 
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8 
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13 
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307, USA.
18  */
19 
20 #ifndef COOLLOCAL_H
21 #define COOLLOCAL_H
22 
23 #include "xim.h"
24 
25 #define WIDE_CHAR
26 
27 extern Atom ATOM_ICCCM_P2P_CLIPBOARD;
28 
29 /* Various rendering routines called internally */
30 void render_bevel (Window win, int x1, int y1, int x2, int y2, int thick, int sunken);
31 long render_textbox (CWidget * w, int redrawall);
32 void render_bitmap_button (CWidget * w, int state);
33 void render_bw_image (CWidget * w, int x, int y, int rendw, int rendh);
34 void render_button (CWidget * w);
35 void render_textinput (CWidget * w);
36 void render_window (CWidget * w);
37 void render_bar (CWidget * w);
38 void render_text (CWidget * w);
39 void render_status (CWidget * w, int expose);
40 void render_scrollbar (CWidget * w);
41 void render_sunken (CWidget * w);
42 int which_scrollbar_button (int bx, int by, CWidget * w);
43 long count_textbox_lines (CWidget * w, int all);
44 void render_progress (CWidget * w);
45 void render_switch (CWidget * w);
46 int (*default_event_handler (int kindofwidget)) (CWidget *, XEvent *, CEvent *);
47 CWidget **find_empty_widget_entry (void);
48 CWidget *allocate_widget (Window newwin,
49 			  const char *ident, Window parent, int x, int y,
50 			  int width, int height, int kindofwidget);
51 int eh_picture (struct cool_widget *w, XEvent * xevent, CEvent * cwevent);
52 void drawstring_xy (Window win, int x, int y, const char *text);
53 void drawstring_xy_hotkey (Window win, int x, int y, const char *text, int hotkey);
54 int run_callbacks (CWidget * w, XEvent * xevent, CEvent * cwevent);
55 void process_external_focus (Window win, int type);
56 void focus_window (Window win);
57 void link_scrollbar_to_textbox (CWidget * w, CWidget * textbox, XEvent * xevent, CEvent * cwevent, int whichscrbutton);
58 void link_scrollbar_to_editor (CWidget * w, CWidget * editor, XEvent * xevent, CEvent * cwevent, int whichscrbutton);
59 void destroy_picture (CWidget * w);
60 int edit_translate_key (unsigned int x_keycode, long x_key, int x_state, int *cmd, long *ch);
61 void toggle_cursor (void);
62 
63 /* returns non-zero if they keysym of one of the control keys (shift, capslock etc.) */
64 int mod_type_key (KeySym x);
65 
66 Window my_XmuClientWindow (Display * dpy, Window win);
67 
68 /* initialise drag and drop */
69 void initialise_drag_n_drop (void);
70 void render_focus_border (Window win);
71 
72 void toggle_radio_button (CWidget * w);
73 char *whereis_hotchar (const char *labl, int hotkey);
74 int match_hotkey (KeySym a, KeySym b);
75 int find_hotkey (CWidget * w);
76 int find_letter_at_word_start (unsigned char *label, unsigned char *used_keys, int n);
77 
78 void set_font_tab_width (int t);
79 int get_font_tab_width (void);
80 
81 void destroy_focus_border (void);
82 void create_focus_border (CWidget * w, int border);
83 void render_rounded_bevel (Window win, int x1, int y1, int x2, int y2, int radius, int thick, int sunken);
84 long create_input_context (CWidget * w, XIMStyle input_style);
85 long set_status_position (CWidget * w);
86 XIMStyle get_input_style (void);
87 
88 typedef long (*for_all_widgets_cb_t) (CWidget *, void *, void *);
89 long for_all_widgets (for_all_widgets_cb_t call_back, void *data1, void *data2);
90 
91 
92 typedef union {
93     struct {
94 	unsigned char fg;
95 	unsigned char bg;
96 	unsigned short style;
97 	unsigned int ch;
98     } c;
99     unsigned int _style;
100 } cache_type;
101 
102 void edit_draw_proportional (void *data,
103 	   void (*converttext) (void *, long, cache_type *, cache_type *, int, int, int),
104 	   int calctextpos (void *, long, long *, int),
105 				int scroll_right,
106 				Window win,
107 				int x_max,
108 				long b,
109 				int row,
110 				int y,
111 				int x_offset,
112 				int tabwidth);
113 
114 
115 #endif				/* ! COOLLOCAL_H */
116 
117