Laxkit  0.0.7.1
laxutils.h
1 //
2 //
3 // The Laxkit, a windowing toolkit
4 // Please consult http://laxkit.sourceforge.net about where to send any
5 // correspondence about this software.
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //
21 // Copyright (C) 2004-2013 by Tom Lechner
22 //
23 #ifndef _LAX_LAXUTILS_H
24 #define _LAX_LAXUTILS_H
25 
26 
27 #include <lax/screencolor.h>
28 #include <lax/anxapp.h>
29 #include <lax/laximages.h>
30 #include <lax/vectors.h>
31 #include <lax/doublebbox.h>
32 #include <lax/displayer.h>
33 #include <lax/drawingdefs.h>
34 
35 
36 namespace Laxkit {
37 
38 
39  //drawing basics
41 void drawing_line_attributes(double width, int type, int cap, int join);
42 //ScreenColor forground_color(ScreenColor &color);
43 //ScreenColor background_color(ScreenColor &color);
44 void foreground_color(double r,double g,double b,double a=1);
45 void background_color(double r,double g,double b);
46 unsigned long foreground_color(unsigned long newcolor);
47 unsigned long background_color(unsigned long newcolor);
48 
49 void clear_window(anXWindow *win);
50 void draw_rectangle(aDrawable *win, double x, double y, double w, double h);
51 void fill_rectangle(aDrawable *win, double x, double y, double w, double h);
52 void draw_line(aDrawable *win, double x1,double y1, double x2,double y2);
53 void draw_arc(aDrawable *win, double x,double y, double xradius, double yradius, double start_radians, double end_radians);
54 void draw_arc_wh(aDrawable *win, double x,double y, double width, double height, double start_radians, double end_radians);
55 void fill_arc(aDrawable *win, double x,double y, double xradius, double yradius, double start_radians, double end_radians);
56 void fill_arc_wh(aDrawable *win, double x,double y, double width, double height, double start_radians, double end_radians);
57 void draw_lines(aDrawable *win, flatpoint *p, int n, int isclosed);
58 void fill_polygon(aDrawable *win, flatpoint *p, int n);
59 
60 void draw_bevel(aDrawable *win,int bevel,unsigned long highlight,unsigned long shadow,int state,double x,double y,double w,double h);
61 int draw_thing(aDrawable *win,double x, double y, double rx, double ry, int fill, DrawThingTypes thing);
62 int draw_thing(aDrawable *win,double x, double y, double rx, double ry, DrawThingTypes thing,unsigned long fg,unsigned long bg,int lwidth=1);
63 flatpoint *draw_thing_coordinates(DrawThingTypes thing, flatpoint *buffer, int buffer_size, int *n_ret,double scale=1,DoubleBBox *bounds=NULL);
64 
65 
66  //color utitilies
67 ScreenColor *coloravg(ScreenColor *result, ScreenColor *a, ScreenColor *b,float r=.5);
68 unsigned long pixelfromcolor(ScreenColor *col);
69 
70 unsigned long coloravg(unsigned long a,unsigned long b,float r=.5);
71 void colorrgb(unsigned long col,int *r,int *g,int *b);
72 unsigned long rgbcolor(int r,int g,int b);
73 unsigned long rgbcolorf(double r,double g,double b);
74 void set_color_shift_info(unsigned int rm, unsigned int gm, unsigned int bm, unsigned int am);
75 
76 
77  //mouse and coordinate utilities
78 int translate_window_coordinates(anXWindow *from, int x, int y, anXWindow *to, int *xx, int *yy, anXWindow **kid);
79 int mouseposition(int mouse_id, anXWindow *win, int *x, int *y, unsigned int *state,anXWindow **child,int *screen=NULL);
80 //Window xouseposition(XID mouse_id, int *x, int *y, unsigned int *state,anXWindow **child,Window *childw);
81 int mouseisin(XID mouse_id, anXWindow *win);
82 unsigned long screen_color_at_mouse(int mouse_id);
83 
84 
85  //text utilities
86 
87 #define LAX_ICON_ONLY (0)
88 #define LAX_TEXT_ONLY (1)
89 #define LAX_TEXT_ICON (2)
90 #define LAX_ICON_TEXT (3)
91 #define LAX_ICON_OVER_TEXT (4)
92 #define LAX_TEXT_OVER_ICON (5)
93 #define LAX_ICON_STYLE_MASK (7)
94 #define LAX_WAY_OFF (-1000000)
95 
96 double text_height();
97 LaxFont *get_default_font();
98 double getextent(const char *str,int len, double *ex,double *ey,double *fasc=NULL,double *fdes=NULL,char r=0);
99 double getextent(LaxFont *font, const char *str,int len,double *ex,double *ey,double *fasc,double *fdes,char r=0);
100 
101 double textout(aDrawable *win,const char *thetext,int len,double x,double y,unsigned long align);
102 double textout(aDrawable *win,LaxFont *font,const char *thetext,int len,double x,double y,unsigned long align);
103 double textout_rotated(aDrawable *win, double radians,const char *thetext,int len,double x,double y,unsigned long align);
104 double textout_rotated(aDrawable *win, LaxFont *font, double radians,const char *thetext,int len,double x,double y,unsigned long align);
105 double textout_matrix(aDrawable *win, double *m,const char *thetext,int len,double x,double y,unsigned long align);
106 
107 double textout_multiline(aDrawable *win,const char *thetext,int len,double x,double y,unsigned long align);
108 
109 void get_placement(LaxImage *image,const char *label,int gap,unsigned int how,
110  int *w,int *h,int *tx,int *ty,int *ix,int *iy);
111 void get_placement(int thingw, int thingh,const char *label,int gap,unsigned int how,
112  int *w,int *h,int *tx,int *ty,int *ix,int *iy);
113 
114 
115 
116 
117 
118 } //namespace Laxkit
119 
120 #endif
121 

Mon Feb 17 2014 11:52:56, Laxkit