mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-23 00:38:01 +00:00
Simplify the mechanics of generating the 'inactive' pixmap.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8729 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a61e00a55d
commit
c688967bc3
@ -1,3 +1,7 @@
|
|||||||
|
2004-05-03 Angus Leeming <leeming@lyx.org>
|
||||||
|
|
||||||
|
* XFormsToolbar.[Ch] (generateInactivePixmaps): simpler mechanics.
|
||||||
|
|
||||||
2004-05-02 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
2004-05-02 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||||
|
|
||||||
* FormGraphics.C: #include <cmath> (STLport compile fix for floor())
|
* FormGraphics.C: #include <cmath> (STLport compile fix for floor())
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using lyx::frontend::Box;
|
using lyx::frontend::Box;
|
||||||
using lyx::frontend::BoxList;
|
using lyx::frontend::BoxList;
|
||||||
|
|
||||||
@ -43,6 +46,7 @@ using lyx::support::compare_ascii_no_case;
|
|||||||
using std::distance;
|
using std::distance;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
// some constants
|
// some constants
|
||||||
@ -79,9 +83,8 @@ XFormsToolbar::toolbarItem::toolbarItem()
|
|||||||
: icon(0),
|
: icon(0),
|
||||||
unused_pixmap(0),
|
unused_pixmap(0),
|
||||||
active_pixmap(0),
|
active_pixmap(0),
|
||||||
active_mask(0),
|
|
||||||
inactive_pixmap(0),
|
inactive_pixmap(0),
|
||||||
inactive_mask(0)
|
mask(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
@ -99,9 +102,8 @@ void XFormsToolbar::toolbarItem::kill_icon()
|
|||||||
|
|
||||||
unused_pixmap = 0;
|
unused_pixmap = 0;
|
||||||
active_pixmap = 0;
|
active_pixmap = 0;
|
||||||
active_mask = 0;
|
|
||||||
inactive_pixmap = 0;
|
inactive_pixmap = 0;
|
||||||
inactive_mask = 0;
|
mask = 0;
|
||||||
icon = 0;
|
icon = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,19 +130,21 @@ void XFormsToolbar::toolbarItem::generateInactivePixmaps()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Store the existing (active) pixmap.
|
// Store the existing (active) pixmap.
|
||||||
fl_get_pixmap_pixmap(icon, &active_pixmap, &active_mask);
|
fl_get_pixmap_pixmap(icon, &active_pixmap, &mask);
|
||||||
|
|
||||||
if (active_pixmap == 0 || active_mask == 0)
|
if (active_pixmap == 0 || mask == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create an XpmImage of this (active) pixmap. It's this that
|
// Ascertain the width and height of the pixmap.
|
||||||
// we're going to manipulate.
|
Display * display = fl_get_display();
|
||||||
XpmImage xpm_image;
|
unsigned int width;
|
||||||
XpmCreateXpmImageFromPixmap(fl_get_display(),
|
unsigned int height;
|
||||||
active_pixmap,
|
unsigned int uidummy;
|
||||||
active_mask,
|
int idummy;
|
||||||
&xpm_image,
|
Window win;
|
||||||
0);
|
|
||||||
|
XGetGeometry(display, active_pixmap, &win, &idummy, &idummy,
|
||||||
|
&width, &height, &uidummy, &uidummy);
|
||||||
|
|
||||||
// Produce a darker shade of the button background as the
|
// Produce a darker shade of the button background as the
|
||||||
// inactive color. Note the 'hsv.v - 0.2'.
|
// inactive color. Note the 'hsv.v - 0.2'.
|
||||||
@ -150,32 +154,39 @@ void XFormsToolbar::toolbarItem::generateInactivePixmaps()
|
|||||||
hsv.v = std::max(0.0, hsv.v - 0.2);
|
hsv.v = std::max(0.0, hsv.v - 0.2);
|
||||||
string const inactive_color = X11hexname(RGBColor(hsv));
|
string const inactive_color = X11hexname(RGBColor(hsv));
|
||||||
|
|
||||||
// Set all color table entries in xpm_image that aren't
|
// Generate an XPM dataset for a uniformly-colored pixmap with
|
||||||
// "none" to inactive_color
|
// the same dimensions as active_pixmap.
|
||||||
for (uint i = 0; i != xpm_image.ncolors; ++i) {
|
|
||||||
XpmColor & ct = xpm_image.colorTable[i];
|
|
||||||
if (ct.c_color &&
|
|
||||||
compare_ascii_no_case("none", ct.c_color) == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Note that this is a c-struct, so use c memory funcs.
|
// The data set has the form:
|
||||||
if (ct.c_color)
|
// "<width> <height> <ncolors> <chars per pixel>",
|
||||||
free(ct.c_color);
|
// "o c <inactive_color>",
|
||||||
ct.c_color = (char *)malloc(inactive_color.size() + 1);
|
// "oooooooooooooooo", // <width> 'o' chars.
|
||||||
strcpy(ct.c_color, inactive_color.c_str());
|
// repeated <height> times.
|
||||||
}
|
|
||||||
|
|
||||||
// Generate pixmaps of this modified xpm_image.
|
std::ostringstream line1_ss;
|
||||||
Screen * screen = ScreenOfDisplay(fl_get_display(), fl_screen);
|
line1_ss << width << ' ' << height << " 1 1";
|
||||||
|
string const line1 = line1_ss.str();
|
||||||
|
string const line2 = "o c " + inactive_color;
|
||||||
|
string const data(width, 'o');
|
||||||
|
vector<char *> inactive_data(height + 2,
|
||||||
|
const_cast<char *>(data.c_str()));
|
||||||
|
inactive_data[0] = const_cast<char *>(line1.c_str());
|
||||||
|
inactive_data[1] = const_cast<char *>(line2.c_str());
|
||||||
|
|
||||||
XpmCreatePixmapFromXpmImage(fl_get_display(),
|
char ** raw_inactive_data =
|
||||||
|
const_cast<char **>(&*inactive_data.begin());
|
||||||
|
|
||||||
|
// Generate a pixmap of this data set.
|
||||||
|
// Together with 'mask' above, this is sufficient to display
|
||||||
|
// an inactive version of our active_pixmap.
|
||||||
|
Screen * screen = ScreenOfDisplay(display, fl_screen);
|
||||||
|
|
||||||
|
XpmCreatePixmapFromData(fl_get_display(),
|
||||||
XRootWindowOfScreen(screen),
|
XRootWindowOfScreen(screen),
|
||||||
&xpm_image,
|
raw_inactive_data,
|
||||||
&inactive_pixmap,
|
&inactive_pixmap,
|
||||||
&inactive_mask,
|
0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
XpmFreeXpmImage(&xpm_image);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -389,13 +400,13 @@ void XFormsToolbar::update()
|
|||||||
fl_activate_object(p->icon);
|
fl_activate_object(p->icon);
|
||||||
fl_set_pixmap_pixmap(p->icon,
|
fl_set_pixmap_pixmap(p->icon,
|
||||||
p->active_pixmap,
|
p->active_pixmap,
|
||||||
p->active_mask);
|
p->mask);
|
||||||
p->unused_pixmap = p->inactive_pixmap;
|
p->unused_pixmap = p->inactive_pixmap;
|
||||||
} else {
|
} else {
|
||||||
fl_deactivate_object(p->icon);
|
fl_deactivate_object(p->icon);
|
||||||
fl_set_pixmap_pixmap(p->icon,
|
fl_set_pixmap_pixmap(p->icon,
|
||||||
p->inactive_pixmap,
|
p->inactive_pixmap,
|
||||||
p->inactive_mask);
|
p->mask);
|
||||||
p->unused_pixmap = p->active_pixmap;
|
p->unused_pixmap = p->active_pixmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,8 @@ public:
|
|||||||
///
|
///
|
||||||
Pixmap unused_pixmap;
|
Pixmap unused_pixmap;
|
||||||
Pixmap active_pixmap;
|
Pixmap active_pixmap;
|
||||||
Pixmap active_mask;
|
|
||||||
Pixmap inactive_pixmap;
|
Pixmap inactive_pixmap;
|
||||||
Pixmap inactive_mask;
|
Pixmap mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user