123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /**
- *
- * Copyright (c) 2002, Marc Bruenink
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of his contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
- #ifndef _XLIB_TEXTFADER_H_
- #define _XLIB_TEXTFADER_H_
- #include <X11/Xlib.h>
- #include <X11/Xcms.h> // color
- #include <X11/Xutil.h> // XGetPixel
- #include <climits> // MAX_INT
- #include <ostream.h>
- #include <unistd.h>
- #include <stdlib.h> //rand()
- // class define
- //text will be faded in the center of the screen.
- #define TF_WINDOW_CENTER (1<<1)
- // Coordinates marks the middlex and middley of the text
- // default: upper left corner of text
- //#define TF_COORDINATES_CENTER (1<<2)
- // some defines for the arrangement method
- // first 2 bytes marks the row and last 2 bytes the column
- // use XOR !!!!
- #define TF_COORDINATES_UPPER_LEFT ((1<<2) |(1<<4))
- #define TF_COORDINATES_UPPER_CENTER ((1<<2) |(1<<5))
- #define TF_COORDINATES_UPPER_RIGHT ((1<<2) |(1<<4)|(1<<5))
- #define TF_COORDINATES_CENTER_LEFT ((1<<3) |(1<<4))
- #define TF_COORDINATES_CENTER_CENTER ((1<<3) |(1<<5))
- #define TF_COORDINATES_CENTER_RIGHT ((1<<3) |(1<<4)|(1<<5))
- #define TF_COORDINATES_LOWER_LEFT ((1<<2)|(1<<3) |(1<<4))
- #define TF_COORDINATES_LOWER_CENTER ((1<<2)|(1<<3) |(1<<5))
- #define TF_COORDINATES_LOWER_RIGHT ((1<<2)|(1<<3) |(1<<4)|(1<<5))
- #define TF_COORDINATES_SET(old, new) ((old & (~((unsigned long) (1<<2)|(1<<3)|(1<<4)|(1<<5)))) | new)
- #define TF_COORDINATES_GET(old) (old & ((unsigned long)(1<<2)|(1<<3)|(1<<4)|(1<<5)))
- class Xlib_textfader {
- Display *dpy;
- int screen;
- int screenHeight, screenWidth;
- int screenDepth;
- Visual *screenVisual;
- XFontStruct *font;
- XGCValues gc_val;
- unsigned long gc_valValueMask;
- XSetWindowAttributes attr;
- unsigned long attrValueMask;
- XColor textColor;
- // fade positions
- int pos_x, pos_y;
- public:
- Xlib_textfader();
- ~Xlib_textfader();
- // fade section
- int fade(char* text, int length, unsigned int fadeTime, unsigned long optionmask);
- inline int get_fade_position_x() {
- return pos_x;
- }
- inline int get_fade_position_y() {
- return pos_y;
- }
- inline void set_fade_position_x(int _x){
- pos_x = _x;
- }
- inline void set_fade_position_y(int _y) {
- pos_y = _y;
- }
- inline void set_fade_position(int _x, int _y){
- pos_y = _y;
- pos_x = _x;
- }
- // font section
- int get_font_height();
- int get_font_width();
- inline XFontStruct* get_font(){
- return font;
- }
- int set_font(char* name);
- char** get_list_fonts(int* count, char *pattern);
- // screen section
- inline int get_screen_height(){
- return screenHeight;
- }
- inline int get_screen_width() {
- return screenWidth;
- }
- // gc values section
- int set_text_color(char* name);
- int set_text_color(double red, double green, double blue);
- inline unsigned long get_text_color(){
- return gc_val.foreground;
- }
- };// end class
- #endif
|