2000-09-28 20:30:52 +00:00
|
|
|
|
/* Implements a lightweight menubar widget.
|
2007-02-27 03:09:41 +00:00
|
|
|
|
Copyright (C) 1992 Lucid, Inc.
|
2011-01-25 04:08:28 +00:00
|
|
|
|
Copyright (C) 1994-1995, 1997, 1999-2011 Free Software Foundation, Inc.
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
This file is part of the Lucid Widget Library.
|
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
The Lucid Widget Library is free software; you can redistribute it and/or
|
1994-01-18 23:47:41 +00:00
|
|
|
|
modify it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
|
|
The Lucid Widget Library is distributed in the hope that it will be useful,
|
2000-09-28 20:30:52 +00:00
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
1994-01-18 23:47:41 +00:00
|
|
|
|
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
|
1996-07-20 18:10:35 +00:00
|
|
|
|
along with GNU Emacs; see the file COPYING. If not, write to the
|
2005-07-04 15:47:28 +00:00
|
|
|
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, USA. */
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
/* Created by devin@lucid.com */
|
|
|
|
|
|
Add support for large files, plus some locale improvements.
* dispatch.c, lwlib-Xaw.c, lwlib-Xlw.c, lwlib-Xm.c, lwlib.c, xlwmenu.c,
xrdb-cpp.c, xrdb.c:
Include <config.h> before any system include files.
* lwlib-Xm.c, lwlib.c:
Do not include <stdlib.h> or <string.h>, as <config.h> does this.
1999-10-19 07:21:16 +00:00
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2009-10-19 04:27:09 +00:00
|
|
|
|
#include <setjmp.h>
|
2003-05-22 13:38:44 +00:00
|
|
|
|
#include "lisp.h"
|
2001-12-02 05:00:27 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
#include <stdio.h>
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#include <ctype.h>
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2000-09-28 20:30:52 +00:00
|
|
|
|
#if (defined __sun) && !(defined SUNOS41)
|
|
|
|
|
#define SUNOS41
|
1994-01-18 23:47:41 +00:00
|
|
|
|
#include <X11/Xos.h>
|
2000-09-28 20:30:52 +00:00
|
|
|
|
#undef SUNOS41
|
|
|
|
|
#else
|
|
|
|
|
#include <X11/Xos.h>
|
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
#include <X11/IntrinsicP.h>
|
1994-09-24 00:12:06 +00:00
|
|
|
|
#include <X11/ObjectP.h>
|
1994-01-18 23:47:41 +00:00
|
|
|
|
#include <X11/StringDefs.h>
|
|
|
|
|
#include <X11/cursorfont.h>
|
2010-04-17 17:43:03 +00:00
|
|
|
|
#include <X11/Shell.h>
|
1994-01-18 23:47:41 +00:00
|
|
|
|
#include "xlwmenuP.h"
|
2000-06-12 19:12:11 +00:00
|
|
|
|
|
2000-06-06 14:21:15 +00:00
|
|
|
|
#ifdef emacs
|
2000-07-19 15:49:28 +00:00
|
|
|
|
|
|
|
|
|
/* Defined in xfns.c. When config.h defines `static' as empty, we get
|
|
|
|
|
redefinition errors when gray_bitmap is included more than once, so
|
|
|
|
|
we're referring to the one include in xfns.c here. */
|
|
|
|
|
|
|
|
|
|
extern int gray_bitmap_width;
|
|
|
|
|
extern int gray_bitmap_height;
|
2000-12-14 14:11:03 +00:00
|
|
|
|
extern char *gray_bitmap_bits;
|
2000-07-19 15:49:28 +00:00
|
|
|
|
|
2006-05-23 07:19:45 +00:00
|
|
|
|
#include "xterm.h"
|
|
|
|
|
|
2000-07-19 15:49:28 +00:00
|
|
|
|
#else /* not emacs */
|
|
|
|
|
|
|
|
|
|
#include <X11/bitmaps/gray>
|
|
|
|
|
#define gray_bitmap_width gray_width
|
|
|
|
|
#define gray_bitmap_height gray_height
|
|
|
|
|
#define gray_bitmap_bits gray_bits
|
|
|
|
|
|
|
|
|
|
#endif /* not emacs */
|
1994-09-17 12:53:30 +00:00
|
|
|
|
|
|
|
|
|
static int pointer_grabbed;
|
|
|
|
|
static XEvent menu_post_event;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
static XFontStruct *xlwmenu_default_font;
|
1994-10-29 23:25:10 +00:00
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static char
|
|
|
|
|
xlwMenuTranslations [] =
|
1995-12-31 19:15:18 +00:00
|
|
|
|
"<BtnDown>: start()\n\
|
|
|
|
|
<Motion>: drag()\n\
|
|
|
|
|
<BtnUp>: select()\n\
|
|
|
|
|
<Key>Shift_L: nothing()\n\
|
|
|
|
|
<Key>Shift_R: nothing()\n\
|
|
|
|
|
<Key>Meta_L: nothing()\n\
|
|
|
|
|
<Key>Meta_R: nothing()\n\
|
|
|
|
|
<Key>Control_L: nothing()\n\
|
|
|
|
|
<Key>Control_R: nothing()\n\
|
|
|
|
|
<Key>Hyper_L: nothing()\n\
|
|
|
|
|
<Key>Hyper_R: nothing()\n\
|
|
|
|
|
<Key>Super_L: nothing()\n\
|
|
|
|
|
<Key>Super_R: nothing()\n\
|
|
|
|
|
<Key>Alt_L: nothing()\n\
|
|
|
|
|
<Key>Alt_R: nothing()\n\
|
|
|
|
|
<Key>Caps_Lock: nothing()\n\
|
|
|
|
|
<Key>Shift_Lock: nothing()\n\
|
|
|
|
|
<KeyUp>Shift_L: nothing()\n\
|
|
|
|
|
<KeyUp>Shift_R: nothing()\n\
|
|
|
|
|
<KeyUp>Meta_L: nothing()\n\
|
|
|
|
|
<KeyUp>Meta_R: nothing()\n\
|
|
|
|
|
<KeyUp>Control_L: nothing()\n\
|
|
|
|
|
<KeyUp>Control_R: nothing()\n\
|
|
|
|
|
<KeyUp>Hyper_L: nothing()\n\
|
|
|
|
|
<KeyUp>Hyper_R: nothing()\n\
|
|
|
|
|
<KeyUp>Super_L: nothing()\n\
|
|
|
|
|
<KeyUp>Super_R: nothing()\n\
|
|
|
|
|
<KeyUp>Alt_L: nothing()\n\
|
|
|
|
|
<KeyUp>Alt_R: nothing()\n\
|
|
|
|
|
<KeyUp>Caps_Lock: nothing()\n\
|
|
|
|
|
<KeyUp>Shift_Lock:nothing()\n\
|
2002-04-19 18:56:51 +00:00
|
|
|
|
<Key>Return: select()\n\
|
|
|
|
|
<Key>Down: down()\n\
|
|
|
|
|
<Key>Up: up()\n\
|
|
|
|
|
<Key>Left: left()\n\
|
|
|
|
|
<Key>Right: right()\n\
|
1995-12-31 19:15:18 +00:00
|
|
|
|
<Key>: key()\n\
|
|
|
|
|
<KeyUp>: key()\n\
|
1994-01-18 23:47:41 +00:00
|
|
|
|
";
|
|
|
|
|
|
2002-04-19 18:56:51 +00:00
|
|
|
|
/* FIXME: Space should toggle toggleable menu item but not remove the menu
|
|
|
|
|
so you can toggle the next one without entering the menu again. */
|
|
|
|
|
|
|
|
|
|
/* FIXME: Should ESC close one level of menu structure or the complete menu? */
|
|
|
|
|
|
2002-04-29 09:10:28 +00:00
|
|
|
|
/* FIXME: F10 should enter the menu, the first one in the menu-bar. */
|
2002-04-19 18:56:51 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
#define offset(field) XtOffset(XlwMenuWidget, field)
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static XtResource
|
1994-01-18 23:47:41 +00:00
|
|
|
|
xlwMenuResources[] =
|
2000-09-28 20:30:52 +00:00
|
|
|
|
{
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
2005-04-01 18:42:19 +00:00
|
|
|
|
{XtNfontSet, XtCFontSet, XtRFontSet, sizeof(XFontSet),
|
|
|
|
|
offset(menu.fontSet), XtRFontSet, NULL},
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
#define DEFAULT_FACENAME "Sans-10"
|
|
|
|
|
{XtNfaceName, XtCFaceName, XtRString, sizeof(String),
|
|
|
|
|
offset(menu.faceName), XtRString, DEFAULT_FACENAME},
|
|
|
|
|
{XtNdefaultFace, XtCDefaultFace, XtRInt, sizeof(int),
|
|
|
|
|
offset(menu.default_face), XtRImmediate, (XtPointer)1},
|
2005-04-01 18:42:19 +00:00
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
|
2005-03-18 04:19:41 +00:00
|
|
|
|
offset(menu.font), XtRString, "XtDefaultFont"},
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
|
|
|
|
|
offset(menu.foreground), XtRString, "XtDefaultForeground"},
|
2002-05-06 18:56:25 +00:00
|
|
|
|
{XtNdisabledForeground, XtCDisabledForeground, XtRPixel, sizeof(Pixel),
|
|
|
|
|
offset(menu.disabled_foreground), XtRString, (XtPointer)NULL},
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{XtNbuttonForeground, XtCButtonForeground, XtRPixel, sizeof(Pixel),
|
|
|
|
|
offset(menu.button_foreground), XtRString, "XtDefaultForeground"},
|
|
|
|
|
{XtNmargin, XtCMargin, XtRDimension, sizeof(Dimension),
|
2002-04-29 09:10:28 +00:00
|
|
|
|
offset(menu.margin), XtRImmediate, (XtPointer)1},
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{XtNhorizontalSpacing, XtCMargin, XtRDimension, sizeof(Dimension),
|
|
|
|
|
offset(menu.horizontal_spacing), XtRImmediate, (XtPointer)3},
|
|
|
|
|
{XtNverticalSpacing, XtCMargin, XtRDimension, sizeof(Dimension),
|
2002-04-29 09:10:28 +00:00
|
|
|
|
offset(menu.vertical_spacing), XtRImmediate, (XtPointer)2},
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{XtNarrowSpacing, XtCMargin, XtRDimension, sizeof(Dimension),
|
|
|
|
|
offset(menu.arrow_spacing), XtRImmediate, (XtPointer)10},
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
{XmNshadowThickness, XmCShadowThickness, XtRDimension,
|
1994-01-18 23:47:41 +00:00
|
|
|
|
sizeof (Dimension), offset (menu.shadow_thickness),
|
2002-04-29 09:10:28 +00:00
|
|
|
|
XtRImmediate, (XtPointer)1},
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{XmNtopShadowColor, XmCTopShadowColor, XtRPixel, sizeof (Pixel),
|
|
|
|
|
offset (menu.top_shadow_color), XtRImmediate, (XtPointer)-1},
|
|
|
|
|
{XmNbottomShadowColor, XmCBottomShadowColor, XtRPixel, sizeof (Pixel),
|
|
|
|
|
offset (menu.bottom_shadow_color), XtRImmediate, (XtPointer)-1},
|
|
|
|
|
{XmNtopShadowPixmap, XmCTopShadowPixmap, XtRPixmap, sizeof (Pixmap),
|
|
|
|
|
offset (menu.top_shadow_pixmap), XtRImmediate, (XtPointer)None},
|
|
|
|
|
{XmNbottomShadowPixmap, XmCBottomShadowPixmap, XtRPixmap, sizeof (Pixmap),
|
|
|
|
|
offset (menu.bottom_shadow_pixmap), XtRImmediate, (XtPointer)None},
|
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
{XtNopen, XtCCallback, XtRCallback, sizeof(XtPointer),
|
1994-01-18 23:47:41 +00:00
|
|
|
|
offset(menu.open), XtRCallback, (XtPointer)NULL},
|
2000-09-28 20:30:52 +00:00
|
|
|
|
{XtNselect, XtCCallback, XtRCallback, sizeof(XtPointer),
|
1994-01-18 23:47:41 +00:00
|
|
|
|
offset(menu.select), XtRCallback, (XtPointer)NULL},
|
2000-09-28 20:30:52 +00:00
|
|
|
|
{XtNhighlightCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
|
2000-01-17 09:10:58 +00:00
|
|
|
|
offset(menu.highlight), XtRCallback, (XtPointer)NULL},
|
2007-01-01 15:20:11 +00:00
|
|
|
|
{XtNenterCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
|
|
|
|
|
offset(menu.enter), XtRCallback, (XtPointer)NULL},
|
|
|
|
|
{XtNleaveCallback, XtCCallback, XtRCallback, sizeof(XtPointer),
|
|
|
|
|
offset(menu.leave), XtRCallback, (XtPointer)NULL},
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer),
|
|
|
|
|
offset(menu.contents), XtRImmediate, (XtPointer)NULL},
|
|
|
|
|
{XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
|
|
|
|
|
offset(menu.cursor_shape), XtRString, (XtPointer)"right_ptr"},
|
|
|
|
|
{XtNhorizontal, XtCHorizontal, XtRInt, sizeof(int),
|
|
|
|
|
offset(menu.horizontal), XtRImmediate, (XtPointer)True},
|
|
|
|
|
};
|
|
|
|
|
#undef offset
|
|
|
|
|
|
Fix some bad prototypes and formatting after conversion from K&R declaration.
* lwlib/lwlib-Xaw.c: Include <ctype.h> for isdigit.
(fill_xft_data, set_text): Remove unused variable screen.
(draw_text): Cast bp to FcChar8*.
(find_xft_data): Return 0 if inst or xft_data is not set.
(wm_delete_window): Correct prototype. Initialize widget to 0
and return if widget is still 0 after loop.
* lwlib/xlwmenu.c (XlwMenuSetValues, XlwMenuInitialize): Correct prototype.
(display_menu_item): Remove unused variable gi.
(make_windows_if_needed): Remove unused variable screen.
(XlwMenuRedisplay): Remove unused variable i.
* src/gtkutil.c (xg_get_pixbuf_from_pix_and_mask)
(xg_get_image_for_pixmap, create_dialog)
(xg_get_file_with_selection, xg_get_file_name, update_cl_data)
(menuitem_highlight_callback, make_menu_item)
(xg_create_one_menuitem, create_menus, xg_update_menu_item)
(xg_create_scroll_bar, xg_update_scrollbar_pos)
(xg_set_toolkit_scroll_bar_thumb, xg_tool_bar_button_cb)
(xg_tool_bar_proxy_help_callback, xg_tool_bar_detach_callback)
(xg_tool_bar_attach_callback, xg_tool_bar_help_callback)
(xg_tool_bar_item_expose_callback): Reformat prototype.
(xg_update_menubar): GList *group => GSList *group.
(xg_modify_menubar_widgets): Initialize witem to 0, check witem != 0
before use.
(update_frame_tool_bar): 4:th param to xg_get_image_for_pixmap changed
to GTK_IMAGE (wimage).
* src/xsettings.c (something_changedCB, parse_settings)
(apply_xft_settings): Reformat prototype.
(something_changedCB, init_gconf): Remove unused variable i.
(read_settings): Remove unused variable long_len.
* src/xsmfns.c (SSDATA): New macro.
(smc_save_yourself_CB, x_session_initialize): Use SSDATA for strings
passed to strlen/strcpy/strcat.
(create_client_leader_window): Surround with #ifndef USE_GTK. Cast
7:th arg to XChangeProperty to (unsigned char *)
2010-07-05 09:17:12 +00:00
|
|
|
|
static Boolean XlwMenuSetValues(Widget current, Widget request, Widget new,
|
|
|
|
|
ArgList args, Cardinal *num_args);
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
static void XlwMenuRealize(Widget, Mask *, XSetWindowAttributes *);
|
2010-07-04 05:47:55 +00:00
|
|
|
|
static void XlwMenuResize(Widget w);
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
static void XlwMenuInitialize(Widget, Widget, ArgList, Cardinal *);
|
2010-07-04 05:47:55 +00:00
|
|
|
|
static void XlwMenuRedisplay(Widget w, XEvent *ev, Region region);
|
|
|
|
|
static void XlwMenuDestroy(Widget w);
|
|
|
|
|
static void XlwMenuClassInitialize(void);
|
|
|
|
|
static void Start(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
|
|
|
|
static void Drag(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
|
|
|
|
static void Down(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
|
|
|
|
static void Up(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
|
|
|
|
static void Left(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
|
|
|
|
static void Right(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
|
|
|
|
static void Select(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
|
|
|
|
static void Key(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
|
|
|
|
static void Nothing(Widget w, XEvent *ev, String *params, Cardinal *num_params);
|
2010-07-02 12:19:53 +00:00
|
|
|
|
static int separator_height (enum menu_separator);
|
|
|
|
|
static void pop_up_menu (XlwMenuWidget, XButtonPressedEvent *);
|
2010-07-29 04:16:23 +00:00
|
|
|
|
static void abort_gracefully (Widget w) NO_RETURN;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static XtActionsRec
|
1994-01-18 23:47:41 +00:00
|
|
|
|
xlwMenuActionsList [] =
|
|
|
|
|
{
|
|
|
|
|
{"start", Start},
|
|
|
|
|
{"drag", Drag},
|
2002-04-19 18:56:51 +00:00
|
|
|
|
{"down", Down},
|
|
|
|
|
{"up", Up},
|
|
|
|
|
{"left", Left},
|
|
|
|
|
{"right", Right},
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{"select", Select},
|
1995-12-31 19:15:18 +00:00
|
|
|
|
{"key", Key},
|
2004-12-27 15:22:36 +00:00
|
|
|
|
{"MenuGadgetEscape", Key}, /* Compatibility with Lesstif/Motif. */
|
1995-12-31 19:15:18 +00:00
|
|
|
|
{"nothing", Nothing},
|
1994-01-18 23:47:41 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define SuperClass ((CoreWidgetClass)&coreClassRec)
|
|
|
|
|
|
|
|
|
|
XlwMenuClassRec xlwMenuClassRec =
|
|
|
|
|
{
|
|
|
|
|
{ /* CoreClass fields initialization */
|
2000-09-28 20:30:52 +00:00
|
|
|
|
(WidgetClass) SuperClass, /* superclass */
|
1994-01-18 23:47:41 +00:00
|
|
|
|
"XlwMenu", /* class_name */
|
|
|
|
|
sizeof(XlwMenuRec), /* size */
|
|
|
|
|
XlwMenuClassInitialize, /* class_initialize */
|
|
|
|
|
NULL, /* class_part_initialize */
|
|
|
|
|
FALSE, /* class_inited */
|
|
|
|
|
XlwMenuInitialize, /* initialize */
|
|
|
|
|
NULL, /* initialize_hook */
|
|
|
|
|
XlwMenuRealize, /* realize */
|
|
|
|
|
xlwMenuActionsList, /* actions */
|
|
|
|
|
XtNumber(xlwMenuActionsList), /* num_actions */
|
|
|
|
|
xlwMenuResources, /* resources */
|
|
|
|
|
XtNumber(xlwMenuResources), /* resource_count */
|
|
|
|
|
NULLQUARK, /* xrm_class */
|
|
|
|
|
TRUE, /* compress_motion */
|
2005-03-18 04:19:41 +00:00
|
|
|
|
XtExposeCompressMaximal, /* compress_exposure */
|
1994-01-18 23:47:41 +00:00
|
|
|
|
TRUE, /* compress_enterleave */
|
|
|
|
|
FALSE, /* visible_interest */
|
|
|
|
|
XlwMenuDestroy, /* destroy */
|
|
|
|
|
XlwMenuResize, /* resize */
|
|
|
|
|
XlwMenuRedisplay, /* expose */
|
|
|
|
|
XlwMenuSetValues, /* set_values */
|
|
|
|
|
NULL, /* set_values_hook */
|
|
|
|
|
XtInheritSetValuesAlmost, /* set_values_almost */
|
|
|
|
|
NULL, /* get_values_hook */
|
|
|
|
|
NULL, /* accept_focus */
|
|
|
|
|
XtVersion, /* version */
|
|
|
|
|
NULL, /* callback_private */
|
|
|
|
|
xlwMenuTranslations, /* tm_table */
|
|
|
|
|
XtInheritQueryGeometry, /* query_geometry */
|
|
|
|
|
XtInheritDisplayAccelerator, /* display_accelerator */
|
|
|
|
|
NULL /* extension */
|
|
|
|
|
}, /* XlwMenuClass fields initialization */
|
|
|
|
|
{
|
|
|
|
|
0 /* dummy */
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
WidgetClass xlwMenuWidgetClass = (WidgetClass) &xlwMenuClassRec;
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
int submenu_destroyed;
|
|
|
|
|
|
2002-04-28 19:54:30 +00:00
|
|
|
|
/* For debug, if installation-directory is non-nil this is not an installed
|
|
|
|
|
Emacs. In that case we do not grab the keyboard to make it easier to
|
|
|
|
|
debug. */
|
|
|
|
|
#define GRAB_KEYBOARD (EQ (Vinstallation_directory, Qnil))
|
2002-04-22 18:21:06 +00:00
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
static int next_release_must_exit;
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* Utilities */
|
1999-07-21 21:43:52 +00:00
|
|
|
|
|
2002-04-22 18:21:06 +00:00
|
|
|
|
/* Ungrab pointer and keyboard */
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
ungrab_all (Widget w, Time ungrabtime)
|
2002-04-22 18:21:06 +00:00
|
|
|
|
{
|
|
|
|
|
XtUngrabPointer (w, ungrabtime);
|
2002-04-28 19:54:30 +00:00
|
|
|
|
if (GRAB_KEYBOARD) XtUngrabKeyboard (w, ungrabtime);
|
2002-04-22 18:21:06 +00:00
|
|
|
|
}
|
1999-07-21 21:43:52 +00:00
|
|
|
|
|
|
|
|
|
/* Like abort, but remove grabs from widget W before. */
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
abort_gracefully (Widget w)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
if (XtIsShell (XtParent (w)))
|
|
|
|
|
XtRemoveGrab (w);
|
2002-04-22 18:21:06 +00:00
|
|
|
|
ungrab_all (w, CurrentTime);
|
1999-07-21 21:43:52 +00:00
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
push_new_stack (XlwMenuWidget mw, widget_value *val)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
if (!mw->menu.new_stack)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.new_stack_length = 10;
|
|
|
|
|
mw->menu.new_stack =
|
|
|
|
|
(widget_value**)XtCalloc (mw->menu.new_stack_length,
|
|
|
|
|
sizeof (widget_value*));
|
|
|
|
|
}
|
|
|
|
|
else if (mw->menu.new_depth == mw->menu.new_stack_length)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.new_stack_length *= 2;
|
|
|
|
|
mw->menu.new_stack =
|
|
|
|
|
(widget_value**)XtRealloc ((char*)mw->menu.new_stack,
|
|
|
|
|
mw->menu.new_stack_length * sizeof (widget_value*));
|
|
|
|
|
}
|
|
|
|
|
mw->menu.new_stack [mw->menu.new_depth++] = val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
pop_new_stack_if_no_contents (XlwMenuWidget mw)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
2002-12-22 22:00:44 +00:00
|
|
|
|
if (mw->menu.new_depth > 1)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
if (!mw->menu.new_stack [mw->menu.new_depth - 1]->contents)
|
|
|
|
|
mw->menu.new_depth -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
make_old_stack_space (XlwMenuWidget mw, int n)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
if (!mw->menu.old_stack)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.old_stack_length = 10;
|
|
|
|
|
mw->menu.old_stack =
|
|
|
|
|
(widget_value**)XtCalloc (mw->menu.old_stack_length,
|
|
|
|
|
sizeof (widget_value*));
|
|
|
|
|
}
|
|
|
|
|
else if (mw->menu.old_stack_length < n)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.old_stack_length *= 2;
|
|
|
|
|
mw->menu.old_stack =
|
|
|
|
|
(widget_value**)XtRealloc ((char*)mw->menu.old_stack,
|
|
|
|
|
mw->menu.old_stack_length * sizeof (widget_value*));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Size code */
|
2006-05-23 07:19:45 +00:00
|
|
|
|
static int
|
2010-07-04 05:47:55 +00:00
|
|
|
|
string_width (XlwMenuWidget mw, char *s)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XCharStruct xcs;
|
|
|
|
|
int drop;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (mw->menu.xft_font)
|
|
|
|
|
{
|
|
|
|
|
XGlyphInfo gi;
|
|
|
|
|
XftTextExtentsUtf8 (XtDisplay (mw), mw->menu.xft_font,
|
|
|
|
|
(FcChar8 *) s,
|
|
|
|
|
strlen (s), &gi);
|
|
|
|
|
return gi.width;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2005-04-01 18:42:19 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
|
|
|
|
if (mw->menu.fontSet)
|
|
|
|
|
{
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
XRectangle ink, logical;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
XmbTextExtents (mw->menu.fontSet, s, strlen (s), &ink, &logical);
|
|
|
|
|
return logical.width;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
XTextExtents (mw->menu.font, s, strlen (s), &drop, &drop, &drop, &xcs);
|
|
|
|
|
return xcs.width;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
#define MENU_FONT_HEIGHT(mw) \
|
|
|
|
|
((mw)->menu.xft_font != NULL \
|
|
|
|
|
? (mw)->menu.xft_font->height \
|
|
|
|
|
: ((mw)->menu.fontSet != NULL \
|
|
|
|
|
? (mw)->menu.font_extents->max_logical_extent.height \
|
|
|
|
|
: (mw)->menu.font->ascent + (mw)->menu.font->descent))
|
|
|
|
|
#define MENU_FONT_ASCENT(mw) \
|
|
|
|
|
((mw)->menu.xft_font != NULL \
|
|
|
|
|
? (mw)->menu.xft_font->ascent \
|
|
|
|
|
: ((mw)->menu.fontSet != NULL \
|
|
|
|
|
? - (mw)->menu.font_extents->max_logical_extent.y \
|
|
|
|
|
: (mw)->menu.font->ascent))
|
|
|
|
|
#else
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
|
|
|
|
#define MENU_FONT_HEIGHT(mw) \
|
2005-04-01 18:42:19 +00:00
|
|
|
|
((mw)->menu.fontSet != NULL \
|
|
|
|
|
? (mw)->menu.font_extents->max_logical_extent.height \
|
|
|
|
|
: (mw)->menu.font->ascent + (mw)->menu.font->descent)
|
2005-03-18 05:19:59 +00:00
|
|
|
|
#define MENU_FONT_ASCENT(mw) \
|
2005-04-01 18:42:19 +00:00
|
|
|
|
((mw)->menu.fontSet != NULL \
|
|
|
|
|
? - (mw)->menu.font_extents->max_logical_extent.y \
|
|
|
|
|
: (mw)->menu.font->ascent)
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#else
|
|
|
|
|
#define MENU_FONT_HEIGHT(mw) \
|
|
|
|
|
((mw)->menu.font->ascent + (mw)->menu.font->descent)
|
|
|
|
|
#define MENU_FONT_ASCENT(mw) ((mw)->menu.font->ascent)
|
|
|
|
|
#endif
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#endif
|
2005-03-18 04:19:41 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
static int
|
2010-07-04 05:47:55 +00:00
|
|
|
|
arrow_width (XlwMenuWidget mw)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
2005-03-18 04:19:41 +00:00
|
|
|
|
return (MENU_FONT_ASCENT (mw) * 3/4) | 1;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
/* Return the width of toggle buttons of widget MW. */
|
|
|
|
|
|
|
|
|
|
static int
|
2010-07-04 05:47:55 +00:00
|
|
|
|
toggle_button_width (XlwMenuWidget mw)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
2005-03-18 04:19:41 +00:00
|
|
|
|
return (MENU_FONT_HEIGHT (mw) * 2 / 3) | 1;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the width of radio buttons of widget MW. */
|
|
|
|
|
|
|
|
|
|
static int
|
2010-07-04 05:47:55 +00:00
|
|
|
|
radio_button_width (XlwMenuWidget mw)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
return toggle_button_width (mw) * 1.41;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
static XtResource
|
|
|
|
|
nameResource[] =
|
2000-09-28 20:30:52 +00:00
|
|
|
|
{
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{"labelString", "LabelString", XtRString, sizeof(String),
|
|
|
|
|
0, XtRImmediate, 0},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static char*
|
2010-07-04 05:47:55 +00:00
|
|
|
|
resource_widget_value (XlwMenuWidget mw, widget_value *val)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
if (!val->toolkit_data)
|
|
|
|
|
{
|
|
|
|
|
char* resourced_name = NULL;
|
|
|
|
|
char* complete_name;
|
|
|
|
|
XtGetSubresources ((Widget) mw,
|
|
|
|
|
(XtPointer) &resourced_name,
|
|
|
|
|
val->name, val->name,
|
|
|
|
|
nameResource, 1, NULL, 0);
|
|
|
|
|
if (!resourced_name)
|
|
|
|
|
resourced_name = val->name;
|
|
|
|
|
if (!val->value)
|
1994-01-21 16:52:12 +00:00
|
|
|
|
{
|
|
|
|
|
complete_name = (char *) XtMalloc (strlen (resourced_name) + 1);
|
|
|
|
|
strcpy (complete_name, resourced_name);
|
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int complete_length =
|
|
|
|
|
strlen (resourced_name) + strlen (val->value) + 2;
|
|
|
|
|
complete_name = XtMalloc (complete_length);
|
|
|
|
|
*complete_name = 0;
|
|
|
|
|
strcat (complete_name, resourced_name);
|
|
|
|
|
strcat (complete_name, " ");
|
|
|
|
|
strcat (complete_name, val->value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val->toolkit_data = complete_name;
|
|
|
|
|
val->free_toolkit_data = True;
|
|
|
|
|
}
|
|
|
|
|
return (char*)val->toolkit_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Returns the sizes of an item */
|
|
|
|
|
static void
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
size_menu_item (XlwMenuWidget mw,
|
|
|
|
|
widget_value* val,
|
|
|
|
|
int horizontal_p,
|
|
|
|
|
int* label_width,
|
|
|
|
|
int* rest_width,
|
|
|
|
|
int* button_width,
|
|
|
|
|
int* height)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
1999-07-21 21:43:52 +00:00
|
|
|
|
enum menu_separator separator;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
if (lw_separator_p (val->name, &separator, 0))
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
1999-07-21 21:43:52 +00:00
|
|
|
|
*height = separator_height (separator);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
*label_width = 1;
|
|
|
|
|
*rest_width = 0;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
*button_width = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-03-18 04:19:41 +00:00
|
|
|
|
*height = MENU_FONT_HEIGHT (mw)
|
|
|
|
|
+ 2 * mw->menu.vertical_spacing + 2 * mw->menu.shadow_thickness;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
*label_width =
|
|
|
|
|
string_width (mw, resource_widget_value (mw, val))
|
|
|
|
|
+ mw->menu.horizontal_spacing + mw->menu.shadow_thickness;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
*rest_width = mw->menu.horizontal_spacing + mw->menu.shadow_thickness;
|
|
|
|
|
if (!horizontal_p)
|
|
|
|
|
{
|
|
|
|
|
if (val->contents)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
/* Add width of the arrow displayed for submenus. */
|
1994-01-18 23:47:41 +00:00
|
|
|
|
*rest_width += arrow_width (mw) + mw->menu.arrow_spacing;
|
|
|
|
|
else if (val->key)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
/* Add width of key equivalent string. */
|
|
|
|
|
*rest_width += (string_width (mw, val->key)
|
|
|
|
|
+ mw->menu.arrow_spacing);
|
|
|
|
|
|
|
|
|
|
if (val->button_type == BUTTON_TYPE_TOGGLE)
|
|
|
|
|
*button_width = (toggle_button_width (mw)
|
|
|
|
|
+ mw->menu.horizontal_spacing);
|
|
|
|
|
else if (val->button_type == BUTTON_TYPE_RADIO)
|
|
|
|
|
*button_width = (radio_button_width (mw)
|
|
|
|
|
+ mw->menu.horizontal_spacing);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
size_menu (XlwMenuWidget mw, int level)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
int label_width = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
int rest_width = 0;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
int button_width = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
int max_rest_width = 0;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
int max_button_width = 0;
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
int height = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
int horizontal_p = mw->menu.horizontal && (level == 0);
|
|
|
|
|
widget_value* val;
|
|
|
|
|
window_state* ws;
|
|
|
|
|
|
|
|
|
|
if (level >= mw->menu.old_depth)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
abort_gracefully ((Widget) mw);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
ws = &mw->menu.windows [level];
|
1994-01-18 23:47:41 +00:00
|
|
|
|
ws->width = 0;
|
|
|
|
|
ws->height = 0;
|
|
|
|
|
ws->label_width = 0;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
ws->button_width = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
for (val = mw->menu.old_stack [level]->contents; val; val = val->next)
|
|
|
|
|
{
|
|
|
|
|
size_menu_item (mw, val, horizontal_p, &label_width, &rest_width,
|
1999-07-21 21:43:52 +00:00
|
|
|
|
&button_width, &height);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (horizontal_p)
|
|
|
|
|
{
|
|
|
|
|
ws->width += label_width + rest_width;
|
|
|
|
|
if (height > ws->height)
|
|
|
|
|
ws->height = height;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (label_width > ws->label_width)
|
|
|
|
|
ws->label_width = label_width;
|
|
|
|
|
if (rest_width > max_rest_width)
|
|
|
|
|
max_rest_width = rest_width;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
if (button_width > max_button_width)
|
|
|
|
|
max_button_width = button_width;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
ws->height += height;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (horizontal_p)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
ws->label_width = ws->button_width = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
else
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
ws->width = ws->label_width + max_rest_width + max_button_width;
|
|
|
|
|
ws->button_width = max_button_width;
|
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
ws->width += 2 * mw->menu.shadow_thickness;
|
|
|
|
|
ws->height += 2 * mw->menu.shadow_thickness;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
ws->max_rest_width = max_rest_width;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
|
|
|
|
|
if (horizontal_p)
|
|
|
|
|
{
|
|
|
|
|
ws->width += 2 * mw->menu.margin;
|
|
|
|
|
ws->height += 2 * mw->menu.margin;
|
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Display code */
|
1999-07-21 21:43:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
static void
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
draw_arrow (XlwMenuWidget mw,
|
|
|
|
|
Window window,
|
|
|
|
|
GC gc,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int down_p)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
1999-07-21 21:43:52 +00:00
|
|
|
|
Display *dpy = XtDisplay (mw);
|
|
|
|
|
GC top_gc = mw->menu.shadow_top_gc;
|
|
|
|
|
GC bottom_gc = mw->menu.shadow_bottom_gc;
|
|
|
|
|
int thickness = mw->menu.shadow_thickness;
|
|
|
|
|
int height = width;
|
|
|
|
|
XPoint pt[10];
|
|
|
|
|
/* alpha = atan (0.5)
|
|
|
|
|
factor = (1 + sin (alpha)) / cos (alpha) */
|
|
|
|
|
double factor = 1.62;
|
|
|
|
|
int thickness2 = thickness * factor;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
2005-03-18 04:19:41 +00:00
|
|
|
|
y += (MENU_FONT_HEIGHT (mw) - height) / 2;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
if (down_p)
|
|
|
|
|
{
|
|
|
|
|
GC temp;
|
|
|
|
|
temp = top_gc;
|
|
|
|
|
top_gc = bottom_gc;
|
|
|
|
|
bottom_gc = temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pt[0].x = x;
|
|
|
|
|
pt[0].y = y + height;
|
|
|
|
|
pt[1].x = x + thickness;
|
|
|
|
|
pt[1].y = y + height - thickness2;
|
|
|
|
|
pt[2].x = x + thickness2;
|
|
|
|
|
pt[2].y = y + thickness2;
|
|
|
|
|
pt[3].x = x;
|
|
|
|
|
pt[3].y = y;
|
|
|
|
|
XFillPolygon (dpy, window, top_gc, pt, 4, Convex, CoordModeOrigin);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
pt[0].x = x;
|
|
|
|
|
pt[0].y = y;
|
|
|
|
|
pt[1].x = x + thickness;
|
|
|
|
|
pt[1].y = y + thickness2;
|
|
|
|
|
pt[2].x = x + width - thickness2;
|
|
|
|
|
pt[2].y = y + height / 2;
|
|
|
|
|
pt[3].x = x + width;
|
|
|
|
|
pt[3].y = y + height / 2;
|
|
|
|
|
XFillPolygon (dpy, window, top_gc, pt, 4, Convex, CoordModeOrigin);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
pt[0].x = x;
|
|
|
|
|
pt[0].y = y + height;
|
|
|
|
|
pt[1].x = x + thickness;
|
|
|
|
|
pt[1].y = y + height - thickness2;
|
|
|
|
|
pt[2].x = x + width - thickness2;
|
|
|
|
|
pt[2].y = y + height / 2;
|
|
|
|
|
pt[3].x = x + width;
|
|
|
|
|
pt[3].y = y + height / 2;
|
|
|
|
|
XFillPolygon (dpy, window, bottom_gc, pt, 4, Convex, CoordModeOrigin);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
static void
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
draw_shadow_rectangle (XlwMenuWidget mw,
|
|
|
|
|
Window window,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int erase_p,
|
|
|
|
|
int down_p)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
Display *dpy = XtDisplay (mw);
|
|
|
|
|
GC top_gc = !erase_p ? mw->menu.shadow_top_gc : mw->menu.background_gc;
|
|
|
|
|
GC bottom_gc = !erase_p ? mw->menu.shadow_bottom_gc : mw->menu.background_gc;
|
|
|
|
|
int thickness = mw->menu.shadow_thickness;
|
|
|
|
|
XPoint points [4];
|
1999-07-21 21:43:52 +00:00
|
|
|
|
|
|
|
|
|
if (!erase_p && down_p)
|
|
|
|
|
{
|
|
|
|
|
GC temp;
|
|
|
|
|
temp = top_gc;
|
|
|
|
|
top_gc = bottom_gc;
|
|
|
|
|
bottom_gc = temp;
|
|
|
|
|
}
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
points [0].x = x;
|
|
|
|
|
points [0].y = y;
|
|
|
|
|
points [1].x = x + width;
|
|
|
|
|
points [1].y = y;
|
|
|
|
|
points [2].x = x + width - thickness;
|
|
|
|
|
points [2].y = y + thickness;
|
|
|
|
|
points [3].x = x;
|
|
|
|
|
points [3].y = y + thickness;
|
|
|
|
|
XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
|
|
|
|
|
points [0].x = x;
|
|
|
|
|
points [0].y = y + thickness;
|
|
|
|
|
points [1].x = x;
|
|
|
|
|
points [1].y = y + height;
|
|
|
|
|
points [2].x = x + thickness;
|
|
|
|
|
points [2].y = y + height - thickness;
|
|
|
|
|
points [3].x = x + thickness;
|
|
|
|
|
points [3].y = y + thickness;
|
|
|
|
|
XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
|
|
|
|
|
points [0].x = x + width;
|
|
|
|
|
points [0].y = y;
|
|
|
|
|
points [1].x = x + width - thickness;
|
|
|
|
|
points [1].y = y + thickness;
|
|
|
|
|
points [2].x = x + width - thickness;
|
|
|
|
|
points [2].y = y + height - thickness;
|
|
|
|
|
points [3].x = x + width;
|
|
|
|
|
points [3].y = y + height - thickness;
|
|
|
|
|
XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
|
|
|
|
|
points [0].x = x;
|
|
|
|
|
points [0].y = y + height;
|
|
|
|
|
points [1].x = x + width;
|
|
|
|
|
points [1].y = y + height;
|
|
|
|
|
points [2].x = x + width;
|
|
|
|
|
points [2].y = y + height - thickness;
|
|
|
|
|
points [3].x = x + thickness;
|
|
|
|
|
points [3].y = y + height - thickness;
|
|
|
|
|
XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
static void
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
draw_shadow_rhombus (XlwMenuWidget mw,
|
|
|
|
|
Window window,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
int height,
|
|
|
|
|
int erase_p,
|
|
|
|
|
int down_p)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
Display *dpy = XtDisplay (mw);
|
|
|
|
|
GC top_gc = !erase_p ? mw->menu.shadow_top_gc : mw->menu.background_gc;
|
|
|
|
|
GC bottom_gc = !erase_p ? mw->menu.shadow_bottom_gc : mw->menu.background_gc;
|
|
|
|
|
int thickness = mw->menu.shadow_thickness;
|
|
|
|
|
XPoint points [4];
|
|
|
|
|
|
|
|
|
|
if (!erase_p && down_p)
|
|
|
|
|
{
|
|
|
|
|
GC temp;
|
|
|
|
|
temp = top_gc;
|
|
|
|
|
top_gc = bottom_gc;
|
|
|
|
|
bottom_gc = temp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
points [0].x = x;
|
|
|
|
|
points [0].y = y + height / 2;
|
|
|
|
|
points [1].x = x + thickness;
|
|
|
|
|
points [1].y = y + height / 2;
|
|
|
|
|
points [2].x = x + width / 2;
|
|
|
|
|
points [2].y = y + thickness;
|
|
|
|
|
points [3].x = x + width / 2;
|
|
|
|
|
points [3].y = y;
|
|
|
|
|
XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
|
|
|
|
|
points [0].x = x + width / 2;
|
|
|
|
|
points [0].y = y;
|
|
|
|
|
points [1].x = x + width / 2;
|
|
|
|
|
points [1].y = y + thickness;
|
|
|
|
|
points [2].x = x + width - thickness;
|
|
|
|
|
points [2].y = y + height / 2;
|
|
|
|
|
points [3].x = x + width;
|
|
|
|
|
points [3].y = y + height / 2;
|
|
|
|
|
XFillPolygon (dpy, window, top_gc, points, 4, Convex, CoordModeOrigin);
|
|
|
|
|
points [0].x = x;
|
|
|
|
|
points [0].y = y + height / 2;
|
|
|
|
|
points [1].x = x + thickness;
|
|
|
|
|
points [1].y = y + height / 2;
|
|
|
|
|
points [2].x = x + width / 2;
|
|
|
|
|
points [2].y = y + height - thickness;
|
|
|
|
|
points [3].x = x + width / 2;
|
|
|
|
|
points [3].y = y + height;
|
|
|
|
|
XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
|
|
|
|
|
points [0].x = x + width / 2;
|
|
|
|
|
points [0].y = y + height;
|
|
|
|
|
points [1].x = x + width / 2;
|
|
|
|
|
points [1].y = y + height - thickness;
|
|
|
|
|
points [2].x = x + width - thickness;
|
|
|
|
|
points [2].y = y + height / 2;
|
|
|
|
|
points [3].x = x + width;
|
|
|
|
|
points [3].y = y + height / 2;
|
|
|
|
|
XFillPolygon (dpy, window, bottom_gc, points, 4, Convex, CoordModeOrigin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw a toggle button on widget MW, X window WINDOW. X/Y is the
|
|
|
|
|
top-left corner of the menu item. SELECTED_P non-zero means the
|
|
|
|
|
toggle button is selected. */
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
draw_toggle (XlwMenuWidget mw, Window window, int x, int y, int selected_p)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
|
|
width = toggle_button_width (mw);
|
|
|
|
|
height = width;
|
|
|
|
|
x += mw->menu.horizontal_spacing;
|
2005-03-18 04:19:41 +00:00
|
|
|
|
y += (MENU_FONT_ASCENT (mw) - height) / 2;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
draw_shadow_rectangle (mw, window, x, y, width, height, False, selected_p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw a radio button on widget MW, X window WINDOW. X/Y is the
|
|
|
|
|
top-left corner of the menu item. SELECTED_P non-zero means the
|
|
|
|
|
toggle button is selected. */
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
draw_radio (XlwMenuWidget mw, Window window, int x, int y, int selected_p)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
|
|
width = radio_button_width (mw);
|
|
|
|
|
height = width;
|
|
|
|
|
x += mw->menu.horizontal_spacing;
|
2005-03-18 04:19:41 +00:00
|
|
|
|
y += (MENU_FONT_ASCENT (mw) - height) / 2;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
draw_shadow_rhombus (mw, window, x, y, width, height, False, selected_p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw a menu separator on widget MW, X window WINDOW. X/Y is the
|
|
|
|
|
top-left corner of the menu item. WIDTH is the width of the
|
|
|
|
|
separator to draw. TYPE is the separator type. */
|
|
|
|
|
|
|
|
|
|
static void
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
draw_separator (XlwMenuWidget mw,
|
|
|
|
|
Window window,
|
|
|
|
|
int x,
|
|
|
|
|
int y,
|
|
|
|
|
int width,
|
|
|
|
|
enum menu_separator type)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
Display *dpy = XtDisplay (mw);
|
|
|
|
|
XGCValues xgcv;
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case SEPARATOR_NO_LINE:
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SINGLE_LINE:
|
|
|
|
|
XDrawLine (dpy, window, mw->menu.foreground_gc,
|
|
|
|
|
x, y, x + width, y);
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_DOUBLE_LINE:
|
|
|
|
|
draw_separator (mw, window, x, y, width, SEPARATOR_SINGLE_LINE);
|
|
|
|
|
draw_separator (mw, window, x, y + 2, width, SEPARATOR_SINGLE_LINE);
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SINGLE_DASHED_LINE:
|
|
|
|
|
xgcv.line_style = LineOnOffDash;
|
|
|
|
|
XChangeGC (dpy, mw->menu.foreground_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XDrawLine (dpy, window, mw->menu.foreground_gc,
|
|
|
|
|
x, y, x + width, y);
|
|
|
|
|
xgcv.line_style = LineSolid;
|
|
|
|
|
XChangeGC (dpy, mw->menu.foreground_gc, GCLineStyle, &xgcv);
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_DOUBLE_DASHED_LINE:
|
|
|
|
|
draw_separator (mw, window, x, y, width,
|
|
|
|
|
SEPARATOR_SINGLE_DASHED_LINE);
|
|
|
|
|
draw_separator (mw, window, x, y + 2, width,
|
|
|
|
|
SEPARATOR_SINGLE_DASHED_LINE);
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SHADOW_ETCHED_IN:
|
|
|
|
|
XDrawLine (dpy, window, mw->menu.shadow_bottom_gc,
|
|
|
|
|
x, y, x + width, y);
|
|
|
|
|
XDrawLine (dpy, window, mw->menu.shadow_top_gc,
|
|
|
|
|
x, y + 1, x + width, y + 1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SEPARATOR_SHADOW_ETCHED_OUT:
|
|
|
|
|
XDrawLine (dpy, window, mw->menu.shadow_top_gc,
|
|
|
|
|
x, y, x + width, y);
|
|
|
|
|
XDrawLine (dpy, window, mw->menu.shadow_bottom_gc,
|
|
|
|
|
x, y + 1, x + width, y + 1);
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SHADOW_ETCHED_IN_DASH:
|
|
|
|
|
xgcv.line_style = LineOnOffDash;
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv);
|
2000-12-11 14:33:47 +00:00
|
|
|
|
draw_separator (mw, window, x, y, width, SEPARATOR_SHADOW_ETCHED_IN);
|
1999-07-21 21:43:52 +00:00
|
|
|
|
xgcv.line_style = LineSolid;
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv);
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SHADOW_ETCHED_OUT_DASH:
|
|
|
|
|
xgcv.line_style = LineOnOffDash;
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv);
|
2000-12-11 14:33:47 +00:00
|
|
|
|
draw_separator (mw, window, x, y, width, SEPARATOR_SHADOW_ETCHED_OUT);
|
1999-07-21 21:43:52 +00:00
|
|
|
|
xgcv.line_style = LineSolid;
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN:
|
|
|
|
|
draw_separator (mw, window, x, y, width, SEPARATOR_SHADOW_ETCHED_IN);
|
|
|
|
|
draw_separator (mw, window, x, y + 3, width, SEPARATOR_SHADOW_ETCHED_IN);
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT:
|
|
|
|
|
draw_separator (mw, window, x, y, width,
|
|
|
|
|
SEPARATOR_SHADOW_ETCHED_OUT);
|
|
|
|
|
draw_separator (mw, window, x, y + 3, width,
|
|
|
|
|
SEPARATOR_SHADOW_ETCHED_OUT);
|
|
|
|
|
break;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH:
|
|
|
|
|
xgcv.line_style = LineOnOffDash;
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv);
|
|
|
|
|
draw_separator (mw, window, x, y, width,
|
|
|
|
|
SEPARATOR_SHADOW_DOUBLE_ETCHED_IN);
|
|
|
|
|
xgcv.line_style = LineSolid;
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH:
|
|
|
|
|
xgcv.line_style = LineOnOffDash;
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv);
|
|
|
|
|
draw_separator (mw, window, x, y, width,
|
|
|
|
|
SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT);
|
|
|
|
|
xgcv.line_style = LineSolid;
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_bottom_gc, GCLineStyle, &xgcv);
|
|
|
|
|
XChangeGC (dpy, mw->menu.shadow_top_gc, GCLineStyle, &xgcv);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the pixel height of menu separator SEPARATOR. */
|
|
|
|
|
|
|
|
|
|
static int
|
2010-07-04 05:47:55 +00:00
|
|
|
|
separator_height (enum menu_separator separator)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
{
|
|
|
|
|
switch (separator)
|
|
|
|
|
{
|
|
|
|
|
case SEPARATOR_NO_LINE:
|
|
|
|
|
return 2;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SINGLE_LINE:
|
|
|
|
|
case SEPARATOR_SINGLE_DASHED_LINE:
|
|
|
|
|
return 1;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_DOUBLE_LINE:
|
|
|
|
|
case SEPARATOR_DOUBLE_DASHED_LINE:
|
|
|
|
|
return 3;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SHADOW_ETCHED_IN:
|
|
|
|
|
case SEPARATOR_SHADOW_ETCHED_OUT:
|
|
|
|
|
case SEPARATOR_SHADOW_ETCHED_IN_DASH:
|
|
|
|
|
case SEPARATOR_SHADOW_ETCHED_OUT_DASH:
|
|
|
|
|
return 2;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN:
|
|
|
|
|
case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT:
|
|
|
|
|
case SEPARATOR_SHADOW_DOUBLE_ETCHED_IN_DASH:
|
|
|
|
|
case SEPARATOR_SHADOW_DOUBLE_ETCHED_OUT_DASH:
|
|
|
|
|
return 5;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
default:
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* Display the menu item and increment where.x and where.y to show how large
|
1999-07-21 21:43:52 +00:00
|
|
|
|
the menu item was. */
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
static void
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
display_menu_item (XlwMenuWidget mw,
|
|
|
|
|
widget_value* val,
|
|
|
|
|
window_state* ws,
|
|
|
|
|
XPoint* where,
|
|
|
|
|
Boolean highlighted_p,
|
|
|
|
|
Boolean horizontal_p,
|
|
|
|
|
Boolean just_compute_p)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
GC deco_gc;
|
|
|
|
|
GC text_gc;
|
2005-03-18 04:19:41 +00:00
|
|
|
|
int font_height = MENU_FONT_HEIGHT (mw);
|
|
|
|
|
int font_ascent = MENU_FONT_ASCENT (mw);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
int shadow = mw->menu.shadow_thickness;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
int margin = mw->menu.margin;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
int h_spacing = mw->menu.horizontal_spacing;
|
|
|
|
|
int v_spacing = mw->menu.vertical_spacing;
|
|
|
|
|
int label_width;
|
|
|
|
|
int rest_width;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
int button_width;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
int height;
|
|
|
|
|
int width;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
enum menu_separator separator;
|
|
|
|
|
int separator_p = lw_separator_p (val->name, &separator, 0);
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
XftColor *xftfg;
|
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
/* compute the sizes of the item */
|
1999-07-21 21:43:52 +00:00
|
|
|
|
size_menu_item (mw, val, horizontal_p, &label_width, &rest_width,
|
|
|
|
|
&button_width, &height);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (horizontal_p)
|
|
|
|
|
width = label_width + rest_width;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
label_width = ws->label_width;
|
|
|
|
|
width = ws->width - 2 * shadow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Only highlight an enabled item that has a callback. */
|
|
|
|
|
if (highlighted_p)
|
|
|
|
|
if (!val->enabled || !(val->call_data || val->contents))
|
|
|
|
|
highlighted_p = 0;
|
|
|
|
|
|
|
|
|
|
/* do the drawing. */
|
|
|
|
|
if (!just_compute_p)
|
|
|
|
|
{
|
|
|
|
|
/* Add the shadow border of the containing menu */
|
|
|
|
|
int x = where->x + shadow;
|
|
|
|
|
int y = where->y + shadow;
|
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
if (horizontal_p)
|
|
|
|
|
{
|
|
|
|
|
x += margin;
|
|
|
|
|
y += margin;
|
|
|
|
|
}
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* pick the foreground and background GC. */
|
|
|
|
|
if (val->enabled)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
text_gc = mw->menu.foreground_gc;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
else
|
2002-05-06 18:56:25 +00:00
|
|
|
|
text_gc = mw->menu.disabled_gc;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
deco_gc = mw->menu.foreground_gc;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
xftfg = val->enabled ? &mw->menu.xft_fg : &mw->menu.xft_disabled_fg;
|
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (separator_p)
|
|
|
|
|
{
|
2010-04-17 17:43:03 +00:00
|
|
|
|
draw_separator (mw, ws->pixmap, x, y, width, separator);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
2000-09-28 20:30:52 +00:00
|
|
|
|
else
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
1994-10-02 12:14:00 +00:00
|
|
|
|
int x_offset = x + h_spacing + shadow;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
char* display_string = resource_widget_value (mw, val);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, True,
|
1999-07-21 21:43:52 +00:00
|
|
|
|
False);
|
1994-10-02 12:14:00 +00:00
|
|
|
|
|
|
|
|
|
/* Deal with centering a menu title. */
|
|
|
|
|
if (!horizontal_p && !val->contents && !val->call_data)
|
|
|
|
|
{
|
|
|
|
|
int l = string_width (mw, display_string);
|
|
|
|
|
|
|
|
|
|
if (width > l)
|
|
|
|
|
x_offset = (width - l) >> 1;
|
|
|
|
|
}
|
1999-07-21 21:43:52 +00:00
|
|
|
|
else if (!horizontal_p && ws->button_width)
|
|
|
|
|
x_offset += ws->button_width;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (ws->xft_draw)
|
|
|
|
|
{
|
|
|
|
|
int draw_y = y + v_spacing + shadow;
|
|
|
|
|
XftDrawStringUtf8 (ws->xft_draw, xftfg,
|
|
|
|
|
mw->menu.xft_font,
|
|
|
|
|
x_offset, draw_y + font_ascent,
|
|
|
|
|
(unsigned char *) display_string,
|
|
|
|
|
strlen (display_string));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
2005-04-01 18:42:19 +00:00
|
|
|
|
if (mw->menu.fontSet)
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XmbDrawString (XtDisplay (mw), ws->pixmap, mw->menu.fontSet,
|
2005-04-01 18:42:19 +00:00
|
|
|
|
text_gc, x_offset,
|
|
|
|
|
y + v_spacing + shadow + font_ascent,
|
|
|
|
|
display_string, strlen (display_string));
|
|
|
|
|
else
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#endif
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XDrawString (XtDisplay (mw), ws->pixmap,
|
2005-03-18 04:19:41 +00:00
|
|
|
|
text_gc, x_offset,
|
1994-01-18 23:47:41 +00:00
|
|
|
|
y + v_spacing + shadow + font_ascent,
|
|
|
|
|
display_string, strlen (display_string));
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (!horizontal_p)
|
|
|
|
|
{
|
1999-07-21 21:43:52 +00:00
|
|
|
|
if (val->button_type == BUTTON_TYPE_TOGGLE)
|
2010-04-17 17:43:03 +00:00
|
|
|
|
draw_toggle (mw, ws->pixmap, x, y + v_spacing + shadow,
|
1999-07-21 21:43:52 +00:00
|
|
|
|
val->selected);
|
|
|
|
|
else if (val->button_type == BUTTON_TYPE_RADIO)
|
2010-04-17 17:43:03 +00:00
|
|
|
|
draw_radio (mw, ws->pixmap, x, y + v_spacing + shadow,
|
1999-07-21 21:43:52 +00:00
|
|
|
|
val->selected);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (val->contents)
|
|
|
|
|
{
|
|
|
|
|
int a_w = arrow_width (mw);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
draw_arrow (mw, ws->pixmap, deco_gc,
|
1999-07-21 21:43:52 +00:00
|
|
|
|
x + width - a_w
|
2000-09-28 20:30:52 +00:00
|
|
|
|
- mw->menu.horizontal_spacing
|
1994-09-17 12:53:30 +00:00
|
|
|
|
- mw->menu.shadow_thickness,
|
1999-07-21 21:43:52 +00:00
|
|
|
|
y + v_spacing + shadow, a_w,
|
|
|
|
|
highlighted_p);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
else if (val->key)
|
|
|
|
|
{
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (ws->xft_draw)
|
|
|
|
|
{
|
|
|
|
|
int draw_x = ws->width - ws->max_rest_width
|
|
|
|
|
+ mw->menu.arrow_spacing;
|
|
|
|
|
int draw_y = y + v_spacing + shadow + font_ascent;
|
|
|
|
|
XftDrawStringUtf8 (ws->xft_draw, xftfg,
|
|
|
|
|
mw->menu.xft_font,
|
|
|
|
|
draw_x, draw_y,
|
|
|
|
|
(unsigned char *) val->key,
|
|
|
|
|
strlen (val->key));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
2005-04-01 18:42:19 +00:00
|
|
|
|
if (mw->menu.fontSet)
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XmbDrawString (XtDisplay (mw), ws->pixmap,
|
2005-04-01 18:42:19 +00:00
|
|
|
|
mw->menu.fontSet,
|
|
|
|
|
text_gc,
|
|
|
|
|
x + label_width + mw->menu.arrow_spacing,
|
|
|
|
|
y + v_spacing + shadow + font_ascent,
|
|
|
|
|
val->key, strlen (val->key));
|
|
|
|
|
else
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#endif
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XDrawString (XtDisplay (mw), ws->pixmap,
|
2005-03-18 04:19:41 +00:00
|
|
|
|
text_gc,
|
1994-01-18 23:47:41 +00:00
|
|
|
|
x + label_width + mw->menu.arrow_spacing,
|
|
|
|
|
y + v_spacing + shadow + font_ascent,
|
|
|
|
|
val->key, strlen (val->key));
|
|
|
|
|
}
|
|
|
|
|
}
|
1994-09-17 12:53:30 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XDrawRectangle (XtDisplay (mw), ws->pixmap,
|
1994-09-17 12:53:30 +00:00
|
|
|
|
mw->menu.background_gc,
|
|
|
|
|
x + shadow, y + shadow,
|
|
|
|
|
label_width + h_spacing - 1,
|
2005-03-18 04:19:41 +00:00
|
|
|
|
font_height + 2 * v_spacing - 1);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height,
|
1999-07-21 21:43:52 +00:00
|
|
|
|
True, False);
|
1994-09-17 12:53:30 +00:00
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (highlighted_p)
|
2010-04-17 17:43:03 +00:00
|
|
|
|
draw_shadow_rectangle (mw, ws->pixmap, x, y, width, height, False,
|
1999-07-21 21:43:52 +00:00
|
|
|
|
False);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
where->x += width;
|
|
|
|
|
where->y += height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
display_menu (XlwMenuWidget mw,
|
|
|
|
|
int level,
|
|
|
|
|
Boolean just_compute_p,
|
|
|
|
|
XPoint *highlighted_pos,
|
|
|
|
|
XPoint *hit,
|
|
|
|
|
widget_value **hit_return)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
widget_value* val;
|
|
|
|
|
widget_value* following_item;
|
|
|
|
|
window_state* ws;
|
|
|
|
|
XPoint where;
|
|
|
|
|
int horizontal_p = mw->menu.horizontal && (level == 0);
|
|
|
|
|
int highlighted_p;
|
1997-07-26 01:40:05 +00:00
|
|
|
|
int no_return = 0;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
enum menu_separator separator;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (level >= mw->menu.old_depth)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
abort_gracefully ((Widget) mw);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (level < mw->menu.old_depth - 1)
|
|
|
|
|
following_item = mw->menu.old_stack [level + 1];
|
2000-09-28 20:30:52 +00:00
|
|
|
|
else
|
1994-01-18 23:47:41 +00:00
|
|
|
|
following_item = NULL;
|
|
|
|
|
|
|
|
|
|
if (hit)
|
|
|
|
|
*hit_return = NULL;
|
|
|
|
|
|
|
|
|
|
where.x = 0;
|
|
|
|
|
where.y = 0;
|
|
|
|
|
|
|
|
|
|
ws = &mw->menu.windows [level];
|
2010-04-17 17:43:03 +00:00
|
|
|
|
|
|
|
|
|
if (!just_compute_p)
|
|
|
|
|
XFillRectangle (XtDisplay (mw), ws->pixmap, mw->menu.background_gc,
|
|
|
|
|
0, 0, ws->width, ws->height);
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
for (val = mw->menu.old_stack [level]->contents; val; val = val->next)
|
|
|
|
|
{
|
|
|
|
|
highlighted_p = val == following_item;
|
|
|
|
|
if (highlighted_p && highlighted_pos)
|
|
|
|
|
{
|
|
|
|
|
if (horizontal_p)
|
|
|
|
|
highlighted_pos->x = where.x;
|
|
|
|
|
else
|
|
|
|
|
highlighted_pos->y = where.y;
|
|
|
|
|
}
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
display_menu_item (mw, val, ws, &where, highlighted_p, horizontal_p,
|
2010-04-17 17:43:03 +00:00
|
|
|
|
just_compute_p);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (highlighted_p && highlighted_pos)
|
|
|
|
|
{
|
|
|
|
|
if (horizontal_p)
|
|
|
|
|
highlighted_pos->y = where.y;
|
|
|
|
|
else
|
|
|
|
|
highlighted_pos->x = where.x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hit
|
|
|
|
|
&& !*hit_return
|
|
|
|
|
&& (horizontal_p ? hit->x < where.x : hit->y < where.y)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
&& !lw_separator_p (val->name, &separator, 0)
|
1997-07-26 01:40:05 +00:00
|
|
|
|
&& !no_return)
|
|
|
|
|
{
|
|
|
|
|
if (val->enabled)
|
|
|
|
|
*hit_return = val;
|
2007-01-01 15:20:11 +00:00
|
|
|
|
else
|
|
|
|
|
no_return = 1;
|
|
|
|
|
if (mw->menu.inside_entry != val)
|
|
|
|
|
{
|
|
|
|
|
if (mw->menu.inside_entry)
|
|
|
|
|
XtCallCallbackList ((Widget)mw, mw->menu.leave,
|
|
|
|
|
(XtPointer) mw->menu.inside_entry);
|
|
|
|
|
mw->menu.inside_entry = val;
|
|
|
|
|
XtCallCallbackList ((Widget)mw, mw->menu.enter,
|
|
|
|
|
(XtPointer) mw->menu.inside_entry);
|
|
|
|
|
}
|
1997-07-26 01:40:05 +00:00
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (horizontal_p)
|
|
|
|
|
where.y = 0;
|
|
|
|
|
else
|
|
|
|
|
where.x = 0;
|
|
|
|
|
}
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (!just_compute_p)
|
2010-04-17 17:43:03 +00:00
|
|
|
|
{
|
|
|
|
|
draw_shadow_rectangle (mw, ws->pixmap, 0, 0, ws->width, ws->height,
|
|
|
|
|
False, False);
|
|
|
|
|
XCopyArea (XtDisplay (mw), ws->pixmap, ws->window,
|
|
|
|
|
mw->menu.foreground_gc, 0, 0, ws->width, ws->height, 0, 0);
|
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Motion code */
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
set_new_state (XlwMenuWidget mw, widget_value *val, int level)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.new_depth = 0;
|
|
|
|
|
for (i = 0; i < level; i++)
|
|
|
|
|
push_new_stack (mw, mw->menu.old_stack [i]);
|
|
|
|
|
push_new_stack (mw, val);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 17:43:03 +00:00
|
|
|
|
static void
|
|
|
|
|
expose_cb (Widget widget,
|
|
|
|
|
XtPointer closure,
|
|
|
|
|
XEvent* event,
|
|
|
|
|
Boolean* continue_to_dispatch)
|
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget) closure;
|
|
|
|
|
int i;
|
|
|
|
|
|
2010-04-21 16:13:55 +00:00
|
|
|
|
*continue_to_dispatch = False;
|
2010-04-17 17:43:03 +00:00
|
|
|
|
for (i = 0; i < mw->menu.windows_length; ++i)
|
|
|
|
|
if (mw->menu.windows [i].w == widget) break;
|
|
|
|
|
if (i < mw->menu.windows_length && i < mw->menu.old_depth)
|
2010-07-04 05:47:55 +00:00
|
|
|
|
display_menu (mw, i, False, NULL, NULL, NULL);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 18:18:12 +00:00
|
|
|
|
static void
|
|
|
|
|
set_window_type (Widget w, XlwMenuWidget mw)
|
|
|
|
|
{
|
|
|
|
|
int popup_menu_p = mw->menu.top_depth == 1;
|
|
|
|
|
Atom type = XInternAtom (XtDisplay (w),
|
|
|
|
|
popup_menu_p
|
|
|
|
|
? "_NET_WM_WINDOW_TYPE_POPUP_MENU"
|
|
|
|
|
: "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU",
|
|
|
|
|
False);
|
|
|
|
|
|
|
|
|
|
XChangeProperty (XtDisplay (w), XtWindow (w),
|
|
|
|
|
XInternAtom (XtDisplay (w), "_NET_WM_WINDOW_TYPE", False),
|
|
|
|
|
XA_ATOM, 32, PropModeReplace,
|
|
|
|
|
(unsigned char *)&type, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
make_windows_if_needed (XlwMenuWidget mw, int n)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int start_at;
|
|
|
|
|
window_state* windows;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (mw->menu.windows_length >= n)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!mw->menu.windows)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.windows =
|
|
|
|
|
(window_state*)XtMalloc (n * sizeof (window_state));
|
|
|
|
|
start_at = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mw->menu.windows =
|
|
|
|
|
(window_state*)XtRealloc ((char*)mw->menu.windows,
|
|
|
|
|
n * sizeof (window_state));
|
|
|
|
|
start_at = mw->menu.windows_length;
|
|
|
|
|
}
|
|
|
|
|
mw->menu.windows_length = n;
|
|
|
|
|
|
|
|
|
|
windows = mw->menu.windows;
|
|
|
|
|
|
|
|
|
|
for (i = start_at; i < n; i++)
|
|
|
|
|
{
|
2010-04-17 17:43:03 +00:00
|
|
|
|
Arg av[10];
|
|
|
|
|
int ac = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
windows [i].x = 0;
|
|
|
|
|
windows [i].y = 0;
|
|
|
|
|
windows [i].width = 1;
|
|
|
|
|
windows [i].height = 1;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
windows [i].max_rest_width = 0;
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XtSetArg (av[ac], XtNwidth, 1); ++ac;
|
|
|
|
|
XtSetArg (av[ac], XtNheight, 1); ++ac;
|
|
|
|
|
XtSetArg (av[ac], XtNsaveUnder, True); ++ac;
|
|
|
|
|
XtSetArg (av[ac], XtNbackground, mw->core.background_pixel); ++ac;
|
|
|
|
|
XtSetArg (av[ac], XtNborderColor, mw->core.border_pixel); ++ac;
|
|
|
|
|
XtSetArg (av[ac], XtNborderWidth, mw->core.border_width); ++ac;
|
|
|
|
|
XtSetArg (av[ac], XtNcursor, mw->menu.cursor_shape); ++ac;
|
|
|
|
|
windows [i].w =
|
|
|
|
|
XtCreatePopupShell ("sub", overrideShellWidgetClass,
|
|
|
|
|
(Widget) mw, av, ac);
|
|
|
|
|
XtRealizeWidget (windows [i].w);
|
|
|
|
|
XtAddEventHandler (windows [i].w, ExposureMask, False, expose_cb, mw);
|
|
|
|
|
windows [i].window = XtWindow (windows [i].w);
|
|
|
|
|
windows [i].pixmap = None;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
2010-04-17 17:43:03 +00:00
|
|
|
|
windows [i].xft_draw = 0;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#endif
|
2010-04-17 18:18:12 +00:00
|
|
|
|
set_window_type (windows [i].w, mw);
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-04-30 14:34:54 +00:00
|
|
|
|
/* Value is non-zero if WINDOW is part of menu bar widget W. */
|
|
|
|
|
|
|
|
|
|
int
|
2010-07-04 05:47:55 +00:00
|
|
|
|
xlwmenu_window_p (Widget w, Window window)
|
2001-04-30 14:34:54 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget) w;
|
|
|
|
|
int i;
|
2003-02-04 14:56:31 +00:00
|
|
|
|
|
2001-04-30 14:34:54 +00:00
|
|
|
|
for (i = 0; i < mw->menu.windows_length; ++i)
|
|
|
|
|
if (window == mw->menu.windows[i].window)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
return i < mw->menu.windows_length;
|
|
|
|
|
}
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* Make the window fit in the screen */
|
|
|
|
|
static void
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
fit_to_screen (XlwMenuWidget mw,
|
|
|
|
|
window_state *ws,
|
|
|
|
|
window_state *previous_ws,
|
|
|
|
|
Boolean horizontal_p)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
1995-04-15 18:33:29 +00:00
|
|
|
|
unsigned int screen_width = WidthOfScreen (XtScreen (mw));
|
|
|
|
|
unsigned int screen_height = HeightOfScreen (XtScreen (mw));
|
1997-01-22 02:04:17 +00:00
|
|
|
|
/* 1 if we are unable to avoid an overlap between
|
|
|
|
|
this menu and the parent menu in the X dimension. */
|
|
|
|
|
int horizontal_overlap = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (ws->x < 0)
|
|
|
|
|
ws->x = 0;
|
|
|
|
|
else if (ws->x + ws->width > screen_width)
|
|
|
|
|
{
|
|
|
|
|
if (!horizontal_p)
|
2000-09-04 13:04:49 +00:00
|
|
|
|
/* The addition of shadow-thickness for a sub-menu's position is
|
|
|
|
|
to reflect a similar adjustment when the menu is displayed to
|
|
|
|
|
the right of the invoking menu-item; it makes the sub-menu
|
|
|
|
|
look more `attached' to the menu-item. */
|
|
|
|
|
ws->x = previous_ws->x - ws->width + mw->menu.shadow_thickness;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
else
|
|
|
|
|
ws->x = screen_width - ws->width;
|
1994-10-08 04:16:17 +00:00
|
|
|
|
if (ws->x < 0)
|
1997-01-22 02:04:17 +00:00
|
|
|
|
{
|
|
|
|
|
ws->x = 0;
|
|
|
|
|
horizontal_overlap = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* If we overlap in X, try to avoid overlap in Y. */
|
|
|
|
|
if (horizontal_overlap
|
|
|
|
|
&& ws->y < previous_ws->y + previous_ws->height
|
|
|
|
|
&& previous_ws->y < ws->y + ws->height)
|
|
|
|
|
{
|
|
|
|
|
/* Put this menu right below or right above PREVIOUS_WS
|
|
|
|
|
if there's room. */
|
|
|
|
|
if (previous_ws->y + previous_ws->height + ws->height < screen_height)
|
|
|
|
|
ws->y = previous_ws->y + previous_ws->height;
|
|
|
|
|
else if (previous_ws->y - ws->height > 0)
|
|
|
|
|
ws->y = previous_ws->y - ws->height;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
1997-01-22 02:04:17 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (ws->y < 0)
|
|
|
|
|
ws->y = 0;
|
|
|
|
|
else if (ws->y + ws->height > screen_height)
|
|
|
|
|
{
|
|
|
|
|
if (horizontal_p)
|
|
|
|
|
ws->y = previous_ws->y - ws->height;
|
|
|
|
|
else
|
|
|
|
|
ws->y = screen_height - ws->height;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
if (ws->y < 0)
|
1994-10-08 04:16:17 +00:00
|
|
|
|
ws->y = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 17:43:03 +00:00
|
|
|
|
static void
|
|
|
|
|
create_pixmap_for_menu (window_state* ws, XlwMenuWidget mw)
|
|
|
|
|
{
|
|
|
|
|
if (ws->pixmap != None)
|
|
|
|
|
{
|
|
|
|
|
XFreePixmap (XtDisplay (ws->w), ws->pixmap);
|
|
|
|
|
ws->pixmap = None;
|
|
|
|
|
}
|
|
|
|
|
ws->pixmap = XCreatePixmap (XtDisplay (ws->w), ws->window,
|
|
|
|
|
ws->width, ws->height,
|
|
|
|
|
DefaultDepthOfScreen (XtScreen (ws->w)));
|
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (ws->xft_draw)
|
|
|
|
|
XftDrawDestroy (ws->xft_draw);
|
|
|
|
|
if (mw->menu.xft_font)
|
|
|
|
|
{
|
|
|
|
|
int screen = XScreenNumberOfScreen (mw->core.screen);
|
|
|
|
|
ws->xft_draw = XftDrawCreate (XtDisplay (ws->w),
|
|
|
|
|
ws->pixmap,
|
|
|
|
|
DefaultVisual (XtDisplay (ws->w), screen),
|
|
|
|
|
mw->core.colormap);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ws->xft_draw = 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* Updates old_stack from new_stack and redisplays. */
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
remap_menubar (XlwMenuWidget mw)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int last_same;
|
|
|
|
|
XPoint selection_position;
|
|
|
|
|
int old_depth = mw->menu.old_depth;
|
|
|
|
|
int new_depth = mw->menu.new_depth;
|
|
|
|
|
widget_value** old_stack;
|
|
|
|
|
widget_value** new_stack;
|
|
|
|
|
window_state* windows;
|
|
|
|
|
widget_value* old_selection;
|
|
|
|
|
widget_value* new_selection;
|
|
|
|
|
|
|
|
|
|
/* Check that enough windows and old_stack are ready. */
|
|
|
|
|
make_windows_if_needed (mw, new_depth);
|
|
|
|
|
make_old_stack_space (mw, new_depth);
|
|
|
|
|
windows = mw->menu.windows;
|
|
|
|
|
old_stack = mw->menu.old_stack;
|
|
|
|
|
new_stack = mw->menu.new_stack;
|
|
|
|
|
|
|
|
|
|
/* compute the last identical different entry */
|
|
|
|
|
for (i = 1; i < old_depth && i < new_depth; i++)
|
|
|
|
|
if (old_stack [i] != new_stack [i])
|
|
|
|
|
break;
|
|
|
|
|
last_same = i - 1;
|
|
|
|
|
|
|
|
|
|
/* Memorize the previously selected item to be able to refresh it */
|
|
|
|
|
old_selection = last_same + 1 < old_depth ? old_stack [last_same + 1] : NULL;
|
|
|
|
|
if (old_selection && !old_selection->enabled)
|
|
|
|
|
old_selection = NULL;
|
|
|
|
|
new_selection = last_same + 1 < new_depth ? new_stack [last_same + 1] : NULL;
|
|
|
|
|
if (new_selection && !new_selection->enabled)
|
|
|
|
|
new_selection = NULL;
|
|
|
|
|
|
2000-01-17 09:10:58 +00:00
|
|
|
|
/* Call callback when the hightlighted item changes. */
|
|
|
|
|
if (old_selection || new_selection)
|
|
|
|
|
XtCallCallbackList ((Widget)mw, mw->menu.highlight,
|
|
|
|
|
(XtPointer) new_selection);
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* updates old_state from new_state. It has to be done now because
|
|
|
|
|
display_menu (called below) uses the old_stack to know what to display. */
|
|
|
|
|
for (i = last_same + 1; i < new_depth; i++)
|
2010-04-17 17:43:03 +00:00
|
|
|
|
{
|
|
|
|
|
XtPopdown (mw->menu.windows [i].w);
|
|
|
|
|
old_stack [i] = new_stack [i];
|
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.old_depth = new_depth;
|
|
|
|
|
|
1996-01-05 00:45:43 +00:00
|
|
|
|
/* refresh the last selection */
|
1994-01-18 23:47:41 +00:00
|
|
|
|
selection_position.x = 0;
|
|
|
|
|
selection_position.y = 0;
|
|
|
|
|
display_menu (mw, last_same, new_selection == old_selection,
|
2010-04-17 17:43:03 +00:00
|
|
|
|
&selection_position, NULL, NULL);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
1997-01-22 02:04:17 +00:00
|
|
|
|
/* Now place the new menus. */
|
|
|
|
|
for (i = last_same + 1; i < new_depth && new_stack[i]->contents; i++)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
1997-01-22 02:04:17 +00:00
|
|
|
|
window_state *previous_ws = &windows[i - 1];
|
|
|
|
|
window_state *ws = &windows[i];
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
ws->x = (previous_ws->x + selection_position.x
|
|
|
|
|
+ mw->menu.shadow_thickness);
|
2000-09-04 13:04:49 +00:00
|
|
|
|
if (mw->menu.horizontal && i == 1)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
ws->x += mw->menu.margin;
|
|
|
|
|
|
|
|
|
|
#if 0
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (!mw->menu.horizontal || i > 1)
|
|
|
|
|
ws->x += mw->menu.shadow_thickness;
|
1999-07-21 21:43:52 +00:00
|
|
|
|
#endif
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1999-07-21 21:43:52 +00:00
|
|
|
|
ws->y = (previous_ws->y + selection_position.y
|
|
|
|
|
+ mw->menu.shadow_thickness);
|
2000-09-04 13:04:49 +00:00
|
|
|
|
if (mw->menu.horizontal && i == 1)
|
1999-07-21 21:43:52 +00:00
|
|
|
|
ws->y += mw->menu.margin;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
size_menu (mw, i);
|
|
|
|
|
|
|
|
|
|
fit_to_screen (mw, ws, previous_ws, mw->menu.horizontal && i == 1);
|
|
|
|
|
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XtVaSetValues (ws->w, XtNwidth, ws->width, XtNheight, ws->height,
|
|
|
|
|
XtNx, ws->x, XtNy, ws->y, NULL);
|
|
|
|
|
create_pixmap_for_menu (ws, mw);
|
|
|
|
|
XtPopup (ws->w, XtGrabNone);
|
|
|
|
|
display_menu (mw, i, False, &selection_position, NULL, NULL);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* unmap the menus that popped down */
|
|
|
|
|
for (i = new_depth - 1; i < old_depth; i++)
|
2002-12-22 22:00:44 +00:00
|
|
|
|
if (i >= new_depth || (i > 0 && !new_stack[i]->contents))
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XtPopdown (windows[i].w);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Boolean
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
motion_event_is_in_menu (XlwMenuWidget mw,
|
|
|
|
|
XMotionEvent *ev,
|
|
|
|
|
int level,
|
|
|
|
|
XPoint *relative_pos)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
window_state* ws = &mw->menu.windows [level];
|
1997-09-20 04:48:29 +00:00
|
|
|
|
int shadow = level == 0 ? 0 : mw->menu.shadow_thickness;
|
|
|
|
|
int x = ws->x + shadow;
|
|
|
|
|
int y = ws->y + shadow;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
relative_pos->x = ev->x_root - x;
|
|
|
|
|
relative_pos->y = ev->y_root - y;
|
1997-09-20 04:48:29 +00:00
|
|
|
|
return (x - shadow < ev->x_root && ev->x_root < x + ws->width
|
2007-01-01 15:20:11 +00:00
|
|
|
|
&& y - shadow < ev->y_root && ev->y_root < y + ws->height);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Boolean
|
Change function definition from K&R to prototype. Fix prototype warnings.
* lwlib-Xaw.c (xaw_generic_callback, command_reset)
(xaw_update_one_value): Reformat.
(xaw_update_one_widget): Reformat and remove dead code.
(xaw_scrollbar_scroll, xaw_scrollbar_jump, xaw_create_scrollbar)
(xaw_update_scrollbar): Remove (not used).
(make_dialog): Change from K&R to prototype. Remove dead code.
(xaw_creation_table): Remove scrollbar entry.
* lwlib-Xlw.c (x_print_complete_resource_name): Change from K&R to
prototype.
(xlw_update_one_value): Reformat.
* lwlib-Xm.c (x_print_complete_resource_name)
(make_destroyed_instance, free_destroyed_instance, first_child)
(lw_motif_widget_p, resource_motif_string, destroy_all_children)
(xm_arm_callback, xm_update_label, xm_update_list)
(xm_update_pushbutton, xm_update_cascadebutton)
(xm_update_toggle, xm_update_radiobox, make_menu_in_widget)
(update_one_menu_entry, xm_update_menu, xm_update_text)
(xm_update_text_field, xm_update_one_widget)
(xm_update_one_value, activate_button, dialog_key_cb)
(make_dialog, mark_dead_instance_destroyed)
(find_matching_instance, recenter_widget, recycle_instance)
(xm_create_dialog, make_menubar, remove_grabs, make_popup_menu)
(make_main, xm_destroy_instance, xm_popup_menu)
(set_min_dialog_size, xm_pop_instance, do_call)
(xm_internal_update_other_instances, xm_generic_callback)
(xm_nosel_callback, xm_pull_down_callback, xm_pop_down_callback)
(xm_set_keyboard_focus, xm_set_main_areas, xm_manage_resizing): Change
from K&R to prototype.
* lwlib-int.h (widget_creation_function): Fix prototype.
* lwlib.c (allocate_widget_info, lw_register_widget): Change from K&R
to prototype.
(lw_internal_update_other_instances, merge_widget_value): Reformat.
* xlwmenu.c (size_menu_item): Change from K&R to prototype.
Change label_width and height to int.
(draw_arrow, draw_shadow_rectangle, draw_shadow_rhombus)
(draw_separator, display_menu, fit_to_screen, motion_event_is_in_menu)
(map_event_to_widget_value): Reformat.
(display_menu_item): Change from K&R to prototype.
2010-07-08 10:29:51 +00:00
|
|
|
|
map_event_to_widget_value (XlwMenuWidget mw,
|
|
|
|
|
XMotionEvent *ev,
|
|
|
|
|
widget_value **val,
|
|
|
|
|
int *level)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
XPoint relative_pos;
|
|
|
|
|
window_state* ws;
|
2007-01-01 15:20:11 +00:00
|
|
|
|
int inside = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
*val = NULL;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* Find the window */
|
|
|
|
|
for (i = mw->menu.old_depth - 1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
ws = &mw->menu.windows [i];
|
|
|
|
|
if (ws && motion_event_is_in_menu (mw, ev, i, &relative_pos))
|
|
|
|
|
{
|
2007-01-01 15:20:11 +00:00
|
|
|
|
inside = 1;
|
2010-04-17 17:43:03 +00:00
|
|
|
|
display_menu (mw, i, True, NULL, &relative_pos, val);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (*val)
|
|
|
|
|
{
|
|
|
|
|
*level = i + 1;
|
|
|
|
|
return True;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-01 15:20:11 +00:00
|
|
|
|
|
|
|
|
|
if (!inside)
|
|
|
|
|
{
|
|
|
|
|
if (mw->menu.inside_entry != NULL)
|
|
|
|
|
XtCallCallbackList ((Widget)mw, mw->menu.leave,
|
|
|
|
|
(XtPointer) mw->menu.inside_entry);
|
|
|
|
|
mw->menu.inside_entry = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
return False;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Procedures */
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
make_drawing_gcs (XlwMenuWidget mw)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XGCValues xgcv;
|
2002-05-07 05:22:48 +00:00
|
|
|
|
float scale;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
XtGCMask mask = GCForeground | GCBackground;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
2005-04-01 18:42:19 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
|
|
|
|
if (!mw->menu.fontSet)
|
|
|
|
|
{
|
|
|
|
|
xgcv.font = mw->menu.font->fid;
|
|
|
|
|
mask |= GCFont;
|
|
|
|
|
}
|
|
|
|
|
#else
|
1994-01-18 23:47:41 +00:00
|
|
|
|
xgcv.font = mw->menu.font->fid;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
mask |= GCFont;
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
xgcv.foreground = mw->menu.foreground;
|
|
|
|
|
xgcv.background = mw->core.background_pixel;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
mw->menu.foreground_gc = XtGetGC ((Widget)mw, mask, &xgcv);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
xgcv.foreground = mw->menu.button_foreground;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
mw->menu.button_gc = XtGetGC ((Widget)mw, mask, &xgcv);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
xgcv.background = mw->core.background_pixel;
|
2002-05-06 18:56:25 +00:00
|
|
|
|
|
|
|
|
|
#define BRIGHTNESS(color) (((color) & 0xff) + (((color) >> 8) & 0xff) + (((color) >> 16) & 0xff))
|
|
|
|
|
|
|
|
|
|
/* Allocate color for disabled menu-items. */
|
2002-05-07 05:22:48 +00:00
|
|
|
|
mw->menu.disabled_foreground = mw->menu.foreground;
|
2002-05-06 18:56:25 +00:00
|
|
|
|
if (BRIGHTNESS(mw->menu.foreground) < BRIGHTNESS(mw->core.background_pixel))
|
2002-05-07 05:22:48 +00:00
|
|
|
|
scale = 2.3;
|
2002-05-06 18:56:25 +00:00
|
|
|
|
else
|
2002-05-07 05:22:48 +00:00
|
|
|
|
scale = 0.55;
|
2002-05-06 18:56:25 +00:00
|
|
|
|
|
|
|
|
|
x_alloc_lighter_color_for_widget ((Widget) mw, XtDisplay ((Widget) mw),
|
|
|
|
|
mw->core.colormap,
|
2002-05-07 05:22:48 +00:00
|
|
|
|
&mw->menu.disabled_foreground,
|
|
|
|
|
scale,
|
2002-05-06 18:56:25 +00:00
|
|
|
|
0x8000);
|
|
|
|
|
|
|
|
|
|
if (mw->menu.foreground == mw->menu.disabled_foreground
|
|
|
|
|
|| mw->core.background_pixel == mw->menu.disabled_foreground)
|
|
|
|
|
{
|
|
|
|
|
/* Too few colors, use stipple. */
|
|
|
|
|
xgcv.foreground = mw->menu.foreground;
|
|
|
|
|
xgcv.fill_style = FillStippled;
|
|
|
|
|
xgcv.stipple = mw->menu.gray_pixmap;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
mw->menu.disabled_gc = XtGetGC ((Widget)mw, mask
|
2005-03-18 04:19:41 +00:00
|
|
|
|
| GCFillStyle | GCStipple, &xgcv);
|
2002-05-06 18:56:25 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Many colors available, use disabled pixel. */
|
|
|
|
|
xgcv.foreground = mw->menu.disabled_foreground;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
mw->menu.disabled_gc = XtGetGC ((Widget)mw, mask, &xgcv);
|
2002-05-06 18:56:25 +00:00
|
|
|
|
}
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
xgcv.foreground = mw->menu.button_foreground;
|
|
|
|
|
xgcv.background = mw->core.background_pixel;
|
|
|
|
|
xgcv.fill_style = FillStippled;
|
|
|
|
|
xgcv.stipple = mw->menu.gray_pixmap;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
mw->menu.inactive_button_gc = XtGetGC ((Widget)mw, mask
|
2005-03-18 04:19:41 +00:00
|
|
|
|
| GCFillStyle | GCStipple, &xgcv);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
xgcv.foreground = mw->core.background_pixel;
|
|
|
|
|
xgcv.background = mw->menu.foreground;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
mw->menu.background_gc = XtGetGC ((Widget)mw, mask, &xgcv);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
release_drawing_gcs (XlwMenuWidget mw)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XtReleaseGC ((Widget) mw, mw->menu.foreground_gc);
|
|
|
|
|
XtReleaseGC ((Widget) mw, mw->menu.button_gc);
|
2002-05-06 18:56:25 +00:00
|
|
|
|
XtReleaseGC ((Widget) mw, mw->menu.disabled_gc);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
XtReleaseGC ((Widget) mw, mw->menu.inactive_button_gc);
|
|
|
|
|
XtReleaseGC ((Widget) mw, mw->menu.background_gc);
|
|
|
|
|
/* let's get some segvs if we try to use these... */
|
|
|
|
|
mw->menu.foreground_gc = (GC) -1;
|
|
|
|
|
mw->menu.button_gc = (GC) -1;
|
2002-05-06 18:56:25 +00:00
|
|
|
|
mw->menu.disabled_gc = (GC) -1;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.inactive_button_gc = (GC) -1;
|
|
|
|
|
mw->menu.background_gc = (GC) -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define MINL(x,y) ((((unsigned long) (x)) < ((unsigned long) (y))) \
|
|
|
|
|
? ((unsigned long) (x)) : ((unsigned long) (y)))
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
make_shadow_gcs (XlwMenuWidget mw)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XGCValues xgcv;
|
|
|
|
|
unsigned long pm = 0;
|
|
|
|
|
Display *dpy = XtDisplay ((Widget) mw);
|
1999-07-21 21:43:52 +00:00
|
|
|
|
Screen *screen = XtScreen ((Widget) mw);
|
2000-03-04 16:04:00 +00:00
|
|
|
|
Colormap cmap = mw->core.colormap;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
XColor topc, botc;
|
|
|
|
|
int top_frobbed = 0, bottom_frobbed = 0;
|
|
|
|
|
|
2000-06-16 18:34:17 +00:00
|
|
|
|
mw->menu.free_top_shadow_color_p = 0;
|
|
|
|
|
mw->menu.free_bottom_shadow_color_p = 0;
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (mw->menu.top_shadow_color == -1)
|
|
|
|
|
mw->menu.top_shadow_color = mw->core.background_pixel;
|
2000-06-16 18:34:17 +00:00
|
|
|
|
else
|
|
|
|
|
mw->menu.top_shadow_color = mw->menu.top_shadow_color;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (mw->menu.bottom_shadow_color == -1)
|
|
|
|
|
mw->menu.bottom_shadow_color = mw->menu.foreground;
|
2000-06-16 18:34:17 +00:00
|
|
|
|
else
|
|
|
|
|
mw->menu.bottom_shadow_color = mw->menu.bottom_shadow_color;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (mw->menu.top_shadow_color == mw->core.background_pixel ||
|
|
|
|
|
mw->menu.top_shadow_color == mw->menu.foreground)
|
|
|
|
|
{
|
|
|
|
|
topc.pixel = mw->core.background_pixel;
|
2000-09-03 11:37:45 +00:00
|
|
|
|
#ifdef emacs
|
|
|
|
|
if (x_alloc_lighter_color_for_widget ((Widget) mw, dpy, cmap,
|
|
|
|
|
&topc.pixel,
|
|
|
|
|
1.2, 0x8000))
|
|
|
|
|
#else
|
1994-01-18 23:47:41 +00:00
|
|
|
|
XQueryColor (dpy, cmap, &topc);
|
|
|
|
|
/* don't overflow/wrap! */
|
|
|
|
|
topc.red = MINL (65535, topc.red * 1.2);
|
|
|
|
|
topc.green = MINL (65535, topc.green * 1.2);
|
|
|
|
|
topc.blue = MINL (65535, topc.blue * 1.2);
|
|
|
|
|
if (XAllocColor (dpy, cmap, &topc))
|
1999-07-21 21:43:52 +00:00
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
mw->menu.top_shadow_color = topc.pixel;
|
2000-06-16 18:34:17 +00:00
|
|
|
|
mw->menu.free_top_shadow_color_p = 1;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
top_frobbed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (mw->menu.bottom_shadow_color == mw->menu.foreground ||
|
|
|
|
|
mw->menu.bottom_shadow_color == mw->core.background_pixel)
|
|
|
|
|
{
|
|
|
|
|
botc.pixel = mw->core.background_pixel;
|
2000-09-03 11:37:45 +00:00
|
|
|
|
#ifdef emacs
|
|
|
|
|
if (x_alloc_lighter_color_for_widget ((Widget) mw, dpy, cmap,
|
|
|
|
|
&botc.pixel,
|
|
|
|
|
0.6, 0x4000))
|
|
|
|
|
#else
|
1994-01-18 23:47:41 +00:00
|
|
|
|
XQueryColor (dpy, cmap, &botc);
|
|
|
|
|
botc.red *= 0.6;
|
|
|
|
|
botc.green *= 0.6;
|
|
|
|
|
botc.blue *= 0.6;
|
|
|
|
|
if (XAllocColor (dpy, cmap, &botc))
|
1999-07-21 21:43:52 +00:00
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
mw->menu.bottom_shadow_color = botc.pixel;
|
2000-06-16 18:34:17 +00:00
|
|
|
|
mw->menu.free_bottom_shadow_color_p = 1;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
bottom_frobbed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (top_frobbed && bottom_frobbed)
|
|
|
|
|
{
|
2000-09-03 11:37:45 +00:00
|
|
|
|
if (topc.pixel == botc.pixel)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
if (botc.pixel == mw->menu.foreground)
|
2000-06-12 19:12:11 +00:00
|
|
|
|
{
|
2000-06-16 18:34:17 +00:00
|
|
|
|
if (mw->menu.free_top_shadow_color_p)
|
|
|
|
|
{
|
|
|
|
|
x_free_dpy_colors (dpy, screen, cmap,
|
|
|
|
|
&mw->menu.top_shadow_color, 1);
|
|
|
|
|
mw->menu.free_top_shadow_color_p = 0;
|
|
|
|
|
}
|
|
|
|
|
mw->menu.top_shadow_color = mw->core.background_pixel;
|
2000-06-12 19:12:11 +00:00
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
else
|
2000-06-12 19:12:11 +00:00
|
|
|
|
{
|
2000-06-16 18:34:17 +00:00
|
|
|
|
if (mw->menu.free_bottom_shadow_color_p)
|
|
|
|
|
{
|
|
|
|
|
x_free_dpy_colors (dpy, screen, cmap,
|
|
|
|
|
&mw->menu.bottom_shadow_color, 1);
|
|
|
|
|
mw->menu.free_bottom_shadow_color_p = 0;
|
|
|
|
|
}
|
|
|
|
|
mw->menu.bottom_shadow_color = mw->menu.foreground;
|
2000-06-12 19:12:11 +00:00
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mw->menu.top_shadow_pixmap &&
|
|
|
|
|
mw->menu.top_shadow_color == mw->core.background_pixel)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.top_shadow_pixmap = mw->menu.gray_pixmap;
|
2000-06-16 18:34:17 +00:00
|
|
|
|
if (mw->menu.free_top_shadow_color_p)
|
|
|
|
|
{
|
|
|
|
|
x_free_dpy_colors (dpy, screen, cmap, &mw->menu.top_shadow_color, 1);
|
|
|
|
|
mw->menu.free_top_shadow_color_p = 0;
|
|
|
|
|
}
|
|
|
|
|
mw->menu.top_shadow_color = mw->menu.foreground;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
if (!mw->menu.bottom_shadow_pixmap &&
|
|
|
|
|
mw->menu.bottom_shadow_color == mw->core.background_pixel)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.bottom_shadow_pixmap = mw->menu.gray_pixmap;
|
2000-06-16 18:34:17 +00:00
|
|
|
|
if (mw->menu.free_bottom_shadow_color_p)
|
|
|
|
|
{
|
|
|
|
|
x_free_dpy_colors (dpy, screen, cmap,
|
|
|
|
|
&mw->menu.bottom_shadow_color, 1);
|
|
|
|
|
mw->menu.free_bottom_shadow_color_p = 0;
|
|
|
|
|
}
|
|
|
|
|
mw->menu.bottom_shadow_color = mw->menu.foreground;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xgcv.fill_style = FillStippled;
|
|
|
|
|
xgcv.foreground = mw->menu.top_shadow_color;
|
|
|
|
|
xgcv.stipple = mw->menu.top_shadow_pixmap;
|
|
|
|
|
pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
|
|
|
|
|
mw->menu.shadow_top_gc = XtGetGC ((Widget)mw, GCForeground | pm, &xgcv);
|
|
|
|
|
|
|
|
|
|
xgcv.foreground = mw->menu.bottom_shadow_color;
|
|
|
|
|
xgcv.stipple = mw->menu.bottom_shadow_pixmap;
|
|
|
|
|
pm = (xgcv.stipple ? GCStipple|GCFillStyle : 0);
|
|
|
|
|
mw->menu.shadow_bottom_gc = XtGetGC ((Widget)mw, GCForeground | pm, &xgcv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
release_shadow_gcs (XlwMenuWidget mw)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
2000-06-12 19:12:11 +00:00
|
|
|
|
Display *dpy = XtDisplay ((Widget) mw);
|
|
|
|
|
Screen *screen = XtScreen ((Widget) mw);
|
|
|
|
|
Colormap cmap = mw->core.colormap;
|
|
|
|
|
Pixel px[2];
|
2000-06-16 18:34:17 +00:00
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
if (mw->menu.free_top_shadow_color_p)
|
|
|
|
|
px[i++] = mw->menu.top_shadow_color;
|
|
|
|
|
if (mw->menu.free_bottom_shadow_color_p)
|
|
|
|
|
px[i++] = mw->menu.bottom_shadow_color;
|
|
|
|
|
if (i > 0)
|
|
|
|
|
x_free_dpy_colors (dpy, screen, cmap, px, i);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
XtReleaseGC ((Widget) mw, mw->menu.shadow_top_gc);
|
|
|
|
|
XtReleaseGC ((Widget) mw, mw->menu.shadow_bottom_gc);
|
|
|
|
|
}
|
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
static int
|
2010-07-04 05:47:55 +00:00
|
|
|
|
openXftFont (XlwMenuWidget mw)
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
{
|
|
|
|
|
char *fname = mw->menu.faceName;
|
|
|
|
|
|
|
|
|
|
mw->menu.xft_font = 0;
|
|
|
|
|
mw->menu.default_face = fname && strcmp (fname, DEFAULT_FACENAME) == 0;
|
|
|
|
|
|
|
|
|
|
if (fname && strcmp (fname, "none") != 0)
|
|
|
|
|
{
|
|
|
|
|
int screen = XScreenNumberOfScreen (mw->core.screen);
|
|
|
|
|
int len = strlen (fname), i = len-1;
|
|
|
|
|
/* Try to convert Gtk-syntax (Sans 9) to Xft syntax Sans-9. */
|
|
|
|
|
while (i > 0 && isdigit (fname[i]))
|
|
|
|
|
--i;
|
|
|
|
|
if (fname[i] == ' ')
|
|
|
|
|
{
|
|
|
|
|
fname = xstrdup (mw->menu.faceName);
|
|
|
|
|
fname[i] = '-';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen, fname);
|
|
|
|
|
if (!mw->menu.xft_font)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Can't find font '%s'\n", fname);
|
|
|
|
|
mw->menu.xft_font = XftFontOpenName (XtDisplay (mw), screen,
|
|
|
|
|
DEFAULT_FACENAME);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fname != mw->menu.faceName) free (fname);
|
|
|
|
|
|
|
|
|
|
return mw->menu.xft_font != 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
static void
|
Fix some bad prototypes and formatting after conversion from K&R declaration.
* lwlib/lwlib-Xaw.c: Include <ctype.h> for isdigit.
(fill_xft_data, set_text): Remove unused variable screen.
(draw_text): Cast bp to FcChar8*.
(find_xft_data): Return 0 if inst or xft_data is not set.
(wm_delete_window): Correct prototype. Initialize widget to 0
and return if widget is still 0 after loop.
* lwlib/xlwmenu.c (XlwMenuSetValues, XlwMenuInitialize): Correct prototype.
(display_menu_item): Remove unused variable gi.
(make_windows_if_needed): Remove unused variable screen.
(XlwMenuRedisplay): Remove unused variable i.
* src/gtkutil.c (xg_get_pixbuf_from_pix_and_mask)
(xg_get_image_for_pixmap, create_dialog)
(xg_get_file_with_selection, xg_get_file_name, update_cl_data)
(menuitem_highlight_callback, make_menu_item)
(xg_create_one_menuitem, create_menus, xg_update_menu_item)
(xg_create_scroll_bar, xg_update_scrollbar_pos)
(xg_set_toolkit_scroll_bar_thumb, xg_tool_bar_button_cb)
(xg_tool_bar_proxy_help_callback, xg_tool_bar_detach_callback)
(xg_tool_bar_attach_callback, xg_tool_bar_help_callback)
(xg_tool_bar_item_expose_callback): Reformat prototype.
(xg_update_menubar): GList *group => GSList *group.
(xg_modify_menubar_widgets): Initialize witem to 0, check witem != 0
before use.
(update_frame_tool_bar): 4:th param to xg_get_image_for_pixmap changed
to GTK_IMAGE (wimage).
* src/xsettings.c (something_changedCB, parse_settings)
(apply_xft_settings): Reformat prototype.
(something_changedCB, init_gconf): Remove unused variable i.
(read_settings): Remove unused variable long_len.
* src/xsmfns.c (SSDATA): New macro.
(smc_save_yourself_CB, x_session_initialize): Use SSDATA for strings
passed to strlen/strcpy/strcat.
(create_client_leader_window): Surround with #ifndef USE_GTK. Cast
7:th arg to XChangeProperty to (unsigned char *)
2010-07-05 09:17:12 +00:00
|
|
|
|
XlwMenuInitialize (Widget request, Widget w, ArgList args, Cardinal *num_args)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
/* Get the GCs and the widget size */
|
Fix some bad prototypes and formatting after conversion from K&R declaration.
* lwlib/lwlib-Xaw.c: Include <ctype.h> for isdigit.
(fill_xft_data, set_text): Remove unused variable screen.
(draw_text): Cast bp to FcChar8*.
(find_xft_data): Return 0 if inst or xft_data is not set.
(wm_delete_window): Correct prototype. Initialize widget to 0
and return if widget is still 0 after loop.
* lwlib/xlwmenu.c (XlwMenuSetValues, XlwMenuInitialize): Correct prototype.
(display_menu_item): Remove unused variable gi.
(make_windows_if_needed): Remove unused variable screen.
(XlwMenuRedisplay): Remove unused variable i.
* src/gtkutil.c (xg_get_pixbuf_from_pix_and_mask)
(xg_get_image_for_pixmap, create_dialog)
(xg_get_file_with_selection, xg_get_file_name, update_cl_data)
(menuitem_highlight_callback, make_menu_item)
(xg_create_one_menuitem, create_menus, xg_update_menu_item)
(xg_create_scroll_bar, xg_update_scrollbar_pos)
(xg_set_toolkit_scroll_bar_thumb, xg_tool_bar_button_cb)
(xg_tool_bar_proxy_help_callback, xg_tool_bar_detach_callback)
(xg_tool_bar_attach_callback, xg_tool_bar_help_callback)
(xg_tool_bar_item_expose_callback): Reformat prototype.
(xg_update_menubar): GList *group => GSList *group.
(xg_modify_menubar_widgets): Initialize witem to 0, check witem != 0
before use.
(update_frame_tool_bar): 4:th param to xg_get_image_for_pixmap changed
to GTK_IMAGE (wimage).
* src/xsettings.c (something_changedCB, parse_settings)
(apply_xft_settings): Reformat prototype.
(something_changedCB, init_gconf): Remove unused variable i.
(read_settings): Remove unused variable long_len.
* src/xsmfns.c (SSDATA): New macro.
(smc_save_yourself_CB, x_session_initialize): Use SSDATA for strings
passed to strlen/strcpy/strcat.
(create_client_leader_window): Surround with #ifndef USE_GTK. Cast
7:th arg to XChangeProperty to (unsigned char *)
2010-07-05 09:17:12 +00:00
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget) w;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
Window window = RootWindowOfScreen (DefaultScreenOfDisplay (XtDisplay (mw)));
|
|
|
|
|
Display* display = XtDisplay (mw);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
#if 0
|
|
|
|
|
widget_value *tem = (widget_value *) XtMalloc (sizeof (widget_value));
|
|
|
|
|
|
|
|
|
|
/* _XtCreate is freeing the object that was passed to us,
|
|
|
|
|
so make a copy that we will actually keep. */
|
Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
* alloc.c (overrun_check_malloc, overrun_check_realloc)
(overrun_check_free, xstrdup, allocate_string)
(allocate_string_data, compact_small_strings, Fmake_string)
(make_unibyte_string, make_multibyte_string)
(make_string_from_bytes, make_specified_string, make_float)
(Fcons, allocate_terminal, allocate_frame, make_pure_string)
(Fgarbage_collect): Replace bcopy, safe_bcopy, bzero, bcmp by
memcpy, memmove, memset, memcmp.
* atimer.c (start_atimer, set_alarm): Likewise.
* buffer.c (clone_per_buffer_values, report_overlay_modification)
(mmap_realloc, init_buffer_once): Likewise.
* callint.c (Fcall_interactively): Likewise.
* callproc.c (Fcall_process, Fcall_process_region, child_setup)
(getenv_internal_1): Likewise.
* casefiddle.c (casify_object): Likewise.
* ccl.c (ccl_driver): Likewise.
* character.c (str_as_multibyte, str_to_multibyte): Likewise.
* charset.c (load_charset_map_from_file)
(load_charset_map_from_file, load_charset_map_from_vector)
(Fdefine_charset_internal): Likewise.
* cm.c (Wcm_clear): Likewise.
* coding.c (decode_eol, decode_coding_object)
(Fset_coding_system_priority, make_subsidiaries): Likewise.
* data.c (Faset): Likewise.
* dired.c (directory_files_internal, file_name_completion_stat):
Likewise.
* dispnew.c (new_glyph_matrix, adjust_glyph_matrix)
(clear_glyph_row, copy_row_except_pointers)
(copy_glyph_row_contents, new_glyph_pool, realloc_glyph_pool)
(save_current_matrix, restore_current_matrix)
(build_frame_matrix_from_leaf_window, mirrored_line_dance)
(mirror_line_dance, scrolling_window): Likewise.
* doc.c (Fsnarf_documentation, Fsubstitute_command_keys):
Likewise.
* doprnt.c (doprnt): Likewise.
* editfns.c (Fuser_full_name, make_buffer_string_both)
(Fmessage_box, Fformat, Ftranspose_regions): Likewise.
* emacs.c (sort_args): Likewise.
* eval.c (Fapply, Ffuncall): Likewise.
* fileio.c (Ffile_name_directory, make_temp_name)
(Fexpand_file_name, search_embedded_absfilename)
(Fsubstitute_in_file_name, Ffile_symlink_p, Finsert_file_contents)
(auto_save_error): Likewise.
* fns.c (Fstring_equal, Fcopy_sequence, concat)
(string_to_multibyte, Fstring_as_unibyte, Fstring_as_multibyte)
(internal_equal, Fclear_string, larger_vector, copy_hash_table)
(Fmake_hash_table): Likewise.
* fringe.c (Fdefine_fringe_bitmap): Likewise.
* ftfont.c (ftfont_text_extents): Likewise.
* getloadavg.c (getloadavg): Likewise.
* image.c (define_image_type, make_image, make_image_cache)
(x_create_x_image_and_pixmap, xbm_image_p)
(w32_create_pixmap_from_bitmap_data, xbm_load, xpm_lookup_color)
(xpm_image_p, x_create_bitmap_from_xpm_data, xpm_load)
(init_color_table, x_build_heuristic_mask, pbm_image_p, pbm_load)
(png_image_p, png_read_from_memory, png_load, jpeg_image_p)
(tiff_image_p, tiff_read_from_memory, gif_image_p)
(gif_read_from_memory, gif_load, svg_image_p, gs_image_p):
Likewise.
* indent.c (scan_for_column, compute_motion): Likewise.
* insdel.c (gap_left, gap_right, make_gap_smaller, copy_text)
(insert_1_both, insert_from_gap, replace_range_2): Likewise.
* intervals.c (reproduce_tree, reproduce_tree_obj): Likewise.
* keyboard.c (echo_char, save_getcjmp, restore_getcjmp)
(kbd_buffer_store_event_hold, apply_modifiers_uncached)
(store_user_signal_events, menu_bar_items, tool_bar_items)
(process_tool_bar_item, append_tool_bar_item)
(read_char_minibuf_menu_prompt, read_key_sequence)
(Fread_key_sequence, Fread_key_sequence_vector, Frecent_keys):
Likewise.
* keymap.c (current_minor_maps, Fdescribe_buffer_bindings):
Likewise.
* lisp.h (STRING_COPYIN): Likewise.
* lread.c (Fload, read1, oblookup): Likewise.
* msdos.c (Frecent_doskeys): Likewise.
* nsfns.m (Fx_create_frame): Likewise.
* nsfont.m (nsfont_open, nsfont_text_extents, ns_glyph_metrics):
Likewise.
* nsimage.m (EmacsImage-initFromSkipXBM:width:height:)
(EmacsImage-initForXPMWithDepth:width:height:flip:length:):
Likewise.
* nsmenu.m (ns_update_menubar): Likewise.
* nsterm.m (ns_draw_fringe_bitmap, ns_term_init): Likewise.
* print.c (print_unwind, printchar, strout, print_string)
(print_error_message): Likewise.
* process.c (conv_lisp_to_sockaddr, set_socket_option)
(Fmake_network_process, Fnetwork_interface_list)
(Fnetwork_interface_info, read_process_output, Fprocess_send_eof)
(init_process): Likewise.
* ralloc.c (resize_bloc, r_alloc_sbrk, r_alloc_init): Likewise.
* regex.c (init_syntax_once, regex_compile, re_compile_fastmap):
Likewise.
* scroll.c (do_scrolling, do_direct_scrolling)
(scrolling_max_lines_saved): Likewise.
* search.c (search_buffer, wordify, Freplace_match): Likewise.
* sound.c (wav_init, au_init, Fplay_sound_internal): Likewise.
* syntax.c (skip_chars, skip_syntaxes): Likewise.
* sysdep.c (child_setup_tty, sys_subshell, emacs_get_tty)
(emacs_set_tty): Likewise.
* term.c (encode_terminal_code, calculate_costs)
(produce_special_glyphs, create_tty_output, init_tty, delete_tty):
Likewise.
* termcap.c (tgetst1, gobble_line): Likewise.
* termhooks.h (EVENT_INIT): Likewise.
* tparam.c (tparam1): Likewise.
* unexalpha.c (unexec): Likewise.
* unexec.c (write_segment): Likewise.
* unexmacosx.c (unexec_write_zero): Likewise.
* w32fns.c (w32_wnd_proc, Fx_create_frame, x_create_tip_frame)
(Fx_file_dialog, Fsystem_move_file_to_trash): Likewise.
* w32font.c (w32font_list_family, w32font_text_extents)
(w32font_list_internal, w32font_match_internal)
(w32font_open_internal, compute_metrics, Fx_select_font):
Likewise.
* w32menu.c (set_frame_menubar, add_menu_item)
(w32_menu_display_help, w32_free_submenu_strings): Likewise.
* w32term.c (XCreateGC, w32_initialize_display_info): Likewise.
* w32uniscribe.c (uniscribe_list_family): Likewise.
* w32xfns.c (get_next_msg, post_msg, prepend_msg): Likewise.
* window.c (make_window, replace_window, set_window_buffer)
(Fsplit_window): Likewise.
* xdisp.c (init_iterator, RECORD_OVERLAY_STRING, reseat_to_string)
(add_to_log, message3, x_consider_frame_title)
(append_space_for_newline, extend_face_to_end_of_line)
(decode_mode_spec_coding, init_glyph_string): Likewise.
* xfaces.c (x_create_gc, get_lface_attributes_no_remap)
(Finternal_copy_lisp_face, Finternal_merge_in_global_face)
(face_attr_equal_p, make_realized_face, make_face_cache)
(free_realized_faces, lookup_named_face, smaller_face)
(face_with_height, lookup_derived_face)
(x_supports_face_attributes_p, Finternal_set_font_selection_order)
(Finternal_set_font_selection_order, realize_default_face)
(compute_char_face, face_at_buffer_position)
(face_for_overlay_string, face_at_string_position, merge_faces):
Likewise.
* xfns.c (xic_create_fontsetname, Fx_create_frame)
(Fx_window_property, x_create_tip_frame)
(Fx_backspace_delete_keys_p): Likewise.
* xfont.c (xfont_list, xfont_match, xfont_list_family)
(xfont_text_extents): Likewise.
* xmenu.c (set_frame_menubar, xmenu_show): Likewise.
* xrdb.c (magic_file_p, x_get_resource): Likewise.
* xselect.c (x_queue_event, x_get_window_property)
(receive_incremental_selection): Likewise.
* xsmfns.c (x_session_check_input): Likewise.
* xterm.c (x_send_scroll_bar_event, SET_SAVED_MENU_EVENT)
(handle_one_xevent, x_check_errors, xim_initialize, x_term_init):
Likewise.
* character.h (BCOPY_SHORT): Removed.
* config.in: Regenerate.
* dispnew.c (safe_bcopy): Only define as dummy if PROFILING.
* emacs.c (main) [PROFILING]: Don't declare
dump_opcode_frequencies.
* lisp.h (safe_bcopy): Remove declaration.
(memset) [!HAVE_MEMSET]: Declare.
(memcpy) [!HAVE_MEMCPY]: Likewise.
(memmove) [!HAVE_MEMMOVE]: Likewise.
(memcmp) [!HAVE_MEMCMP]: Likewise.
* s/ms-w32.h (bzero, bcopy, bcmp, GAP_USE_BCOPY)
(BCOPY_UPWARD_SAFE, BCOPY_DOWNWARD_SAFE, HAVE_BCOPY, HAVE_BCMP):
Don't define.
(HAVE_MEMCMP, HAVE_MEMCPY, HAVE_MEMMOVE, HAVE_MEMSET): Define.
* s/msdos.h (GAP_USE_BCOPY, BCOPY_UPWARD_SAFE)
(BCOPY_DOWNWARD_SAFE): Don't define.
* sysdep.c (memset) [!HAVE_MEMSET]: Define.
(memcpy) [!HAVE_MEMCPY]: Define.
(memmove) [!HAVE_MEMMOVE]: Define.
(memcmp) [!HAVE_MEMCMP]: Define.
* config.nt (HAVE_BCOPY, HAVE_BCMP): Remove undefs.
(HAVE_MEMCPY, HAVE_MEMMOVE, HAVE_MEMSET, HAVE_MEMCMP): Add undefs.
* sed2v2.inp (HAVE_MEMCPY, HAVE_MEMSET): Edit to 1.
(HAVE_BZERO): Don't edit.
* lwlib.c (lwlib_memset, lwlib_bcopy): Remove.
(malloc_widget_value, free_widget_info, allocate_widget_instance)
(lw_separator_p): Replace lwlib_memset, lwlib_bcopy, bzero, bcmp by
memset, memcpy, memcmp.
* lwlib-utils.c (XtApplyToWidgets): Likewise.
* xlwmenu.c (XlwMenuInitialize): Likewise.
* lwlib.h (lwlib_bcopy): Remove declaration.
* ebrowse.c (add_sym, make_namespace): Replace bcopy, bzero by
memcpy, memmove, memset.
* pop.c (pop_retrieve, socket_connection, pop_getline): Likewise.
* CPP-DEFINES (BCOPY_DOWNWARD_SAFE, BCOPY_UPWARD_SAFE)
(GAP_USE_BCOPY, HAVE_BCMP, HAVE_BCOPY, bcmp, bcopy, bzero):
Remove.
* configure.in: Don't check for bcopy, bcmp, bzero. Don't include
<strings.h> and don't define bcopy, bzero, BCMP in config.h.
2010-07-07 22:18:28 +00:00
|
|
|
|
memcpy (tem, mw->menu.contents, sizeof (widget_value));
|
1994-09-17 12:53:30 +00:00
|
|
|
|
mw->menu.contents = tem;
|
|
|
|
|
#endif
|
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
/* mw->menu.cursor = XCreateFontCursor (display, mw->menu.cursor_shape); */
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.cursor = mw->menu.cursor_shape;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1995-05-23 03:04:22 +00:00
|
|
|
|
mw->menu.gray_pixmap
|
2000-07-19 15:49:28 +00:00
|
|
|
|
= XCreatePixmapFromBitmapData (display, window, gray_bitmap_bits,
|
|
|
|
|
gray_bitmap_width, gray_bitmap_height,
|
1995-05-23 03:04:22 +00:00
|
|
|
|
(unsigned long)1, (unsigned long)0, 1);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (openXftFont (mw))
|
|
|
|
|
;
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (!mw->menu.font)
|
|
|
|
|
{
|
|
|
|
|
if (!xlwmenu_default_font)
|
|
|
|
|
xlwmenu_default_font = XLoadQueryFont (display, "fixed");
|
|
|
|
|
mw->menu.font = xlwmenu_default_font;
|
|
|
|
|
if (!mw->menu.font)
|
|
|
|
|
{
|
|
|
|
|
fprintf (stderr, "Menu font fixed not found, can't continue.\n");
|
|
|
|
|
abort ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2005-04-01 18:42:19 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
|
|
|
|
if (mw->menu.fontSet)
|
|
|
|
|
mw->menu.font_extents = XExtentsOfFontSet (mw->menu.fontSet);
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
make_drawing_gcs (mw);
|
|
|
|
|
make_shadow_gcs (mw);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.popped_up = False;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.old_depth = 1;
|
|
|
|
|
mw->menu.old_stack = (widget_value**)XtMalloc (sizeof (widget_value*));
|
|
|
|
|
mw->menu.old_stack_length = 1;
|
|
|
|
|
mw->menu.old_stack [0] = mw->menu.contents;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.new_depth = 0;
|
|
|
|
|
mw->menu.new_stack = 0;
|
|
|
|
|
mw->menu.new_stack_length = 0;
|
|
|
|
|
push_new_stack (mw, mw->menu.contents);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.windows = (window_state*)XtMalloc (sizeof (window_state));
|
|
|
|
|
mw->menu.windows_length = 1;
|
|
|
|
|
mw->menu.windows [0].x = 0;
|
|
|
|
|
mw->menu.windows [0].y = 0;
|
|
|
|
|
mw->menu.windows [0].width = 0;
|
|
|
|
|
mw->menu.windows [0].height = 0;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
mw->menu.windows [0].max_rest_width = 0;
|
2010-04-17 17:43:03 +00:00
|
|
|
|
mw->menu.windows [0].pixmap = None;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
mw->menu.windows [0].xft_draw = 0;
|
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
size_menu (mw, 0);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->core.width = mw->menu.windows [0].width;
|
|
|
|
|
mw->core.height = mw->menu.windows [0].height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
XlwMenuClassInitialize (void)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
xlwmenu_default_font = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
XlwMenuRealize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget)w;
|
|
|
|
|
XSetWindowAttributes xswa;
|
|
|
|
|
int mask;
|
|
|
|
|
|
|
|
|
|
(*xlwMenuWidgetClass->core_class.superclass->core_class.realize)
|
|
|
|
|
(w, valueMask, attributes);
|
|
|
|
|
|
|
|
|
|
xswa.save_under = True;
|
|
|
|
|
xswa.cursor = mw->menu.cursor_shape;
|
|
|
|
|
mask = CWSaveUnder | CWCursor;
|
2006-01-02 07:43:46 +00:00
|
|
|
|
/* I sometimes get random BadCursor errors while creating the first
|
|
|
|
|
frame on a display. I can not find their reason, but they are
|
|
|
|
|
annoying so for now let's ignore any errors here. -- lorentey */
|
|
|
|
|
#ifdef emacs
|
2006-05-24 12:14:26 +00:00
|
|
|
|
x_catch_errors (XtDisplay (w));
|
2006-01-02 07:43:46 +00:00
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
XChangeWindowAttributes (XtDisplay (w), XtWindow (w), mask, &xswa);
|
2006-01-02 07:43:46 +00:00
|
|
|
|
#ifdef emacs
|
2006-05-24 12:14:26 +00:00
|
|
|
|
x_uncatch_errors ();
|
2006-01-02 07:43:46 +00:00
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
2010-04-17 17:43:03 +00:00
|
|
|
|
mw->menu.windows [0].w = w;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.windows [0].window = XtWindow (w);
|
|
|
|
|
mw->menu.windows [0].x = w->core.x;
|
|
|
|
|
mw->menu.windows [0].y = w->core.y;
|
|
|
|
|
mw->menu.windows [0].width = w->core.width;
|
|
|
|
|
mw->menu.windows [0].height = w->core.height;
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
|
2010-04-17 18:18:12 +00:00
|
|
|
|
set_window_type (mw->menu.windows [0].w, mw);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
create_pixmap_for_menu (&mw->menu.windows [0], mw);
|
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (mw->menu.xft_font)
|
|
|
|
|
{
|
|
|
|
|
XColor colors[3];
|
|
|
|
|
colors[0].pixel = mw->menu.xft_fg.pixel = mw->menu.foreground;
|
|
|
|
|
colors[1].pixel = mw->menu.xft_bg.pixel = mw->core.background_pixel;
|
|
|
|
|
colors[2].pixel = mw->menu.xft_disabled_fg.pixel
|
|
|
|
|
= mw->menu.disabled_foreground;
|
|
|
|
|
XQueryColors (XtDisplay (mw), mw->core.colormap, colors, 3);
|
|
|
|
|
mw->menu.xft_fg.color.alpha = 0xFFFF;
|
|
|
|
|
mw->menu.xft_fg.color.red = colors[0].red;
|
|
|
|
|
mw->menu.xft_fg.color.green = colors[0].green;
|
|
|
|
|
mw->menu.xft_fg.color.blue = colors[0].blue;
|
|
|
|
|
mw->menu.xft_bg.color.alpha = 0xFFFF;
|
|
|
|
|
mw->menu.xft_bg.color.red = colors[1].red;
|
|
|
|
|
mw->menu.xft_bg.color.green = colors[1].green;
|
|
|
|
|
mw->menu.xft_bg.color.blue = colors[1].blue;
|
|
|
|
|
mw->menu.xft_disabled_fg.color.alpha = 0xFFFF;
|
|
|
|
|
mw->menu.xft_disabled_fg.color.red = colors[2].red;
|
|
|
|
|
mw->menu.xft_disabled_fg.color.green = colors[2].green;
|
|
|
|
|
mw->menu.xft_disabled_fg.color.blue = colors[2].blue;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Only the toplevel menubar/popup is a widget so it's the only one that
|
|
|
|
|
receives expose events through Xt. So we repaint all the other panes
|
|
|
|
|
when receiving an Expose event. */
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
XlwMenuRedisplay (Widget w, XEvent *ev, Region region)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget)w;
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
/* If we have a depth beyond 1, it's because a submenu was displayed.
|
|
|
|
|
If the submenu has been destroyed, set the depth back to 1. */
|
|
|
|
|
if (submenu_destroyed)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.old_depth = 1;
|
|
|
|
|
submenu_destroyed = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-17 17:43:03 +00:00
|
|
|
|
display_menu (mw, 0, False, NULL, NULL, NULL);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-11-21 22:27:08 +00:00
|
|
|
|
|
|
|
|
|
/* Part of a hack to make the menu redisplay when a tooltip frame
|
|
|
|
|
over a menu item is unmapped. */
|
|
|
|
|
|
|
|
|
|
void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
xlwmenu_redisplay (Widget w)
|
2000-11-21 22:27:08 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuRedisplay (w, NULL, None);
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
XlwMenuDestroy (Widget w)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget) w;
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
if (pointer_grabbed)
|
2002-04-22 18:21:06 +00:00
|
|
|
|
ungrab_all ((Widget)w, CurrentTime);
|
1994-09-17 12:53:30 +00:00
|
|
|
|
pointer_grabbed = 0;
|
|
|
|
|
|
|
|
|
|
submenu_destroyed = 1;
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
release_drawing_gcs (mw);
|
|
|
|
|
release_shadow_gcs (mw);
|
|
|
|
|
|
|
|
|
|
/* this doesn't come from the resource db but is created explicitly
|
|
|
|
|
so we must free it ourselves. */
|
|
|
|
|
XFreePixmap (XtDisplay (mw), mw->menu.gray_pixmap);
|
|
|
|
|
mw->menu.gray_pixmap = (Pixmap) -1;
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
#if 0
|
|
|
|
|
/* Do free mw->menu.contents because nowadays we copy it
|
|
|
|
|
during initialization. */
|
|
|
|
|
XtFree (mw->menu.contents);
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* Don't free mw->menu.contents because that comes from our creator.
|
|
|
|
|
The `*_stack' elements are just pointers into `contents' so leave
|
|
|
|
|
that alone too. But free the stacks themselves. */
|
|
|
|
|
if (mw->menu.old_stack) XtFree ((char *) mw->menu.old_stack);
|
|
|
|
|
if (mw->menu.new_stack) XtFree ((char *) mw->menu.new_stack);
|
|
|
|
|
|
|
|
|
|
/* Remember, you can't free anything that came from the resource
|
|
|
|
|
database. This includes:
|
|
|
|
|
mw->menu.cursor
|
|
|
|
|
mw->menu.top_shadow_pixmap
|
|
|
|
|
mw->menu.bottom_shadow_pixmap
|
|
|
|
|
mw->menu.font
|
|
|
|
|
Also the color cells of top_shadow_color, bottom_shadow_color,
|
|
|
|
|
foreground, and button_foreground will never be freed until this
|
|
|
|
|
client exits. Nice, eh?
|
|
|
|
|
*/
|
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (mw->menu.windows [0].xft_draw)
|
|
|
|
|
XftDrawDestroy (mw->menu.windows [0].xft_draw);
|
|
|
|
|
if (mw->menu.xft_font)
|
|
|
|
|
XftFontClose (XtDisplay (mw), mw->menu.xft_font);
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-04-17 17:43:03 +00:00
|
|
|
|
if (mw->menu.windows [0].pixmap != None)
|
|
|
|
|
XFreePixmap (XtDisplay (mw), mw->menu.windows [0].pixmap);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* start from 1 because the one in slot 0 is w->core.window */
|
|
|
|
|
for (i = 1; i < mw->menu.windows_length; i++)
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
{
|
2010-04-17 17:43:03 +00:00
|
|
|
|
if (mw->menu.windows [i].pixmap != None)
|
|
|
|
|
XFreePixmap (XtDisplay (mw), mw->menu.windows [i].pixmap);
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (mw->menu.windows [i].xft_draw)
|
|
|
|
|
XftDrawDestroy (mw->menu.windows [i].xft_draw);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
if (mw->menu.windows)
|
|
|
|
|
XtFree ((char *) mw->menu.windows);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-16 01:08:29 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
static int
|
|
|
|
|
facename_changed (XlwMenuWidget newmw,
|
|
|
|
|
XlwMenuWidget oldmw)
|
|
|
|
|
{
|
2010-04-17 17:43:03 +00:00
|
|
|
|
/* This will fore a new XftFont even if the same string is set.
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
This is good, as rendering parameters may have changed and
|
|
|
|
|
we just want to do a redisplay. */
|
|
|
|
|
return newmw->menu.faceName != oldmw->menu.faceName;
|
|
|
|
|
}
|
2010-04-16 01:08:29 +00:00
|
|
|
|
#endif
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static Boolean
|
Fix some bad prototypes and formatting after conversion from K&R declaration.
* lwlib/lwlib-Xaw.c: Include <ctype.h> for isdigit.
(fill_xft_data, set_text): Remove unused variable screen.
(draw_text): Cast bp to FcChar8*.
(find_xft_data): Return 0 if inst or xft_data is not set.
(wm_delete_window): Correct prototype. Initialize widget to 0
and return if widget is still 0 after loop.
* lwlib/xlwmenu.c (XlwMenuSetValues, XlwMenuInitialize): Correct prototype.
(display_menu_item): Remove unused variable gi.
(make_windows_if_needed): Remove unused variable screen.
(XlwMenuRedisplay): Remove unused variable i.
* src/gtkutil.c (xg_get_pixbuf_from_pix_and_mask)
(xg_get_image_for_pixmap, create_dialog)
(xg_get_file_with_selection, xg_get_file_name, update_cl_data)
(menuitem_highlight_callback, make_menu_item)
(xg_create_one_menuitem, create_menus, xg_update_menu_item)
(xg_create_scroll_bar, xg_update_scrollbar_pos)
(xg_set_toolkit_scroll_bar_thumb, xg_tool_bar_button_cb)
(xg_tool_bar_proxy_help_callback, xg_tool_bar_detach_callback)
(xg_tool_bar_attach_callback, xg_tool_bar_help_callback)
(xg_tool_bar_item_expose_callback): Reformat prototype.
(xg_update_menubar): GList *group => GSList *group.
(xg_modify_menubar_widgets): Initialize witem to 0, check witem != 0
before use.
(update_frame_tool_bar): 4:th param to xg_get_image_for_pixmap changed
to GTK_IMAGE (wimage).
* src/xsettings.c (something_changedCB, parse_settings)
(apply_xft_settings): Reformat prototype.
(something_changedCB, init_gconf): Remove unused variable i.
(read_settings): Remove unused variable long_len.
* src/xsmfns.c (SSDATA): New macro.
(smc_save_yourself_CB, x_session_initialize): Use SSDATA for strings
passed to strlen/strcpy/strcat.
(create_client_leader_window): Surround with #ifndef USE_GTK. Cast
7:th arg to XChangeProperty to (unsigned char *)
2010-07-05 09:17:12 +00:00
|
|
|
|
XlwMenuSetValues (Widget current, Widget request, Widget new,
|
|
|
|
|
ArgList args, Cardinal *num_args)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget oldmw = (XlwMenuWidget)current;
|
|
|
|
|
XlwMenuWidget newmw = (XlwMenuWidget)new;
|
|
|
|
|
Boolean redisplay = False;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if (newmw->menu.contents
|
|
|
|
|
&& newmw->menu.contents->contents
|
|
|
|
|
&& newmw->menu.contents->contents->change >= VISIBLE_CHANGE)
|
|
|
|
|
redisplay = True;
|
1995-12-31 19:15:18 +00:00
|
|
|
|
/* Do redisplay if the contents are entirely eliminated. */
|
|
|
|
|
if (newmw->menu.contents
|
|
|
|
|
&& newmw->menu.contents->contents == 0
|
|
|
|
|
&& newmw->menu.contents->change >= VISIBLE_CHANGE)
|
|
|
|
|
redisplay = True;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
if (newmw->core.background_pixel != oldmw->core.background_pixel
|
1994-09-17 12:53:30 +00:00
|
|
|
|
|| newmw->menu.foreground != oldmw->menu.foreground
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
|| facename_changed (newmw, oldmw)
|
|
|
|
|
#endif
|
2005-04-01 18:42:19 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
|
|
|
|
|| newmw->menu.fontSet != oldmw->menu.fontSet
|
|
|
|
|
|| (newmw->menu.fontSet == NULL && newmw->menu.font != oldmw->menu.font)
|
|
|
|
|
#else
|
2005-03-18 04:19:41 +00:00
|
|
|
|
|| newmw->menu.font != oldmw->menu.font
|
|
|
|
|
#endif
|
|
|
|
|
)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
release_drawing_gcs (newmw);
|
|
|
|
|
make_drawing_gcs (newmw);
|
2000-08-30 11:52:37 +00:00
|
|
|
|
|
|
|
|
|
release_shadow_gcs (newmw);
|
|
|
|
|
/* Cause the shadow colors to be recalculated. */
|
|
|
|
|
newmw->menu.top_shadow_color = -1;
|
|
|
|
|
newmw->menu.bottom_shadow_color = -1;
|
|
|
|
|
make_shadow_gcs (newmw);
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
redisplay = True;
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
2000-09-04 12:13:34 +00:00
|
|
|
|
if (XtIsRealized (current))
|
2000-09-04 11:55:02 +00:00
|
|
|
|
/* If the menu is currently displayed, change the display. */
|
|
|
|
|
for (i = 0; i < oldmw->menu.windows_length; i++)
|
|
|
|
|
{
|
|
|
|
|
XSetWindowBackground (XtDisplay (oldmw),
|
|
|
|
|
oldmw->menu.windows [i].window,
|
|
|
|
|
newmw->core.background_pixel);
|
|
|
|
|
/* clear windows and generate expose events */
|
|
|
|
|
XClearArea (XtDisplay (oldmw), oldmw->menu.windows[i].window,
|
|
|
|
|
0, 0, 0, 0, True);
|
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
Lucid menus can now use Xft for fonts.
* xsettings.c (current_font, SYSTEM_FONT, XSETTINGS_FONT_NAME): New.
(parse_xft_settings): Also check for XSETTINGS_FONT_NAME and save that
in current_font.
(init_gconf): Read value of SYSTEM_FONT and save it in current_font.
(Ffont_get_system_normal_font, xsettings_get_system_normal_font): New
functions.
(syms_of_xsettings): Initialize current_font. defsubr
Sfont_get_system_normal_font.
* xsettings.h (Ffont_get_system_normal_font,
xsettings_get_system_normal_font): Declare.
* xfns.c (extern xlwmenu_default_font): Remove.
(Fx_create_frame): Remove setting of xlwmenu_default_font, moved
to xlwmenu.c.
* menu.c (digest_single_submenu): If USE_LUCID and HAVE_XFT, encode
menu items in UTF-8.
* xmenu.c: include xsettings.h and xlwmenu.h if USE_LUCID.
(apply_systemfont_to_menu): New function.
(set_frame_menubar, create_and_show_popup_menu): Call
apply_systemfont_to_menu.
* xlwmenu.c (xlwmenu_default_font): Make static.
(xlwMenuResources): Add XtNfaceName and XtNdefaultFace.
(string_width): Use XftTextExtentsUtf8 if HAVE_XFT.
(MENU_FONT_HEIGHT, MENU_FONT_ASCENT): Add versions for
HAVE_XFT.
(size_menu): Set max_rest_width in window_state structure.
(display_menu_item): If HAVE_XFT and xft_draw is set, use
XftDrawRect and XftDrawStringUtf8 to draw text.
(make_windows_if_needed): Set max_rest_width and xft_draw
in windows[i].
(openXftFont): New.
(XlwMenuInitialize): Call openXftFont if HAVE_XFT. If mw->menu.font
is not set, load font fixed and save it in xlwmenu_default_font.
(XlwMenuInitialize): Set max_rest_width and xft_draw in windows[0].
(XlwMenuClassInitialize): Initialize xlwmenu_default_font.
(XlwMenuRealize): Set xft_fg, xft_bg, xft_disabled_fg and
windows[0].xft_draw if xft_font is set.
(XlwMenuDestroy): Destroy all xft_draw and close xft_font.
(facename_changed): New.
(XlwMenuSetValues): Call facename_changed. If face name did change,
close old fonts and destroy xft_draw:s. Then create new ones.
* xlwmenu.h (XtNfaceName, XtCFaceName, XtNdefaultFace,
XtCDefaultFace): New.
* xlwmenuP.h (_window_state): Add max_rest_width and xft_draw.
(_XlwMenu_part): Add faceName,xft_fg, xft_bg, xft_disabled_fg and
xft_font.
* xresources.texi (Lucid Resources): Mention faceName to set Xft fonts.
2010-04-08 16:20:32 +00:00
|
|
|
|
#ifdef HAVE_XFT
|
|
|
|
|
if (facename_changed (newmw, oldmw))
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
int screen = XScreenNumberOfScreen (newmw->core.screen);
|
|
|
|
|
if (newmw->menu.xft_font)
|
|
|
|
|
XftFontClose (XtDisplay (newmw), newmw->menu.xft_font);
|
|
|
|
|
openXftFont (newmw);
|
|
|
|
|
for (i = 0; i < newmw->menu.windows_length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (newmw->menu.windows [i].xft_draw)
|
|
|
|
|
XftDrawDestroy (newmw->menu.windows [i].xft_draw);
|
|
|
|
|
newmw->menu.windows [i].xft_draw = 0;
|
|
|
|
|
}
|
|
|
|
|
if (newmw->menu.xft_font)
|
|
|
|
|
for (i = 0; i < newmw->menu.windows_length; i++)
|
|
|
|
|
newmw->menu.windows [i].xft_draw
|
|
|
|
|
= XftDrawCreate (XtDisplay (newmw),
|
|
|
|
|
newmw->menu.windows [i].window,
|
|
|
|
|
DefaultVisual (XtDisplay (newmw), screen),
|
|
|
|
|
newmw->core.colormap);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2005-03-18 04:19:41 +00:00
|
|
|
|
#ifdef HAVE_X_I18N
|
2005-04-01 18:42:19 +00:00
|
|
|
|
if (newmw->menu.fontSet != oldmw->menu.fontSet && newmw->menu.fontSet != NULL)
|
2005-03-18 04:19:41 +00:00
|
|
|
|
{
|
|
|
|
|
redisplay = True;
|
2005-04-01 18:42:19 +00:00
|
|
|
|
newmw->menu.font_extents = XExtentsOfFontSet (newmw->menu.fontSet);
|
2005-03-18 04:19:41 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
return redisplay;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
XlwMenuResize (Widget w)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget)w;
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
if (mw->menu.popped_up)
|
|
|
|
|
{
|
|
|
|
|
/* Don't allow the popup menu to resize itself. */
|
|
|
|
|
mw->core.width = mw->menu.windows [0].width;
|
|
|
|
|
mw->core.height = mw->menu.windows [0].height;
|
2010-04-17 17:43:03 +00:00
|
|
|
|
mw->core.parent->core.width = mw->core.width;
|
|
|
|
|
mw->core.parent->core.height = mw->core.height;
|
1994-09-17 12:53:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
mw->menu.windows [0].width = mw->core.width;
|
|
|
|
|
mw->menu.windows [0].height = mw->core.height;
|
2010-04-17 17:43:03 +00:00
|
|
|
|
create_pixmap_for_menu (&mw->menu.windows [0], mw);
|
1994-09-17 12:53:30 +00:00
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Action procedures */
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
handle_single_motion_event (XlwMenuWidget mw, XMotionEvent *ev)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
widget_value* val;
|
|
|
|
|
int level;
|
|
|
|
|
|
|
|
|
|
if (!map_event_to_widget_value (mw, ev, &val, &level))
|
|
|
|
|
pop_new_stack_if_no_contents (mw);
|
|
|
|
|
else
|
|
|
|
|
set_new_state (mw, val, level);
|
|
|
|
|
remap_menubar (mw);
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-01-18 23:47:41 +00:00
|
|
|
|
/* Sync with the display. Makes it feel better on X terms. */
|
|
|
|
|
XSync (XtDisplay (mw), False);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
handle_motion_event (XlwMenuWidget mw, XMotionEvent *ev)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
int x = ev->x_root;
|
|
|
|
|
int y = ev->y_root;
|
|
|
|
|
int state = ev->state;
|
2010-04-17 17:43:03 +00:00
|
|
|
|
XMotionEvent oldev = *ev;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
/* allow motion events to be generated again */
|
|
|
|
|
if (ev->is_hint
|
|
|
|
|
&& XQueryPointer (XtDisplay (mw), ev->window,
|
|
|
|
|
&ev->root, &ev->subwindow,
|
|
|
|
|
&ev->x_root, &ev->y_root,
|
|
|
|
|
&ev->x, &ev->y,
|
|
|
|
|
&ev->state)
|
|
|
|
|
&& ev->state == state
|
|
|
|
|
&& (ev->x_root != x || ev->y_root != y))
|
|
|
|
|
handle_single_motion_event (mw, ev);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
else
|
|
|
|
|
handle_single_motion_event (mw, &oldev);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Start (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget)w;
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
if (!mw->menu.popped_up)
|
|
|
|
|
{
|
|
|
|
|
menu_post_event = *ev;
|
2004-01-12 01:45:22 +00:00
|
|
|
|
/* If event is set to CurrentTime, get the last known time stamp.
|
|
|
|
|
This is for calculating if (popup) menus should stay up after
|
|
|
|
|
a fast click. */
|
|
|
|
|
if (menu_post_event.xbutton.time == CurrentTime)
|
|
|
|
|
menu_post_event.xbutton.time
|
|
|
|
|
= XtLastTimestampProcessed (XtDisplay (w));
|
|
|
|
|
|
2000-06-06 14:21:15 +00:00
|
|
|
|
pop_up_menu (mw, (XButtonPressedEvent*) ev);
|
1994-09-17 12:53:30 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
1994-09-23 21:02:25 +00:00
|
|
|
|
{
|
|
|
|
|
/* If we push a button while the menu is posted semipermanently,
|
|
|
|
|
releasing the button should always pop the menu down. */
|
|
|
|
|
next_release_must_exit = 1;
|
1994-09-17 12:53:30 +00:00
|
|
|
|
|
1994-09-23 21:02:25 +00:00
|
|
|
|
/* notes the absolute position of the menubar window */
|
|
|
|
|
mw->menu.windows [0].x = ev->xmotion.x_root - ev->xmotion.x;
|
|
|
|
|
mw->menu.windows [0].y = ev->xmotion.y_root - ev->xmotion.y;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
1994-09-23 21:02:25 +00:00
|
|
|
|
/* handles the down like a move, slots are compatible */
|
2006-05-23 07:19:45 +00:00
|
|
|
|
ev->xmotion.is_hint = 0;
|
1994-09-23 21:02:25 +00:00
|
|
|
|
handle_motion_event (mw, &ev->xmotion);
|
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-28 20:30:52 +00:00
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Drag (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget)w;
|
1995-05-29 07:16:27 +00:00
|
|
|
|
if (mw->menu.popped_up)
|
|
|
|
|
handle_motion_event (mw, &ev->xmotion);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
1995-12-31 19:15:18 +00:00
|
|
|
|
/* Do nothing.
|
|
|
|
|
This is how we handle presses and releases of modifier keys. */
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Nothing (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
1995-12-31 19:15:18 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-12 01:45:22 +00:00
|
|
|
|
static widget_value *
|
2010-07-04 05:47:55 +00:00
|
|
|
|
find_first_selectable (XlwMenuWidget mw, widget_value *item, int skip_titles)
|
2002-04-20 13:39:57 +00:00
|
|
|
|
{
|
|
|
|
|
widget_value *current = item;
|
|
|
|
|
enum menu_separator separator;
|
|
|
|
|
|
2004-01-12 01:45:22 +00:00
|
|
|
|
while (lw_separator_p (current->name, &separator, 0) || !current->enabled
|
2004-11-01 12:20:45 +00:00
|
|
|
|
|| (skip_titles && !current->call_data && !current->contents))
|
2002-04-20 13:39:57 +00:00
|
|
|
|
if (current->next)
|
|
|
|
|
current=current->next;
|
|
|
|
|
else
|
2004-11-01 12:20:45 +00:00
|
|
|
|
return NULL;
|
2002-04-20 13:39:57 +00:00
|
|
|
|
|
|
|
|
|
return current;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-12 01:45:22 +00:00
|
|
|
|
static widget_value *
|
2010-07-04 05:47:55 +00:00
|
|
|
|
find_next_selectable (XlwMenuWidget mw, widget_value *item, int skip_titles)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
{
|
|
|
|
|
widget_value *current = item;
|
|
|
|
|
enum menu_separator separator;
|
|
|
|
|
|
|
|
|
|
while (current->next && (current=current->next) &&
|
2004-01-12 01:45:22 +00:00
|
|
|
|
(lw_separator_p (current->name, &separator, 0) || !current->enabled
|
2004-11-01 12:20:45 +00:00
|
|
|
|
|| (skip_titles && !current->call_data && !current->contents)))
|
2002-04-19 18:56:51 +00:00
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
if (current == item)
|
|
|
|
|
{
|
2002-05-06 18:56:25 +00:00
|
|
|
|
if (mw->menu.old_depth < 2)
|
|
|
|
|
return current;
|
2002-04-19 18:56:51 +00:00
|
|
|
|
current = mw->menu.old_stack [mw->menu.old_depth - 2]->contents;
|
|
|
|
|
|
2004-01-12 01:45:22 +00:00
|
|
|
|
while (lw_separator_p (current->name, &separator, 0)
|
|
|
|
|
|| !current->enabled
|
2004-11-01 12:20:45 +00:00
|
|
|
|
|| (skip_titles && !current->call_data
|
|
|
|
|
&& !current->contents))
|
2002-04-20 13:39:57 +00:00
|
|
|
|
{
|
|
|
|
|
if (current->next)
|
|
|
|
|
current=current->next;
|
|
|
|
|
|
|
|
|
|
if (current == item)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-19 18:56:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return current;
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-12 01:45:22 +00:00
|
|
|
|
static widget_value *
|
2010-07-04 05:47:55 +00:00
|
|
|
|
find_prev_selectable (XlwMenuWidget mw, widget_value *item, int skip_titles)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
{
|
|
|
|
|
widget_value *current = item;
|
|
|
|
|
widget_value *prev = item;
|
|
|
|
|
|
2004-11-01 12:20:45 +00:00
|
|
|
|
while ((current=find_next_selectable (mw, current, skip_titles))
|
2004-01-12 01:45:22 +00:00
|
|
|
|
!= item)
|
2002-04-20 13:39:57 +00:00
|
|
|
|
{
|
|
|
|
|
if (prev == current)
|
|
|
|
|
break;
|
2002-04-19 18:56:51 +00:00
|
|
|
|
prev=current;
|
2002-04-20 13:39:57 +00:00
|
|
|
|
}
|
2002-04-19 18:56:51 +00:00
|
|
|
|
|
|
|
|
|
return prev;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Down (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget) w;
|
|
|
|
|
widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
|
2004-01-12 01:45:22 +00:00
|
|
|
|
int popup_menu_p = mw->menu.top_depth == 1;
|
2002-04-19 18:56:51 +00:00
|
|
|
|
|
|
|
|
|
/* Inside top-level menu-bar? */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
if (mw->menu.old_depth == mw->menu.top_depth)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
/* When <down> in the menu-bar is pressed, display the corresponding
|
2004-01-12 01:45:22 +00:00
|
|
|
|
sub-menu and select the first selectable menu item there.
|
2004-11-01 12:20:45 +00:00
|
|
|
|
If this is a popup menu, skip title item of the popup. */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw,
|
|
|
|
|
find_first_selectable (mw,
|
|
|
|
|
selected_item->contents,
|
|
|
|
|
popup_menu_p),
|
|
|
|
|
mw->menu.old_depth);
|
2002-04-19 18:56:51 +00:00
|
|
|
|
else
|
|
|
|
|
/* Highlight next possible (enabled and not separator) menu item. */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw, find_next_selectable (mw, selected_item, popup_menu_p),
|
|
|
|
|
mw->menu.old_depth - 1);
|
2002-04-19 18:56:51 +00:00
|
|
|
|
|
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Up (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget) w;
|
|
|
|
|
widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
|
2004-01-12 01:45:22 +00:00
|
|
|
|
int popup_menu_p = mw->menu.top_depth == 1;
|
2002-04-19 18:56:51 +00:00
|
|
|
|
|
|
|
|
|
/* Inside top-level menu-bar? */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
if (mw->menu.old_depth == mw->menu.top_depth)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
{
|
|
|
|
|
/* FIXME: this is tricky. <up> in the menu-bar should select the
|
2002-04-20 13:39:57 +00:00
|
|
|
|
last selectable item in the list. So we select the first
|
|
|
|
|
selectable one and find the previous selectable item. Is there
|
|
|
|
|
a better way? */
|
2004-11-01 12:20:45 +00:00
|
|
|
|
/* If this is a popup menu, skip title item of the popup. */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw,
|
|
|
|
|
find_first_selectable (mw,
|
|
|
|
|
selected_item->contents,
|
|
|
|
|
popup_menu_p),
|
|
|
|
|
mw->menu.old_depth);
|
2002-04-19 18:56:51 +00:00
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw,
|
|
|
|
|
find_prev_selectable (mw,
|
|
|
|
|
selected_item,
|
|
|
|
|
popup_menu_p),
|
|
|
|
|
mw->menu.old_depth - 1);
|
2002-04-19 18:56:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* Highlight previous (enabled and not separator) menu item. */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw, find_prev_selectable (mw, selected_item, popup_menu_p),
|
|
|
|
|
mw->menu.old_depth - 1);
|
2002-04-19 18:56:51 +00:00
|
|
|
|
|
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-12 01:45:22 +00:00
|
|
|
|
void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Left (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget) w;
|
|
|
|
|
widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
|
|
|
|
|
|
|
|
|
|
/* Inside top-level menu-bar? */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
if (mw->menu.old_depth == mw->menu.top_depth)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
/* When <left> in the menu-bar is pressed, display the previous item on
|
|
|
|
|
the menu-bar. If the current item is the first one, highlight the
|
|
|
|
|
last item in the menubar (probably Help). */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw, find_prev_selectable (mw, selected_item, 0),
|
|
|
|
|
mw->menu.old_depth - 1);
|
2002-12-22 22:00:44 +00:00
|
|
|
|
else if (mw->menu.old_depth == 1
|
|
|
|
|
&& selected_item->contents) /* Is this menu item expandable? */
|
|
|
|
|
{
|
|
|
|
|
set_new_state (mw, selected_item->contents, mw->menu.old_depth);
|
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
|
2004-01-12 01:45:22 +00:00
|
|
|
|
if (!selected_item->enabled && find_first_selectable (mw,
|
|
|
|
|
selected_item,
|
|
|
|
|
0))
|
|
|
|
|
set_new_state (mw, find_first_selectable (mw, selected_item, 0),
|
|
|
|
|
mw->menu.old_depth - 1);
|
2002-12-22 22:00:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-19 18:56:51 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pop_new_stack_if_no_contents (mw);
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw, mw->menu.old_stack [mw->menu.old_depth - 2],
|
|
|
|
|
mw->menu.old_depth - 2);
|
2002-04-19 18:56:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
}
|
|
|
|
|
|
2004-01-12 01:45:22 +00:00
|
|
|
|
void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Right (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget) w;
|
|
|
|
|
widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
|
|
|
|
|
|
|
|
|
|
/* Inside top-level menu-bar? */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
if (mw->menu.old_depth == mw->menu.top_depth)
|
2002-04-19 18:56:51 +00:00
|
|
|
|
/* When <right> in the menu-bar is pressed, display the next item on
|
|
|
|
|
the menu-bar. If the current item is the last one, highlight the
|
|
|
|
|
first item (probably File). */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw, find_next_selectable (mw, selected_item, 0),
|
|
|
|
|
mw->menu.old_depth - 1);
|
2002-04-19 18:56:51 +00:00
|
|
|
|
else if (selected_item->contents) /* Is this menu item expandable? */
|
2002-04-20 13:39:57 +00:00
|
|
|
|
{
|
|
|
|
|
set_new_state (mw, selected_item->contents, mw->menu.old_depth);
|
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
|
2004-01-12 01:45:22 +00:00
|
|
|
|
if (!selected_item->enabled && find_first_selectable (mw,
|
|
|
|
|
selected_item,
|
|
|
|
|
0))
|
|
|
|
|
set_new_state (mw, find_first_selectable (mw, selected_item, 0),
|
|
|
|
|
mw->menu.old_depth - 1);
|
2002-04-20 13:39:57 +00:00
|
|
|
|
}
|
2002-04-19 18:56:51 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pop_new_stack_if_no_contents (mw);
|
2004-01-12 01:45:22 +00:00
|
|
|
|
set_new_state (mw, mw->menu.old_stack [mw->menu.old_depth - 2],
|
|
|
|
|
mw->menu.old_depth - 2);
|
2002-04-19 18:56:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
}
|
|
|
|
|
|
1995-12-31 19:15:18 +00:00
|
|
|
|
/* Handle key press and release events while menu is popped up.
|
|
|
|
|
Our action is to get rid of the menu. */
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Key (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
1995-12-31 19:15:18 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget)w;
|
|
|
|
|
|
|
|
|
|
/* Pop down everything. */
|
|
|
|
|
mw->menu.new_depth = 1;
|
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
|
|
|
|
|
if (mw->menu.popped_up)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.popped_up = False;
|
2002-04-22 18:21:06 +00:00
|
|
|
|
ungrab_all ((Widget)mw, ev->xmotion.time);
|
1995-12-31 19:15:18 +00:00
|
|
|
|
if (XtIsShell (XtParent ((Widget) mw)))
|
|
|
|
|
XtPopdown (XtParent ((Widget) mw));
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
XtRemoveGrab ((Widget) mw);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
display_menu (mw, 0, False, NULL, NULL, NULL);
|
1995-12-31 19:15:18 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* callback */
|
|
|
|
|
XtCallCallbackList ((Widget)mw, mw->menu.select, (XtPointer)0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
Select (Widget w, XEvent *ev, String *params, Cardinal *num_params)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
XlwMenuWidget mw = (XlwMenuWidget)w;
|
|
|
|
|
widget_value* selected_item = mw->menu.old_stack [mw->menu.old_depth - 1];
|
2000-09-28 20:30:52 +00:00
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
/* If user releases the button quickly, without selecting anything,
|
|
|
|
|
after the initial down-click that brought the menu up,
|
|
|
|
|
do nothing. */
|
|
|
|
|
if ((selected_item == 0
|
|
|
|
|
|| ((widget_value *) selected_item)->call_data == 0)
|
|
|
|
|
&& !next_release_must_exit
|
|
|
|
|
&& (ev->xbutton.time - menu_post_event.xbutton.time
|
|
|
|
|
< XtGetMultiClickTime (XtDisplay (w))))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* pop down everything. */
|
1994-01-18 23:47:41 +00:00
|
|
|
|
mw->menu.new_depth = 1;
|
|
|
|
|
remap_menubar (mw);
|
|
|
|
|
|
|
|
|
|
if (mw->menu.popped_up)
|
|
|
|
|
{
|
|
|
|
|
mw->menu.popped_up = False;
|
2002-04-22 18:21:06 +00:00
|
|
|
|
ungrab_all ((Widget)mw, ev->xmotion.time);
|
1994-09-24 00:12:06 +00:00
|
|
|
|
if (XtIsShell (XtParent ((Widget) mw)))
|
|
|
|
|
XtPopdown (XtParent ((Widget) mw));
|
1994-09-23 21:02:25 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
XtRemoveGrab ((Widget) mw);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
display_menu (mw, 0, False, NULL, NULL, NULL);
|
1994-09-23 21:02:25 +00:00
|
|
|
|
}
|
1994-01-18 23:47:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* callback */
|
|
|
|
|
XtCallCallbackList ((Widget)mw, mw->menu.select, (XtPointer)selected_item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Special code to pop-up a menu */
|
2004-01-12 01:45:22 +00:00
|
|
|
|
static void
|
2010-07-04 05:47:55 +00:00
|
|
|
|
pop_up_menu (XlwMenuWidget mw, XButtonPressedEvent *event)
|
1994-01-18 23:47:41 +00:00
|
|
|
|
{
|
|
|
|
|
int x = event->x_root;
|
|
|
|
|
int y = event->y_root;
|
|
|
|
|
int w;
|
|
|
|
|
int h;
|
|
|
|
|
int borderwidth = mw->menu.shadow_thickness;
|
|
|
|
|
Screen* screen = XtScreen (mw);
|
1994-10-26 04:57:41 +00:00
|
|
|
|
Display *display = XtDisplay (mw);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
next_release_must_exit = 0;
|
|
|
|
|
|
2007-01-01 15:20:11 +00:00
|
|
|
|
mw->menu.inside_entry = NULL;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
XtCallCallbackList ((Widget)mw, mw->menu.open, NULL);
|
|
|
|
|
|
1994-09-24 00:12:06 +00:00
|
|
|
|
if (XtIsShell (XtParent ((Widget)mw)))
|
1994-09-23 21:02:25 +00:00
|
|
|
|
size_menu (mw, 0);
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
|
|
|
|
w = mw->menu.windows [0].width;
|
|
|
|
|
h = mw->menu.windows [0].height;
|
|
|
|
|
|
|
|
|
|
x -= borderwidth;
|
|
|
|
|
y -= borderwidth;
|
|
|
|
|
if (x < borderwidth)
|
|
|
|
|
x = borderwidth;
|
|
|
|
|
if (x + w + 2 * borderwidth > WidthOfScreen (screen))
|
|
|
|
|
x = WidthOfScreen (screen) - w - 2 * borderwidth;
|
|
|
|
|
if (y < borderwidth)
|
|
|
|
|
y = borderwidth;
|
|
|
|
|
if (y + h + 2 * borderwidth> HeightOfScreen (screen))
|
|
|
|
|
y = HeightOfScreen (screen) - h - 2 * borderwidth;
|
|
|
|
|
|
|
|
|
|
mw->menu.popped_up = True;
|
1994-09-24 00:12:06 +00:00
|
|
|
|
if (XtIsShell (XtParent ((Widget)mw)))
|
1994-09-23 21:02:25 +00:00
|
|
|
|
{
|
1994-09-24 00:12:06 +00:00
|
|
|
|
XtConfigureWidget (XtParent ((Widget)mw), x, y, w, h,
|
|
|
|
|
XtParent ((Widget)mw)->core.border_width);
|
|
|
|
|
XtPopup (XtParent ((Widget)mw), XtGrabExclusive);
|
2010-04-17 17:43:03 +00:00
|
|
|
|
display_menu (mw, 0, False, NULL, NULL, NULL);
|
1994-09-23 21:02:25 +00:00
|
|
|
|
mw->menu.windows [0].x = x + borderwidth;
|
|
|
|
|
mw->menu.windows [0].y = y + borderwidth;
|
2004-01-12 01:45:22 +00:00
|
|
|
|
mw->menu.top_depth = 1; /* Popup menus don't have a bar so top is 1 */
|
1994-09-23 21:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
XEvent *ev = (XEvent *) event;
|
|
|
|
|
|
1994-09-25 23:30:51 +00:00
|
|
|
|
XtAddGrab ((Widget) mw, True, True);
|
1994-09-23 21:02:25 +00:00
|
|
|
|
|
|
|
|
|
/* notes the absolute position of the menubar window */
|
|
|
|
|
mw->menu.windows [0].x = ev->xmotion.x_root - ev->xmotion.x;
|
|
|
|
|
mw->menu.windows [0].y = ev->xmotion.y_root - ev->xmotion.y;
|
2004-01-12 01:45:22 +00:00
|
|
|
|
mw->menu.top_depth = 2;
|
1994-09-23 21:02:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
#ifdef emacs
|
2006-05-23 07:19:45 +00:00
|
|
|
|
x_catch_errors (display);
|
1994-09-17 12:53:30 +00:00
|
|
|
|
#endif
|
2002-04-22 18:21:06 +00:00
|
|
|
|
if (XtGrabPointer ((Widget)mw, False,
|
|
|
|
|
(PointerMotionMask
|
|
|
|
|
| PointerMotionHintMask
|
|
|
|
|
| ButtonReleaseMask
|
|
|
|
|
| ButtonPressMask),
|
|
|
|
|
GrabModeAsync, GrabModeAsync, None,
|
|
|
|
|
mw->menu.cursor_shape,
|
|
|
|
|
event->time) == Success)
|
|
|
|
|
{
|
2002-04-28 19:54:30 +00:00
|
|
|
|
if (! GRAB_KEYBOARD
|
2002-04-22 18:21:06 +00:00
|
|
|
|
|| XtGrabKeyboard ((Widget)mw, False, GrabModeAsync,
|
|
|
|
|
GrabModeAsync, event->time) == Success)
|
|
|
|
|
{
|
|
|
|
|
XtSetKeyboardFocus((Widget)mw, None);
|
|
|
|
|
pointer_grabbed = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
XtUngrabPointer ((Widget)mw, event->time);
|
|
|
|
|
}
|
|
|
|
|
|
1994-09-17 12:53:30 +00:00
|
|
|
|
#ifdef emacs
|
1994-10-26 04:57:41 +00:00
|
|
|
|
if (x_had_errors_p (display))
|
1994-09-17 12:53:30 +00:00
|
|
|
|
{
|
|
|
|
|
pointer_grabbed = 0;
|
|
|
|
|
XtUngrabPointer ((Widget)mw, event->time);
|
|
|
|
|
}
|
2006-05-23 07:19:45 +00:00
|
|
|
|
x_uncatch_errors ();
|
1994-09-17 12:53:30 +00:00
|
|
|
|
#endif
|
1994-01-18 23:47:41 +00:00
|
|
|
|
|
2006-05-23 07:19:45 +00:00
|
|
|
|
((XMotionEvent*)event)->is_hint = 0;
|
1994-01-18 23:47:41 +00:00
|
|
|
|
handle_motion_event (mw, (XMotionEvent*)event);
|
|
|
|
|
}
|
2003-09-01 15:45:59 +00:00
|
|
|
|
|