/*
 *  WindowMaker window manager
 * 
 *  Copyright (c) 1997 Alfredo K. Kojima
 * 
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef WINDOWMAKER_H_
#define WINDOWMAKER_H_

#include "wconfig.h"

/* max. number of distinct window levels */
#define MAX_WINDOW_LEVELS	5


/* class codes */
typedef enum {
    WCLASS_UNKNOWN = 0,
      WCLASS_WINDOW = 1,	       /* managed client windows */
      WCLASS_MENU = 2,		       /* root menus */
      WCLASS_APPICON = 3,
      WCLASS_DIALOG = 4,
      WCLASS_DUMMYWINDOW = 5,	       /* window that holds window group leader */
      WCLASS_MINIWINDOW = 6,
      WCLASS_DOCK_ICON = 7
} WClassType;



/*
 * WObjDescriptor will be used by the event dispatcher to
 * send events to a particular object through the methods in the 
 * method table. If all objects of the same class share the
 * same methods, the class method table should be used, otherwise
 * a new method table must be created for each object.
 * It is also assigned to find the parent structure of a given
 * window (like the WWindow or WMenu for a button)
 */
typedef struct WObjDescriptor {
    void *self;			       /* the object that will be called */
    struct WMethodTable *methods;
    
    WClassType parent_type;	       /* type code of the parent */
    void *parent;		       /* parent object (WWindow or WMenu) */
    
    Time click_timestamp;	       /* timestamp of the last click */
} WObjDescriptor;


typedef void (*WEventHandler)(WObjDescriptor *sender, XEvent *event);

/*
 * WMethodTable is a table for callbacks to be called by the event
 * dispatcher. The sender parameter will be set by the dispatcher
 * to the self field of the WEventHandler structure.
 * There are 3 types of method tables:
 * # classwide method tables, which is a table that will be shared
 * among all the objects of a class
 * 	WCore
 * # object method tables, where each object has it's own different
 * table.
 * 	-
 * # mixed method tables, each object of the same type points to the
 * same method table. (ex. all close button objects point to the same
 *		       table, as well as iconify etc.)
 * 	WButton
 */

/* DO NOT CHANGE THE ORDER OF THIS. NEW EVENTS SHOULD BE ADDED AT THE END 
 * OF THE TABLE
 */
typedef struct WMethodTable {
    WEventHandler mouse_down;
    WEventHandler click;
    WEventHandler dbl_click;
    WEventHandler any_event;      /* the "generic" event handler */
} WMethodTable;





/* cursors */
#define WCUR_DEFAULT	0
#define WCUR_NORMAL 	0
#define WCUR_MOVE	1
#define WCUR_RESIZE	2
#define WCUR_WAIT	3
#define WCUR_ARROW	4
#define WCUR_QUESTION	5
#define WCUR_TEXT	6
#define WCUR_LAST	7


/* geometry displays */
#define WDIS_NEW	0	       /* new style */
#define WDIS_CENTER	1	       /* center of screen */
#define WDIS_TOPLEFT	2	       /* top left corner of screen */
#define WDIS_FRAME_CENTER 3	       /* center of the frame */


/* keyboard input focus mode */
#define WKF_CLICK	0
#define WKF_POINTER	1
#define WKF_SLOPPY	2

/* window placement mode */
#define WPM_MANUAL	0
#define WPM_CASCADE	1
#define WPM_AUTO	2
#define WPM_SMART	3
#define WPM_RANDOM	4

/* text justification */
#define WTJ_CENTER	0
#define WTJ_LEFT	1
#define WTJ_RIGHT	2


/* switchmenu actions */
#define ACTION_ADD	0
#define ACTION_REMOVE	1
#define ACTION_CHANGE	2
#define ACTION_CHANGE_WORKSPACE 3


typedef struct W2Color {
    char *color1;
    char *color2;
} W2Color;

typedef struct WCoord {
    short x, y;
} WCoord;

typedef struct WPreferences {
    char size_display;		       /* display type for resize geometry */
    char move_display;		       /* display type for move geometry */
    char window_placement;	       /* window placement mode */
    char colormap_follows_mouse;       /* Colormaps should be installed when
					* the mouse enters a window */
    char focus_mode;		       /* window focusing mode */
    
    char opaque_move;		       /* update window position during */
				       /* move */

    char align_menus;		       /* align menu with their parents */
    
    char use_saveunders;	       /* turn on SaveUnders for menus,
					* icons etc. */ 

    WCoord root_menu_pos;	       /* initial position of the root menu
					* -1,-1 (default) means don't map
					* menu on startup */
    char ignore_focus_click;

    char on_top_transients;	       /* transient windows are kept on top
					* of their owners */
    char title_justification;	       /* titlebar text alignment */

    char strict_ns;		       /* disable non-NS like features */

    int raise_delay;		       /* delay for autoraise. 0 is disabled */

    char dithering;		       /* use dithering or not */

    int cmap_size;		       /* size of dithering colormap in colors
					* per channel */
    
    char animations;		       /* enable/disable animations */
    
    char autowrap;		       /* wrap workspace when window is moved
					* to the edge */
    
    char *icon_back_file;	       /* background image for icons */
    char *icon_dots_file;	       /* for 3dots */
    char *logo_file;
    
    char *title_font;		       /* font for window title text */
    char *menu_title_font;	       /* font for menu titles */
    char *menu_entry_font;	       /* font for menu entries */
    char *icon_title_font;	       /* font for icon titles */
    char *info_font;		       /* resize/move display et cetera */
    char *panel_title_font;	       /* dialog panel title (not titlebar) */
    char *panel_text_font;	       /* dialog panel text */

    char *ftitle_fcolor;	       /* solid colors */
    char *ftitle_bcolor;
    char *ptitle_fcolor;
    char *ptitle_bcolor;
    char *utitle_fcolor;
    char *utitle_bcolor;
    char *menu_title_fcolor;
    char *menu_title_bcolor;    
    char *menu_text_fcolor;
    char *menu_text_bcolor;
    char *menu_text_dcolor;

    char ftitle_texture;	       /* texture types */
    char ptitle_texture;
    char utitle_texture;
    char menu_title_texture;
    char menu_text_texture;
    
    W2Color ftitle_gradient;	       /* gradient colors */
    W2Color ptitle_gradient;
    W2Color utitle_gradient;
    W2Color menu_title_gradient;
    W2Color menu_text_gradient;
    
    struct {
	unsigned int nodock:1;	       /* don't display the dock */
	unsigned int nocpp:1;	       /* don't use cpp */
    } flags;			       /* internal flags */
} WPreferences;

/****** Global Variables  ******/
extern Display	*dpy;
extern char *ProgName;

/****** Global Functions ******/
extern void wAbort();

#endif
