1999-11-18 20:05:24 -08:00
|
|
|
/*
|
2000-01-05 09:34:32 -08:00
|
|
|
* Copyright (C) 1997-2000, Michael Jennings
|
1999-08-17 16:01:18 -07:00
|
|
|
*
|
1999-11-18 20:05:24 -08:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
1999-08-17 16:01:18 -07:00
|
|
|
*
|
1999-11-18 20:05:24 -08:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
1999-08-17 18:12:47 -07:00
|
|
|
*
|
1999-11-18 20:05:24 -08:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1999-08-17 18:12:47 -07:00
|
|
|
*/
|
2000-03-08 19:38:31 -08:00
|
|
|
|
1999-08-17 16:01:18 -07:00
|
|
|
#ifndef _SCROLLBAR_H
|
1999-11-18 20:05:24 -08:00
|
|
|
#define _SCROLLBAR_H
|
1999-08-17 16:01:18 -07:00
|
|
|
|
1999-11-18 20:05:24 -08:00
|
|
|
#include <X11/Xfuncproto.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "events.h"
|
Fri May 26 20:43:03 PDT 2000 Michael Jennings <mej@eterm.org>
Okay, there are a few changes here. First off, I made multi-byte font
support the default now, as long as you have ISO 10646 fonts. In
order to do this, I made the default encoding type "Latin1" so as not
to interfere with 8-bit ISO 8859-1 characters. This means that if you
relied on the default multi-byte encoding method to be SJIS, you'll
need to update your theme files.
I also set it up so that Eterm will ignore SIGHUP, at least until I do
something with it (like reloading the theme or something).
I fixed the proportional font size algorithm. If there is more than
a 3-pixel variance between the minimum and maximum sizes for glyphs in
a proportional font, Eterm will set the size to 2 standard deviations
above the average width. This is so that they won't look so spread
out and ugly, but it still doesn't look perfect. Not much I can do on
that front...terminals must have fixed-width columns.
And then there's the biggie. I put in the ability to configure the
now-infamous font effects. I left a black drop shadow in as the
default, but you can now customize it via the --font-fx option or in
the config file using "font effects <stuff>" in the attributes
context. You can even use "fx" instead of "effects" for short.
So what goes in the <stuff> part? Well, you have several options.
To use a single-color outline, say "outline <color>". Likewise, a
single-color drop shadow is "shadow [corner] <color>"; "bottom_right"
is the default corner if you don't specify one. For a 3-D embossed
look, "emboss <dark_color> <light_color>". The opposite, a carved-
out look, can be had with "carved <dark_color> <light_color>". (Of
course, with those last two, the 3-D look will only work if you
choose the colors wisely.)
Those are all the shortcuts. The long way is to specify a series of
corner/color pairs, like "tl blue" for top-left blue, or
"bottom_right green". You can abbreviate using "tl," "tr," "bl," or
"br," or you can spell out "top_left," "top_right," "bottom_left," or
"bottom_right." If you omit a corner name, the first one defaults to
top-left, the second to top-right, and so on as listed above.
SVN revision: 2714
2000-05-26 20:41:22 -07:00
|
|
|
#include "pixmap.h"
|
1999-08-17 16:01:18 -07:00
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
/************ Macros and Definitions ************/
|
1999-08-17 16:01:18 -07:00
|
|
|
/* Scrollbar types we support */
|
1999-11-18 20:05:24 -08:00
|
|
|
#define SCROLLBAR_MOTIF 1
|
|
|
|
#define SCROLLBAR_XTERM 2
|
|
|
|
#define SCROLLBAR_NEXT 3
|
|
|
|
|
|
|
|
/* Scrollbar states */
|
|
|
|
#define SCROLLBAR_STATE_VISIBLE (1UL << 0)
|
|
|
|
#define SCROLLBAR_STATE_MOVING (1UL << 1)
|
|
|
|
#define SCROLLBAR_STATE_UP_CLICKED (1UL << 2)
|
|
|
|
#define SCROLLBAR_STATE_DOWN_CLICKED (1UL << 3)
|
1999-11-19 15:21:09 -08:00
|
|
|
#define SCROLLBAR_STATE_ANCHOR_CLICKED (1UL << 4)
|
|
|
|
#define SCROLLBAR_STATE_MOTION_MASK (SCROLLBAR_STATE_UP_CLICKED | SCROLLBAR_STATE_DOWN_CLICKED | SCROLLBAR_STATE_ANCHOR_CLICKED | SCROLLBAR_STATE_MOVING)
|
1999-08-17 16:01:18 -07:00
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
/* Scrollbar state macros */
|
1999-11-18 20:05:24 -08:00
|
|
|
#define scrollbar_is_visible() (scrollbar.state & SCROLLBAR_STATE_VISIBLE)
|
|
|
|
#define scrollbar_is_moving() (scrollbar.state & SCROLLBAR_STATE_MOVING)
|
|
|
|
#define scrollbar_uparrow_is_pressed() (scrollbar.state & SCROLLBAR_STATE_UP_CLICKED)
|
|
|
|
#define scrollbar_downarrow_is_pressed() (scrollbar.state & SCROLLBAR_STATE_DOWN_CLICKED)
|
|
|
|
#define scrollbar_arrow_is_pressed() (scrollbar.state & (SCROLLBAR_STATE_UP_CLICKED | SCROLLBAR_STATE_DOWN_CLICKED))
|
1999-11-19 15:21:09 -08:00
|
|
|
#define scrollbar_anchor_is_pressed() (scrollbar.state & SCROLLBAR_STATE_ANCHOR_CLICKED)
|
|
|
|
#define scrollbar_cancel_motion() (scrollbar.state &= ~(SCROLLBAR_STATE_MOTION_MASK))
|
1999-11-18 20:05:24 -08:00
|
|
|
#define scrollbar_set_visible(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_VISIBLE) : (scrollbar.state &= ~(SCROLLBAR_STATE_VISIBLE)))
|
|
|
|
#define scrollbar_set_motion(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_MOVING) : (scrollbar.state &= ~(SCROLLBAR_STATE_MOVING)))
|
|
|
|
#define scrollbar_set_uparrow_pressed(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_UP_CLICKED) : (scrollbar.state &= ~(SCROLLBAR_STATE_UP_CLICKED)))
|
|
|
|
#define scrollbar_set_downarrow_pressed(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_DOWN_CLICKED) : (scrollbar.state &= ~(SCROLLBAR_STATE_DOWN_CLICKED)))
|
1999-11-19 15:21:09 -08:00
|
|
|
#define scrollbar_set_anchor_pressed(bit) ((bit) ? (scrollbar.state |= SCROLLBAR_STATE_ANCHOR_CLICKED) : (scrollbar.state &= ~(SCROLLBAR_STATE_ANCHOR_CLICKED)))
|
1999-08-17 18:12:47 -07:00
|
|
|
|
|
|
|
/* The various scrollbar elements */
|
1999-11-18 20:05:24 -08:00
|
|
|
#define scrollbar_win_is_trough(w) (scrollbar_is_visible() && (w) == scrollbar.win)
|
|
|
|
#define scrollbar_win_is_uparrow(w) ((w) == scrollbar.up_win)
|
|
|
|
#define scrollbar_win_is_downarrow(w) ((w) == scrollbar.dn_win)
|
|
|
|
#define scrollbar_win_is_anchor(w) ((w) == scrollbar.sa_win)
|
|
|
|
#define scrollbar_is_pixmapped() (images[image_sb].mode & MODE_MASK)
|
|
|
|
#define scrollbar_uparrow_is_pixmapped() (images[image_up].mode & MODE_MASK)
|
|
|
|
#define scrollbar_downarrow_is_pixmapped() (images[image_down].mode & MODE_MASK)
|
|
|
|
#define scrollbar_anchor_is_pixmapped() (images[image_sa].mode & MODE_MASK)
|
1999-08-17 18:12:47 -07:00
|
|
|
|
|
|
|
/* Scrollbar dimensions */
|
1999-11-18 20:05:24 -08:00
|
|
|
#define scrollbar_scrollarea_height() (scrollbar.scrollarea_end - scrollbar.scrollarea_start)
|
|
|
|
#define scrollbar_anchor_width() ((scrollbar.type == SCROLLBAR_XTERM) ? (scrollbar.win_width) : (scrollbar.width))
|
2000-06-09 22:16:26 -07:00
|
|
|
#define scrollbar_anchor_height() (MAX((scrollbar.anchor_bottom - scrollbar.anchor_top), 2))
|
1999-11-18 20:05:24 -08:00
|
|
|
#define scrollbar_trough_width() (scrollbar.win_width)
|
|
|
|
#define scrollbar_trough_height() (scrollbar.win_height)
|
|
|
|
#define scrollbar_arrow_width() (scrollbar.width)
|
|
|
|
#define scrollbar_arrow_height() (scrollbar.width)
|
1999-08-17 18:12:47 -07:00
|
|
|
|
|
|
|
/* Scrollbar positions */
|
2000-01-21 12:53:49 -08:00
|
|
|
#define scrollbar_is_above_anchor(w, y) (!scrollbar_win_is_anchor(w) && ((y) <= scrollbar.anchor_top))
|
|
|
|
#define scrollbar_is_below_anchor(w, y) (!scrollbar_win_is_anchor(w) && ((y) >= scrollbar.anchor_bottom))
|
1999-11-18 20:05:24 -08:00
|
|
|
#define scrollbar_position(y) ((y) - scrollbar.scrollarea_start)
|
|
|
|
#define scrollbar_up_loc() (scrollbar.up_arrow_loc)
|
|
|
|
#define scrollbar_dn_loc() (scrollbar.down_arrow_loc)
|
1999-08-17 18:12:47 -07:00
|
|
|
|
|
|
|
/* Scrollbar operations */
|
2000-02-15 19:37:34 -08:00
|
|
|
#if 0
|
|
|
|
#define map_scrollbar(show) do {PrivMode(show, PrivMode_scrollbar); if (scrollbar_mapping(show)) {scr_touch(); parent_resize();}} while (0)
|
|
|
|
#else
|
|
|
|
#define map_scrollbar(show) do {PrivMode(show, PrivMode_scrollbar); if (scrollbar_mapping(show)) {parent_resize();}} while (0)
|
|
|
|
#endif
|
1999-11-18 20:05:24 -08:00
|
|
|
#define scrollbar_map_arrows() do {XMapWindow(Xdisplay, scrollbar.up_win); XMapWindow(Xdisplay, scrollbar.dn_win);} while (0)
|
|
|
|
#define scrollbar_unmap_arrows() do {XUnmapWindow(Xdisplay, scrollbar.up_win); XUnmapWindow(Xdisplay, scrollbar.dn_win);} while (0)
|
1999-11-19 16:51:26 -08:00
|
|
|
#define scrollbar_get_shadow() ((scrollbar.type == SCROLLBAR_XTERM) ? (0) : (scrollbar.shadow))
|
1999-11-18 20:05:24 -08:00
|
|
|
#define scrollbar_set_shadow(s) (scrollbar.shadow = (s))
|
|
|
|
#define scrollbar_get_type() (scrollbar.type)
|
|
|
|
#define scrollbar_set_type(t) (scrollbar.type = (t))
|
|
|
|
#define scrollbar_get_width() (scrollbar.width)
|
|
|
|
#define scrollbar_set_width(w) (scrollbar.width = (w))
|
|
|
|
#define scrollbar_get_win() (scrollbar.win)
|
|
|
|
#define scrollbar_get_uparrow_win() (scrollbar.up_win)
|
|
|
|
#define scrollbar_get_downarrow_win() (scrollbar.dn_win)
|
|
|
|
#define scrollbar_get_anchor_win() (scrollbar.sa_win)
|
1999-08-17 18:12:47 -07:00
|
|
|
|
|
|
|
/************ Structures ************/
|
1999-08-17 16:01:18 -07:00
|
|
|
typedef struct {
|
1999-11-18 20:05:24 -08:00
|
|
|
Window win, up_win, dn_win, sa_win;
|
|
|
|
short scrollarea_start, scrollarea_end;
|
|
|
|
short anchor_top, anchor_bottom;
|
|
|
|
unsigned char state;
|
|
|
|
unsigned int type:2;
|
|
|
|
unsigned int init:1;
|
|
|
|
unsigned int shadow:5;
|
|
|
|
unsigned short width, height;
|
|
|
|
unsigned short win_width, win_height;
|
|
|
|
short up_arrow_loc, down_arrow_loc;
|
1999-08-17 18:12:47 -07:00
|
|
|
} scrollbar_t;
|
1999-08-17 16:01:18 -07:00
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
/************ Variables ************/
|
1999-11-18 20:05:24 -08:00
|
|
|
extern scrollbar_t scrollbar;
|
1999-08-17 18:12:47 -07:00
|
|
|
#ifdef SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
|
|
|
|
extern short scroll_arrow_delay;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/************ Function Prototypes ************/
|
1999-08-17 16:01:18 -07:00
|
|
|
_XFUNCPROTOBEGIN
|
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
extern void scrollbar_event_init_dispatcher(void);
|
Mon Sep 20 18:32:01 PDT 1999 Michael Jennings <mej@eterm.org>
Lots of changes here. First off, this should fix the background draw
bug with transparency that several people pointed out. While I was
at it, I also cleaned up a lot of other related stuff. Three-state
images should be a lot more robust now.
Then again, some stuff may be broken entirely from this, so let me
know. :-)
For one thing, the various image modes should work as expected now.
You can allow and disallow modes for the various widgets. The
fallback mode is "solid" now, rather than "image," so you can cause
a certain widget to refuse to use an image if you want to. If you
specify an image without specifying a "mode" line that allows the
"image" mode, your image will not appear. <-- READ THIS TWICE! I
had to go back and fix all the theme files because of this, so you
will need to remove your current theme directory and allow Eterm's
"make install" to put the new ones in place; otherwise, everything
will go back to being solid colors. =]
Anytime something changes this drastically, there are bound to be
problems. Let me know if you find any of them. :)
SVN revision: 348
1999-09-20 18:16:46 -07:00
|
|
|
extern unsigned char sb_handle_configure_notify(event_t *);
|
1999-08-17 18:12:47 -07:00
|
|
|
extern unsigned char sb_handle_enter_notify(event_t *);
|
|
|
|
extern unsigned char sb_handle_leave_notify(event_t *);
|
|
|
|
extern unsigned char sb_handle_focus_in(event_t *);
|
|
|
|
extern unsigned char sb_handle_focus_out(event_t *);
|
|
|
|
extern unsigned char sb_handle_expose(event_t *);
|
|
|
|
extern unsigned char sb_handle_button_press(event_t *);
|
|
|
|
extern unsigned char sb_handle_button_release(event_t *);
|
|
|
|
extern unsigned char sb_handle_motion_notify(event_t *);
|
|
|
|
extern unsigned char scrollbar_dispatch_event(event_t *);
|
1999-11-18 20:05:24 -08:00
|
|
|
extern void scrollbar_draw_uparrow(unsigned char image_state, unsigned char force_modes);
|
|
|
|
extern unsigned char scrollbar_move_uparrow(void);
|
|
|
|
extern void scrollbar_draw_downarrow(unsigned char image_state, unsigned char force_modes);
|
|
|
|
extern unsigned char scrollbar_move_downarrow(void);
|
|
|
|
extern void scrollbar_draw_anchor(unsigned char image_state, unsigned char force_modes);
|
|
|
|
extern unsigned char scrollbar_move_anchor(void);
|
|
|
|
extern void scrollbar_draw_trough(unsigned char image_state, unsigned char force_modes);
|
|
|
|
extern void scrollbar_init(int, int);
|
1999-08-17 18:12:47 -07:00
|
|
|
extern unsigned char scrollbar_mapping(unsigned char);
|
1999-08-17 16:01:18 -07:00
|
|
|
extern void scrollbar_reset(void);
|
1999-11-18 20:05:24 -08:00
|
|
|
extern void scrollbar_calc_size(int width, int height);
|
1999-10-11 11:37:55 -07:00
|
|
|
extern void scrollbar_resize(int, int);
|
1999-11-12 19:15:18 -08:00
|
|
|
extern void scrollbar_change_type(unsigned int);
|
|
|
|
extern void scrollbar_change_width(unsigned short);
|
1999-11-18 20:05:24 -08:00
|
|
|
extern void scrollbar_drawing_init(void);
|
|
|
|
extern unsigned char scrollbar_set_focus(short has_focus);
|
|
|
|
extern unsigned char scrollbar_anchor_update_position(short mouseoffset);
|
Thu Feb 10 15:10:01 PST 2000 Michael Jennings <mej@eterm.org>
This is the first public availability of the work thus far on Eterm
0.9.1. There's quite a bit of new stuff here.
* Added scrollbar thumb support.
* Completely redid the terminfo/termcap stuff. The terminfo file is
now compiled (by tic) and installed by default (unless you specify
--without-terminfo). The config files still say xterm, though,
because some programs (like SLang and GNU mc) use the silly algorithm
of "Is $TERM set to xterm?" to detect mouse reporting support in a
terminal. =P But if you don't ever use xterm, you can use Eterm's
termcap and just name it "xterm" instead. Thanks to Marius Gedminas
<mgedmin@takas.lt> for his patch that started this whole revamp.
* Added the kEsetroot script for KDE users from Dax Games
<dgames@isoc.net>.
* You can now configure the Home and End emulation via --with-home=
and --with-end= options to configure. The --with-terminfo option is
also new, and --enable-xim is now the default.
* Added a new image state, disabled, for when Eterm loses focus. This
is supported by all widgets (well, all those that could possibly be
on screen when Eterm lost focus), even the background image. So you
could actually have all your images darken on focus out and restore
to normal on focus in.
* Widget colors formerly dealt with as colors (menu text color,
scrollbar color, etc.) are now handled by the imageclasses. Each
image state can have a foreground and background color defined. The
current exception is the background image; I hope to add that later.
The foreground is the text color and the background is the object
color (for solid color mode). So menu text color is set by the menu
imageclass. And again, for unfocused colors, use the disabled state
of the imageclass.
* Proportionally-spaced fonts are now handled much better. They are
still forced into evenly-spaced columns (it's a terminal for crying
out loud!) but at least you don't end up with Eterm's wider than your
screen. :-)
* Home on refresh is gone, as is home on echo. It's now much simpler.
There are two options: home on output, and home on input, the former
being a combination of echo and refresh. Also, keypresses that don't
necessarily have corresonding output can trigger a home on input,
like Ctrl-End or whatever...ones that don't have special meaning.
Credit to Darren Stuart Embry <dse@louisville.edu> for pointing out
this issue and the one with "m-" in font names.
* I finally got around to re-merging the new parser stuff from my
work on the Not Game. Closed up some old potential behavior quirks
with theme parsing.
* Added a new escape sequence to fork-and-exec a program. Also added
a scrollback search capability to highlight all occurances of a string
in your scrollback buffer. Use the new "Etsearch" utility to access
it. "Etsearch string" to search for a string, then "Etsearch" by
itself to reset the highlighting.
* And of course, the biggie. Eterm now supports a completely-
customizeable buttonbar. Not a menubar, a buttonbar. It can have an
arbitrary number of buttons, and each button can perform an action,
just like a menuitem. So a button could bring up a menu (like a
menubar) or launch a program (like a launchbar) or perform an
operation (like a toolbar). Each button can have an icon, text, or
both. And you can have buttons left- or right-justified in the
buttonbar. You will eventually be able to have an arbitrary number
of buttonbars, but I'm still working on that.
As with any change this big, things could very easily be broken. So
beware. :-) I have tested this myself, and everything seems to work,
but I can't test every possibility. Let me know if you find anything
that's broken, and enjoy!
SVN revision: 2048
2000-02-10 16:25:07 -08:00
|
|
|
extern void scrollbar_draw(unsigned char image_state, unsigned char force_modes);
|
1999-11-18 20:05:24 -08:00
|
|
|
extern void scrollbar_reposition_and_draw(unsigned char force_modes);
|
1999-11-19 16:51:26 -08:00
|
|
|
extern void scrollbar_reposition_and_always_draw(void);
|
1999-08-17 18:12:47 -07:00
|
|
|
extern unsigned char scrollbar_show(short);
|
1999-08-17 16:01:18 -07:00
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
_XFUNCPROTOEND
|
1999-08-17 16:01:18 -07:00
|
|
|
|
|
|
|
#endif /* _SCROLLBAR_H */
|