/* vi:set ts=8 sts=4 sw=4:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
* (C) 2001,2005 by Marcin Dalecki <martin@dalecki.de>
*
* Implementation of dialogue functions for the Motif GUI variant.
*
* Note about Lesstif: Apparently lesstif doesn't get the widget layout right,
* when using a dynamic scrollbar policy.
*/
#include <Xm/Form.h>
#include <Xm/PushBG.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/Label.h>
#include <Xm/Frame.h>
#include <Xm/LabelG.h>
#include <Xm/ToggleBG.h>
#include <Xm/SeparatoG.h>
#include <Xm/DialogS.h>
#include <Xm/List.h>
#include <Xm/RowColumn.h>
#include <Xm/AtomMgr.h>
#include <Xm/Protocols.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include "vim.h"
extern Widget vimShell;
#ifdef FEAT_MENU
# define apply_fontlist(w) gui_motif_menu_fontlist(w)
#else
# define apply_fontlist(w)
#endif
/****************************************************************************
* Font selection dialogue implementation.
*/
static char wild[3] = "*";
/*
* FIXME: This is a generic function, which should be used throughout the whole
* application.
*
* Add close_callback, which will be called when the user selects close from
* the window menu. The close menu item usually activates f.kill which sends a
* WM_DELETE_WINDOW protocol request for the window.
*/
static void
add_cancel_action(Widget shell, XtCallbackProc close_callback, void *arg)
{
static Atom wmp_atom = 0;
static Atom dw_atom = 0;
Display *display = XtDisplay(shell);
/* deactivate the built-in delete response of killing the application */
XtVaSetValues(shell, XmNdeleteResponse, XmDO_NOTHING, NULL);
/* add a delete window protocol callback instead */
if (!dw_atom)
{
wmp_atom = XmInternAtom(display, "WM_PROTOCOLS", True);
dw_atom = XmInternAtom(display, "WM_DELETE_WINDOW", True);
}
XmAddProtocolCallback(shell, wmp_atom, dw_atom, close_callback, arg);
}
#define MAX_FONTS 65535
#define MAX_FONT_NAME_LEN 256
#define MAX_ENTRIES_IN_LIST 5000
#define MAX_DISPLAY_SIZE 150
#define TEMP_BUF_SIZE 256
enum ListSpecifier
{
ENCODING,
NAME,
STYLE,
SIZE,
NONE
};
typedef struct _SharedFontSelData
{
Widget dialog;
Widget ok;
Widget cancel;
Widget encoding_pulldown;
Widget encoding_menu;
Widget list[NONE];
Widget name;
Widget sample;
char **names; /* font name array of arrays */
int num; /* number of font names */
String sel[NONE]; /* selection category */
Boolean in_pixels; /* toggle state - size in pixels */
char *font_name; /* current font name */
XFontStruct *old; /* font data structure for sample display */
XmFontList old_list; /* font data structure for sample display */
Boolean exit; /* used for program exit control */
} SharedFontSelData;
/*
* Checking access to the font name array for validity.
*/
static char *
fn(SharedFontSelData *data,