#ifdef FEAT_GUI_MOTIF
# include <Xm/Xm.h>
#endif
#ifdef FEAT_GUI_ATHENA
# include <X11/Intrinsic.h>
# include <X11/StringDefs.h>
#endif
#ifdef FEAT_BEVAL
# include "gui_beval.h"
#endif
#ifdef FEAT_GUI_GTK
# ifdef VMS
# ifdef MAX
# undef MAX
# endif
# ifdef MIN
# undef MIN
# endif
# endif
# include <X11/Intrinsic.h>
# include <gtk/gtk.h>
#endif
#ifdef FEAT_GUI_MAC
# include <Types.h>
# include <Quickdraw.h>
# include <Fonts.h>
# include <Events.h>
# include <Menus.h>
# if !(defined (TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON))
# include <Windows.h>
# endif
# include <Controls.h>
# include <Dialogs.h>
# include <OSUtils.h>
#endif
#ifdef RISCOS
# include "gui_riscos.h"
#endif
#ifdef FEAT_GUI_PHOTON
# include <Ph.h>
# include <Pt.h>
# include "photon/PxProto.h"
#endif
#if defined(FEAT_GUI_MSWIN) || (defined(FEAT_GUI_MAC) && !defined(MACOS_X_UNIX))
# define ALWAYS_USE_GUI
#endif
#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MAC) || defined(HAVE_GTK2)
# define USE_ON_FLY_SCROLL
#endif
#if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_MAC) \
|| defined(FEAT_GUI_GTK)
# define HAVE_DROP_FILE
#endif
#ifdef FEAT_XFONTSET
# define FONTSET_ALWAYS
#endif
#ifdef FEAT_GUI_W32
# define TEXT_X(col) ((col) * gui.char_width)
# define TEXT_Y(row) ((row) * gui.char_height + gui.char_ascent)
# define FILL_X(col) ((col) * gui.char_width)
# define FILL_Y(row) ((row) * gui.char_height)
# define X_2_COL(x) ((x) / gui.char_width)
# define Y_2_ROW(y) ((y) / gui.char_height)
#else
# define TEXT_X(col) ((col) * gui.char_width + gui.border_offset)
# define FILL_X(col) ((col) * gui.char_width + gui.border_offset)
# define X_2_COL(x) (((x) - gui.border_offset) / gui.char_width)
# define TEXT_Y(row) ((row) * gui.char_height + gui.char_ascent \
+ gui.border_offset)
# define FILL_Y(row) ((row) * gui.char_height + gui.border_offset)
# define Y_2_ROW(y) (((y) - gui.border_offset) / gui.char_height)
#endif
#define SBAR_NONE -1
#define SBAR_LEFT 0
#define SBAR_RIGHT 1
#define SBAR_BOTTOM 2
#define SBAR_VERT 0
#define SBAR_HORIZ 1
#define SB_DEFAULT_WIDTH 16
#define MENU_DEFAULT_HEIGHT 1
#define GUI_MON_WRAP_CURSOR 0x01
#define GUI_MON_INVERT 0x02
#define GUI_MON_IS_CURSOR 0x04
#define GUI_MON_TRS_CURSOR 0x08
#define GUI_MON_NOCLEAR 0x10
#define DRAW_TRANSP 0x01
#define DRAW_BOLD 0x02
#define DRAW_UNDERL 0x04
#define DRAW_UNDERC 0x08
#if defined(RISCOS) || defined(HAVE_GTK2)
# define DRAW_ITALIC 0x10
#endif
#define DRAW_CURSOR 0x20
#define TEAR_STRING "-->Detach"
#define TEAR_LEN (9)
#ifdef FEAT_GUI_W16
# define TOOLBAR_BUTTON_HEIGHT 15
# define TOOLBAR_BUTTON_WIDTH 16
#else
# define TOOLBAR_BUTTON_HEIGHT 18
# define TOOLBAR_BUTTON_WIDTH 18
#endif
#define TOOLBAR_BORDER_HEIGHT 12
#ifdef FEAT_GUI_MSWIN
# define TABLINE_HEIGHT 22
#endif
#ifdef FEAT_GUI_MOTIF
# define TABLINE_HEIGHT 30
#endif
#if defined(NO_CONSOLE) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_X11)
# define NO_CONSOLE_INPUT
#endif
typedef struct GuiScrollbar
{
long ident;
win_T *wp;
int type;
long value;
#ifdef FEAT_GUI_ATHENA
int pixval;
#endif
long size;
long max;
int top;
int height;
#ifdef FEAT_VERTSPLIT
int width;
#endif
int status_height;
#ifdef FEAT_GUI_X11
Widget id;
#endif
#ifdef FEAT_GUI_GTK
GtkWidget *id;
unsigned long handler_id;
#endif
#ifdef FEAT_GUI_MSWIN
HWND id;
int scroll_shift;
#endif
#ifdef FEAT_GUI_MAC
ControlHandle id;
#endif
#ifdef RISCOS
int id;
#endif
#ifdef FEAT_GUI_PHOTON
PtWidget_t *id;
#endif
} scrollbar_T;
typedef long guicolor_T;
#define INVALCOLOR (guicolor_T)-11111
#ifdef FEAT_GUI_GTK
# ifdef HAVE_GTK2
typedef PangoFontDescription *GuiFont;
typedef PangoFontDescription *GuiFontset;
# else
typedef GdkFont *GuiFont;
typedef GdkFont *GuiFontset;
# endif
# define NOFONT (GuiFont)NULL
# define NOFONTSET (GuiFontset)NULL
#else
# ifdef FEAT_GUI_PHOTON
typedef char *GuiFont;
typedef char *GuiFontset;
# define NOFONT (GuiFont)NULL
# define NOFONTSET (GuiFontset)NULL
# else
# ifdef FEAT_GUI_X11
typedef XFontStruct *GuiFont;
typedef XFontSet GuiFontset;
# define NOFONT (GuiFont)0
# define NOFONTSET (GuiFontset)0
# else
typedef long_u GuiFont;
typedef long_u GuiFontset;
# define NOFONT (GuiFont)0
# define NOFONTSET (GuiFontset)0
# endif
# endif
#endif
typedef struct Gui
{
int in_focus;
int in_use;
int starting;
int shell_created;
int dying;
int dofork;
int dragged_sb;
win_T *dragged_wp;
int pointer_hidden;
int col;
int row;
int cursor_col;
int cursor_row;
char cursor_is_valid;
int num_cols;
int num_rows;
int scroll_region_top;
int scroll_region_bot;
int scroll_region_left;
int scroll_region_right;
int highlight_mask;
int scrollbar_width;
int scrollbar_height;
int left_sbar_x;
int right_sbar_x;
#ifdef FEAT_MENU
# ifndef FEAT_GUI_GTK
int menu_height;
int menu_width;
# endif
char menu_is_active;
# ifdef FEAT_GUI_ATHENA
char menu_height_fixed;
# endif
#endif
scrollbar_T bottom_sbar;
int which_scrollbars[3];
int prev_wrap;
int char_width;
int char_height;
int char_ascent;
int border_width;
int border_offset;
GuiFont norm_font;
#ifndef HAVE_GTK2
GuiFont bold_font;
GuiFont ital_font;
GuiFont boldital_font;
#else
int font_can_bold;
#endif
#if defined(FEAT_MENU) && !defined(HAVE_GTK2)
# ifdef FONTSET_ALWAYS
GuiFontset menu_fontset;
# else
GuiFont menu_font;
# endif
#endif
#ifdef FEAT_MBYTE
GuiFont wide_font;
#endif
#ifdef FEAT_XFONTSET
GuiFontset fontset;
#endif
guicolor_T back_pixel;
guicolor_T norm_pixel;
guicolor_T def_back_pixel;
guicolor_T def_norm_pixel;
#ifdef FEAT_GUI_X11
char *rsrc_menu_fg_name;
guicolor_T menu_fg_pixel;
char *rsrc_menu_bg_name;
guicolor_T menu_bg_pixel;
char *rsrc_scroll_fg_name;
guicolor_T scroll_fg_pixel;
char *rsrc_scroll_bg_name;
guicolor_T scroll_bg_pixel;
# ifdef FEAT_GUI_MOTIF
guicolor_T menu_def_fg_pixel;
guicolor_T menu_def_bg_pixel;
guicolor_T scroll_def_fg_pixel;
guicolor_T scroll_def_bg_pixel;
# endif
Display *dpy;
Window wid;
int visibility;
GC text_gc;
GC back_gc;
GC invert_gc;
Cursor blank_pointer;
char_u *rsrc_font_name;
char_u *rsrc_bold_font_name;
char_u *rsrc_ital_font_name;
char_u *rsrc_boldital_font_name;
char_u *rsrc_menu_font_name;
Bool rsrc_rev_video;
char_u *geom;
Bool color_approx;
#endif
#ifdef FEAT_GUI_GTK
int visibility;
GdkCursor *blank_pointer;
char_u *geom;
GtkWidget *mainwin;
GtkWidget *formwin;
GtkWidget *drawarea;
# ifdef FEAT_MENU
GtkWidget *menubar;
# endif
# ifdef FEAT_TOOLBAR
GtkWidget *toolbar;
# endif
# ifdef FEAT_GUI_GNOME
GtkWidget *menubar_h;
GtkWidget *toolbar_h;
# endif
GdkColor *fgcolor;
GdkColor *bgcolor;
GdkColor *spcolor;
# ifndef HAVE_GTK2
GuiFont current_font;
# endif
GdkGC *text_gc;
# ifdef HAVE_GTK2
PangoContext *text_context;
PangoFont *ascii_font;
PangoGlyphString *ascii_glyphs;
# endif
# ifdef FEAT_GUI_TABLINE
GtkWidget *tabline;
# endif
GtkAccelGroup *accel_group;
# ifndef HAVE_GTK2
GtkWidget *fontdlg;
char_u *fontname;
# endif
GtkWidget *filedlg;
char_u *browse_fname;
#endif
#if defined(FEAT_GUI_TABLINE) \
&& (defined(FEAT_GUI_W32) || defined(FEAT_GUI_MOTIF) \
|| defined(FEAT_GUI_MAC))
int tabline_height;
#endif
#ifdef FEAT_FOOTER
int footer_height;
#endif
#if defined(FEAT_TOOLBAR) \
&& (defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MOTIF))
int toolbar_height;
#endif
#ifdef FEAT_BEVAL_TIP
char_u *rsrc_tooltip_font_name;
char *rsrc_tooltip_fg_name;
char *rsrc_tooltip_bg_name;
guicolor_T tooltip_fg_pixel;
guicolor_T tooltip_bg_pixel;
XFontSet tooltip_fontset;
#endif
#ifdef FEAT_GUI_MSWIN
GuiFont currFont;
guicolor_T currFgColor;
guicolor_T currBgColor;
guicolor_T currSpColor;
#endif
#ifdef FEAT_GUI_MAC
WindowPtr VimWindow;
MenuHandle MacOSHelpMenu;
int MacOSHelpItems;
WindowPtr wid;
int visibility;
#endif
#ifdef RISCOS
int window_handle;
char_u *window_title;
int window_title_size;
int fg_colour;
int bg_colour;
#endif
#ifdef FEAT_GUI_PHOTON
PtWidget_t *vimWindow;
PtWidget_t *vimTextArea;
PtWidget_t *vimContainer;
# if defined(FEAT_MENU) || defined(FEAT_TOOLBAR)
PtWidget_t *vimToolBarGroup;
# endif
# ifdef FEAT_MENU
PtWidget_t *vimMenuBar;
# endif
# ifdef FEAT_TOOLBAR
PtWidget_t *vimToolBar;
int toolbar_height;
# endif
PhEvent_t *event_buffer;
#endif
#ifdef FEAT_XIM
char *rsrc_input_method;
char *rsrc_preedit_type_name;
#endif
} gui_T;
extern gui_T gui;
typedef enum
{
VW_POS_MOUSE,
VW_POS_CENTER,
VW_POS_TOP_CENTER
} gui_win_pos_T;
#ifdef FIND_REPLACE_DIALOG
# define FRD_FINDNEXT 1
# define FRD_R_FINDNEXT 2
# define FRD_REPLACE 3
# define FRD_REPLACEALL 4
# define FRD_UNDO 5
# define FRD_TYPE_MASK 7
# define FRD_WHOLE_WORD 0x08
# define FRD_MATCH_CASE 0x10
#endif
#ifdef HAVE_GTK2
# define CONVERT_TO_UTF8(String) \
((output_conv.vc_type == CONV_NONE || (String) == NULL) \
? (String) \
: string_convert(&output_conv, (String), NULL))
# define CONVERT_TO_UTF8_FREE(String) \
((String) = ((output_conv.vc_type == CONV_NONE) \
? (char_u *)NULL \
: (vim_free(String), (char_u *)NULL)))
# define CONVERT_FROM_UTF8(String) \
((input_conv.vc_type == CONV_NONE || (String) == NULL) \
? (String) \
: string_convert(&input_conv, (String), NULL))
# define CONVERT_FROM_UTF8_FREE(String) \
((String) = ((input_conv.vc_type == CONV_NONE) \
? (char_u *)NULL \
: (vim_free(String), (char_u *)NULL)))
#else
# define CONVERT_TO_UTF8(String) (String)
# define CONVERT_TO_UTF8_FREE(String) ((String) = (char_u *)NULL)
# define CONVERT_FROM_UTF8(String) (String)
# define CONVERT_FROM_UTF8_FREE(String) ((String) = (char_u *)NULL)
#endif