olaf neophyte and de.po updates, valgrind tweaks, delete green lady, inkscape dpi=96
[goodguy/history.git] / cinelerra-5.1 / guicast / bcwindowbase.h
index af271e49bf82103c6391ecfafe376eae8c140419..ca73b39e61c696d37648cf3243243475ece56daa 100644 (file)
 #ifndef BCWINDOWBASE_H
 #define BCWINDOWBASE_H
 
-#if defined(HAVE_CONFIG_H)
-#include "config.h"
-#endif
-
-//#define HAVE_LIBXXF86VM
-
 // Window types
 #define MAIN_WINDOW 0
 #define SUB_WINDOW 1
@@ -71,6 +65,7 @@
 #include "bctimer.inc"
 #include "bctitle.inc"
 #include "bctoggle.inc"
+#include "bctrace.inc"
 #include "bctumble.inc"
 #include "bcwindow.inc"
 #include "bcwindowbase.inc"
@@ -98,6 +93,7 @@
 #endif
 #include <X11/extensions/Xinerama.h>
 #ifdef HAVE_GL
+#define GL_GLEXT_PROTOTYPES
 #include <GL/glx.h>
 #endif
 
@@ -130,10 +126,10 @@ public:
 
 
 // Windows, subwindows, popupwindows inherit from this
-class BC_WindowBase
+class BC_WindowBase : public trace_info
 {
 public:
-       BC_WindowBase(int opts=0);
+       BC_WindowBase();
        virtual ~BC_WindowBase();
 
        friend class BC_Bar;
@@ -198,14 +194,17 @@ public:
        virtual int drag_motion_event() { return 0; };
        virtual int drag_stop_event() { return 0; };
        virtual int uses_text() { return 0; };
+       virtual int selection_clear_event() { return 0; }
 // Only if opengl is enabled
        virtual int expose_event() { return 0; };
+       virtual int grab_event(XEvent *event) { return 0; };
        virtual void create_objects() { return; };
 
        int get_window_type() { return window_type; }
 // Wait until event loop is running
        void init_wait();
        int is_running() { return window_running; }
+       int is_hidden() { return hidden; }
 // Check if a hardware accelerated colormodel is available and reserve it
        int accel_available(int color_model, int lock_it);
        void get_input_context();
@@ -225,7 +224,6 @@ public:
        int get_deleting();
 
 
-
 //============================= OpenGL functions ===============================
 // OpenGL functions must be called from inside a BC_Synchronous command.
 // Create openGL context and bind it to the current window.
@@ -270,23 +268,30 @@ public:
        virtual int keyboard_listener(BC_WindowBase *wp) { return 0; }
        void add_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *));
        void del_keyboard_listener(int(BC_WindowBase::*handler)(BC_WindowBase *));
+       int resend_event(BC_WindowBase *window);
 // Dimensions
-       virtual int get_w();
-       virtual int get_h();
-       virtual int get_x();
-       virtual int get_y();
+       virtual int get_w() { return w; }
+       virtual int get_h() { return h; }
+       virtual int get_x() { return x; }
+       virtual int get_y() { return y; }
        int get_root_w(int lock_display);
        int get_root_h(int lock_display);
        XineramaScreenInfo *get_xinerama_info(int screen);
+       void get_fullscreen_geometry(int &wx, int &wy, int &ww, int &wh);
        int get_screen_w(int lock_display, int screen);
        int get_screen_h(int lock_display, int screen);
        int get_screen_x(int lock_display, int screen);
        int get_screen_y(int lock_display, int screen);
 // Get current position
-       int get_abs_cursor_x(int lock_window);
-       int get_abs_cursor_y(int lock_window);
-       int get_relative_cursor_x();
-       int get_relative_cursor_y();
+       void get_abs_cursor(int &abs_x, int &abs_y, int lock_window=0);
+       int get_abs_cursor_x(int lock_window=0);
+       int get_abs_cursor_y(int lock_window=0);
+       void get_pop_cursor(int &px, int &py, int lock_window=0);
+       int get_pop_cursor_x(int lock_window=0);
+       int get_pop_cursor_y(int lock_window=0);
+       void get_relative_cursor(int &x, int &y, int lock_window=0);
+       int get_relative_cursor_x(int lock_window=0);
+       int get_relative_cursor_y(int lock_window=0);
        void get_root_coordinates(int x, int y, int *abs_x, int *abs_y);
        void get_win_coordinates(int abs_x, int abs_y, int *x, int *y);
 // Return 1 if cursor is over an unobscured part of this window.
@@ -394,8 +399,8 @@ public:
                BC_Pixmap *pixmap = 0, int is_utf8 = 0);
        void draw_xft_text(int x, int y, const wchar_t *text,
                int length, BC_Pixmap *pixmap);
-       void draw_wtext(int x, int y, const wchar_t *text, int length = -1,
-               BC_Pixmap *pixmap = 0, int *charpos = 0);
+       int draw_single_text(int draw, int font,
+               int x, int y, const wchar_t *text, int length = -1, BC_Pixmap *pixmap = 0);
 // truncate the text to a ... version that fits in the width, using the current_font
        void truncate_text(char *result, const char *text, int w);
        void draw_center_text(int x, int y, const char *text, int length = -1);
@@ -446,15 +451,23 @@ public:
        void set_background(VFrame *bitmap);
 // Change the window title.
        void put_title(const char *text);
-       void set_title(const char *text);
+       void set_title(const char *text, int utf8=1);
        const char *get_title();
-       void set_utf8title(const char *text);
 // Change the window title.  The title is translated internally.
        void start_video();
        void stop_video();
        int get_id();
        void set_done(int return_value);
        void close(int return_value);
+// Reroute toplevel events
+       int grab(BC_WindowBase *window);
+       int ungrab(BC_WindowBase *window);
+       int grab_event_count();
+// Grab button events
+       int grab_buttons();
+       void ungrab_buttons();
+       void grab_cursor();
+       void ungrab_cursor();
 // Get a bitmap to draw on the window with
        BC_Bitmap* new_bitmap(int w, int h, int color_model = -1);
 // Draw a bitmap on the window
@@ -483,6 +496,8 @@ public:
        void slide_right(int distance);
        void slide_up(int distance);
        void slide_down(int distance);
+       void flicker(int n=3, int ms=66);
+       void focus();
 
        int cycle_textboxes(int amount);
 
@@ -502,7 +517,8 @@ public:
        int unset_repeat(int64_t duration);
        const char *get_tooltip();
        int set_tooltip(const char *text);
-       int show_tooltip(int w = -1, int h = -1);
+       virtual int show_tooltip(const char *text, int x=-1, int y=-1, int w = -1, int h = -1);
+       int show_tooltip(int w=-1, int h=-1) { return show_tooltip(0, -1, -1, w, h); }
        int hide_tooltip();
        int set_icon(VFrame *data);
        int load_defaults(BC_Hash *defaults);
@@ -515,6 +531,9 @@ public:
    void restore_vm();
 #endif
 
+       Atom to_clipboard(const char *data, long len, int clipboard_num);
+       long from_clipboard(char *data, long maxlen, int clipboard_num);
+       long clipboard_len(int clipboard_num);
 
        int test_keypress;
        char keys_return[KEYPRESSLEN];
@@ -534,8 +553,8 @@ private:
        int get_screen();
        virtual int initialize();
        int get_atoms();
-// Function to overload to recieve customly defined atoms
-       virtual int recieve_custom_xatoms(xatom_event *event);
+// Function to overload to receive customly defined atoms
+       virtual int receive_custom_xatoms(xatom_event *event);
 
        void init_cursors();
        int init_colors();
@@ -544,6 +563,7 @@ private:
        int create_private_colors();
        int create_color(int color);
        int create_shared_colors();
+       Cursor create_grab_cursor();
 // Get width of a single line.  Used by get_text_width
        int get_single_text_width(int font, const char *text, int length);
        int get_single_text_width(int font, const wchar_t *text, int length);
@@ -559,7 +579,6 @@ private:
        int64_t get_color_bgr24(int color);
        XFontStruct* get_font_struct(int font);
        XftFont* get_xft_struct(int font);
-       int wcharpos(const wchar_t *text, XftFont *font, int length, int *charpos);
        Cursor get_cursor_struct(int cursor);
        XFontSet get_fontset(int font);
        XFontSet get_curr_fontset(void);
@@ -570,8 +589,8 @@ private:
 
        int trigger_tooltip();
        int untrigger_tooltip();
-       void draw_tooltip();
-       int arm_repeat(int64_t duration);
+       void draw_tooltip(const char *text=0);
+       static XEvent *new_xevent();
 // delete all repeater opjects for a close
        int unset_all_repeaters();
 
@@ -581,9 +600,14 @@ private:
        int get_event_count();
 // Put event in common events.
        void put_event(XEvent *event);
+// remove events queued for win
+       void dequeue_events(Window win);
+// clear selection
+       int do_selection_clear(Atom selection);
 
 // Recursive event dispatchers
        int dispatch_resize_event(int w, int h);
+       int dispatch_flash();
        int dispatch_focus_in();
        int dispatch_focus_out();
        int dispatch_motion_event();
@@ -600,13 +624,16 @@ private:
        int dispatch_drag_motion();
        int dispatch_drag_stop();
        int dispatch_expose_event();
+       int dispatch_selection_clear();
 
 // Get the port ID for a color model or return -1 for failure
-       int grab_port_id(BC_WindowBase *window, int color_model);
+       int grab_port_id(int color_model);
 
        int find_next_textbox(BC_WindowBase **first_textbox, BC_WindowBase **next_textbox, int &result);
        int find_prev_textbox(BC_WindowBase **last_textbox, BC_WindowBase **prev_textbox, int &result);
 
+       void xft_draw_string(XftColor *xft_color, XftFont *xft_font, int x, int y,
+               const FcChar32 *fc, int len, BC_Pixmap *pixmap=0);
 
        void translate_coordinates(Window src_w, Window dest_w,
                int src_x, int src_y, int *dest_x_return, int *dest_y_return);
@@ -625,12 +652,16 @@ private:
        int light1, light2, medium, dark1, dark2, bg_color;
 // Type of window defined above
        int window_type;
+// keypress/pointer active grab
+       BC_WindowBase *active_grab, *grab_active;
 // Pointer to the active menubar in the window.
        BC_MenuBar* active_menubar;
 // pointer to the active popup menu in the window
        BC_PopupMenu* active_popup_menu;
 // pointer to the active subwindow
        BC_WindowBase* active_subwindow;
+// pointer to the window to which to put the current event
+       BC_WindowBase* resend_event_window;
 // thread id of display locker
        pthread_t display_lock_owner;
 
@@ -648,6 +679,8 @@ private:
        int video_on;
 // Event handler completion
        int done, done_set, window_running;
+// Enter/Leave notify state
+       int cursor_entered;
 // Return value of event handler
        int return_value;
 // Motion event compression
@@ -697,6 +730,7 @@ private:
 #ifndef SINGLE_THREAD
 // Array of repeaters for multiple repeating objects.
        ArrayList<BC_Repeater*> repeaters;
+       int arm_repeat(int64_t duration);
 #endif
 // Text for tooltip if one exists
        const char *tooltip_text;
@@ -709,25 +743,21 @@ private:
 // Popup window for tooltip
        BC_Popup *tooltip_popup;
 // If this subwindow has already shown a tooltip since the last EnterNotify
-       int tooltip_done;
-       int options;
-
+       int flash_enabled;
 
 
 // Font sets
-    XFontSet smallfontset, mediumfontset, largefontset, bigfontset, curr_fontset;
-
+       XFontSet smallfontset, mediumfontset, largefontset, bigfontset, clockfontset;
+       XFontSet curr_fontset;
 // Fonts
        int current_font;
-       XFontStruct *smallfont, *mediumfont, *largefont, *bigfont;
-
+       XFontStruct *smallfont, *mediumfont, *largefont, *bigfont, *clockfont;
 // Must be void so users don't need to include the wrong libpng version.
-       void *smallfont_xft, *mediumfont_xft, *largefont_xft, *bigfont_xft;
-
+       void *smallfont_xft, *mediumfont_xft, *largefont_xft, *bigfont_xft, *clockfont_xft;
+       void *bold_smallfont_xft, *bold_mediumfont_xft, *bold_largefont_xft;
 
        int line_width;
        int line_dashes;
-       void *bold_largefont_xft, *bold_mediumfont_xft, *bold_smallfont_xft;
        int64_t current_color;
 // Coordinate of drag start
        int drag_x, drag_y;
@@ -744,6 +774,8 @@ private:
        Window rootwin;
 // windows previous events happened in
        Window event_win, drag_win;
+// selection clear
+       Atom event_selection;
        Visual *vis;
        Colormap cmap;
 // Name of display
@@ -785,6 +817,7 @@ private:
 // Depth given by the X Server
        int default_depth;
        Atom DelWinXAtom;
+       Atom DestroyAtom;
        Atom ProtoXAtom;
        Atom RepeaterXAtom;
        Atom SetDoneXAtom;
@@ -812,6 +845,7 @@ private:
        Cursor downright_resize_cursor;
        Cursor hourglass_cursor;
        Cursor transparent_cursor;
+       Cursor grabbed_cursor;
 
        int xvideo_port_id;
        ArrayList<BC_ResizeCall*> resize_history;