diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-03-14 20:51:55 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-03-14 20:51:55 +0000 |
commit | 8d3fdc3c5b87f6d1444830d82f28d18a2201afea (patch) | |
tree | f4fc9893bbb92d5d7b2fc3c5321db4bb6ffa0635 | |
parent | e72e0caf9949be20b3d5416648a902ab3fe9c588 (diff) |
fix problems with pixmaps/xpm files
git-svn-id: svn://localhost/trunk/ardour2@392 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | gtk2_ardour/ardour_ui.cc | 17 | ||||
-rw-r--r-- | gtk2_ardour/pixmaps/v_meter_strip.xpm | 483 | ||||
-rw-r--r-- | gtk2_ardour/utils.cc | 3 | ||||
-rw-r--r-- | gtk2_ardour/utils.h | 1 | ||||
-rw-r--r-- | libs/gtkmm2ext/fastmeter.cc | 60 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/fastmeter.h | 7 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/pix.h | 8 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/pixscroller.h | 5 | ||||
-rw-r--r-- | libs/gtkmm2ext/pix.cc | 20 | ||||
-rw-r--r-- | libs/gtkmm2ext/pixscroller.cc | 18 | ||||
-rw-r--r-- | libs/gtkmm2ext/slider_controller.cc | 2 | ||||
-rw-r--r-- | libs/gtkmm2ext/utils.cc | 12 |
12 files changed, 579 insertions, 57 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 6c21cdc1df..5e4eac768b 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -230,8 +230,21 @@ ARDOUR_UI::set_engine (AudioEngine& e) keyboard = new Keyboard; install_keybindings (); - FastMeter::set_vertical_xpm (ARDOUR::find_data_file("v_meter_strip.xpm", "pixmaps")); - FastMeter::set_horizontal_xpm (ARDOUR::find_data_file("h_meter_strip.xpm", "pixmaps")); + string meter_path; + + meter_path = ARDOUR::find_data_file("v_meter_strip.xpm", "pixmaps"); + if (meter_path.empty()) { + error << _("no vertical meter strip image found") << endmsg; + exit (1); + } + FastMeter::set_vertical_xpm (meter_path); + + meter_path = ARDOUR::find_data_file("h_meter_strip.xpm", "pixmaps"); + if (meter_path.empty()) { + error << _("no horizontal meter strip image found") << endmsg; + exit (1); + } + FastMeter::set_horizontal_xpm (meter_path); if (setup_windows ()) { throw failed_constructor (); diff --git a/gtk2_ardour/pixmaps/v_meter_strip.xpm b/gtk2_ardour/pixmaps/v_meter_strip.xpm new file mode 100644 index 0000000000..d673c1da0b --- /dev/null +++ b/gtk2_ardour/pixmaps/v_meter_strip.xpm @@ -0,0 +1,483 @@ +/* XPM */ +static const gchar * v_meter_strip_xpm[] = { +"5 250 230 2", +" c None", +". c #FE0000", +"+ c #FF0000", +"@ c #FE0100", +"# c #FD0200", +"$ c #FD0300", +"% c #FD0400", +"& c #FC0500", +"* c #FC0600", +"= c #FC0700", +"- c #FB0800", +"; c #FA0900", +"> c #FA0A00", +", c #FA0B00", +"' c #F90C00", +") c #F90D00", +"! c #F80E00", +"~ c #F80F00", +"{ c #F71000", +"] c #F71100", +"^ c #F61200", +"/ c #F61300", +"( c #F61400", +"_ c #F51600", +": c #F41700", +"< c #F41800", +"[ c #F31A00", +"} c #F31B00", +"| c #F21C00", +"1 c #F21E00", +"2 c #F11F00", +"3 c #F54A00", +"4 c #FFA900", +"5 c #FFAB00", +"6 c #FFAC01", +"7 c #FFAD02", +"8 c #FFAE02", +"9 c #FFAF03", +"0 c #FFB004", +"a c #FFB104", +"b c #FFB205", +"c c #FFB406", +"d c #FFB506", +"e c #FFB607", +"f c #FFB708", +"g c #FFB808", +"h c #FFB909", +"i c #FFBA0A", +"j c #FFBB0A", +"k c #FFBC0A", +"l c #FFBD0B", +"m c #FFBE0C", +"n c #FFBF0C", +"o c #FFC00D", +"p c #FFC10E", +"q c #FFC20F", +"r c #FFC30F", +"s c #FFC410", +"t c #FFC511", +"u c #FFC611", +"v c #FFC711", +"w c #FFC812", +"x c #FFC913", +"y c #FFCA13", +"z c #FFCB14", +"A c #FFCC15", +"B c #FFCD15", +"C c #FFCF16", +"D c #FFD017", +"E c #FFD117", +"F c #FFD218", +"G c #FFD319", +"H c #FFD419", +"I c #FFD51A", +"J c #FFD61B", +"K c #FFD71B", +"L c #FFD81C", +"M c #FFD91C", +"N c #FFDA1D", +"O c #FFDB1E", +"P c #FFDC1E", +"Q c #FFDD1F", +"R c #FFDE20", +"S c #FFDF20", +"T c #FFE021", +"U c #FFE222", +"V c #FFE322", +"W c #FFE423", +"X c #FFE524", +"Y c #FFE624", +"Z c #FFE725", +"` c #FFE826", +" . c #FFE926", +".. c #FFEA26", +"+. c #FFEB27", +"@. c #FFEC28", +"#. c #FFED28", +"$. c #FFEE29", +"%. c #FFEF2A", +"&. c #FFF02A", +"*. c #FFF12B", +"=. c #FFF22C", +"-. c #FFF32D", +";. c #FFF42D", +">. c #FDF42C", +",. c #FBF42C", +"'. c #FAF42C", +"). c #F8F42B", +"!. c #F6F42B", +"~. c #F4F42B", +"{. c #F3F42A", +"]. c #F1F42A", +"^. c #F0F429", +"/. c #EEF429", +"(. c #ECF429", +"_. c #EAF528", +":. c #E9F528", +"<. c #E7F528", +"[. c #E5F527", +"}. c #E3F527", +"|. c #E2F526", +"1. c #E0F526", +"2. c #DFF526", +"3. c #DDF525", +"4. c #DBF525", +"5. c #D9F525", +"6. c #D8F524", +"7. c #D6F624", +"8. c #D5F624", +"9. c #D3F624", +"0. c #D1F623", +"a. c #CFF623", +"b. c #CEF622", +"c. c #CCF622", +"d. c #CBF622", +"e. c #C9F621", +"f. c #C7F621", +"g. c #C5F621", +"h. c #C4F720", +"i. c #C2F720", +"j. c #C0F71F", +"k. c #BEF71F", +"l. c #BDF71F", +"m. c #BBF71E", +"n. c #BAF71E", +"o. c #B8F71E", +"p. c #B6F71D", +"q. c #B5F71D", +"r. c #B3F71D", +"s. c #B2F71C", +"t. c #B0F81C", +"u. c #AEF81B", +"v. c #ACF81B", +"w. c #ABF81B", +"x. c #A9F81A", +"y. c #A8F81A", +"z. c #A6F81A", +"A. c #A4F81A", +"B. c #A2F819", +"C. c #A1F819", +"D. c #9FF819", +"E. c #9EF818", +"F. c #9BF918", +"G. c #9AF917", +"H. c #98F917", +"I. c #97F917", +"J. c #95F916", +"K. c #93F916", +"L. c #91F916", +"M. c #90F915", +"N. c #8EF915", +"O. c #8DF914", +"P. c #8BF914", +"Q. c #89FA14", +"R. c #87FA13", +"S. c #86FA13", +"T. c #84FA13", +"U. c #83FA12", +"V. c #81FA12", +"W. c #7FFA12", +"X. c #7DFA12", +"Y. c #7CFA11", +"Z. c #7AFA11", +"`. c #78FA10", +" + c #76FA10", +".+ c #75FB10", +"++ c #73FB0F", +"@+ c #72FB0F", +"#+ c #70FB0F", +"$+ c #6EFB0E", +"%+ c #6DFB0E", +"&+ c #6BFB0E", +"*+ c #6AFB0D", +"=+ c #68FB0D", +"-+ c #66FB0C", +";+ c #64FB0C", +">+ c #63FB0C", +",+ c #61FC0B", +"'+ c #60FC0B", +")+ c #5EFC0B", +"!+ c #5CFC0A", +"~+ c #5AFC0A", +"{+ c #59FC09", +"]+ c #57FC09", +"^+ c #56FC09", +"/+ c #53FC09", +"(+ c #52FC08", +"_+ c #50FC08", +":+ c #4FFD08", +"<+ c #4DFD07", +"[+ c #4BFD07", +"}+ c #49FD07", +"|+ c #48FD06", +"1+ c #46FD06", +"2+ c #45FD05", +"3+ c #43FD05", +"4+ c #41FD05", +"5+ c #3FFD04", +"6+ c #3EFD04", +"7+ c #3CFD04", +"8+ c #3BFE03", +"9+ c #39FE03", +"0+ c #37FE02", +"a+ c #35FE02", +"b+ c #34FE02", +"c+ c #32FE01", +"d+ c #30FE01", +"e+ c #2EFE01", +"f+ c #2DFE00", +"g+ c #2BFE00", +". . + + + ", +". . + + + ", +"@ @ @ @ @ ", +"# # # # # ", +"$ $ $ $ $ ", +"% % % % % ", +"& & & & & ", +"* * * * * ", +"= = = = = ", +"- - - - - ", +"; ; ; ; ; ", +"> > > > > ", +", , , , , ", +"' ' ' ' ' ", +") ) ) ) ) ", +"! ! ! ! ! ", +"~ ~ ~ ~ ~ ", +"{ { { { { ", +"] ] ] ] ] ", +"^ ^ ^ ^ ^ ", +"/ / / / / ", +"( ( ( ( ( ", +"_ _ _ _ _ ", +": : : : : ", +": : : : : ", +"< < < < < ", +"[ [ [ [ [ ", +"} } } } } ", +"} } } } } ", +"| | | | | ", +"1 1 1 1 1 ", +"2 2 2 2 2 ", +"3 3 3 3 3 ", +"4 4 4 4 4 ", +"5 5 5 5 5 ", +"6 6 6 6 6 ", +"6 6 6 6 6 ", +"7 7 7 7 7 ", +"8 8 8 8 8 ", +"9 9 9 9 9 ", +"9 9 9 9 9 ", +"0 0 0 0 0 ", +"a a a a a ", +"a a a a a ", +"b b b b b ", +"c c c c c ", +"d d d d d ", +"d d d d d ", +"e e e e e ", +"f f f f f ", +"g g g g g ", +"g g g g g ", +"h h h h h ", +"i i i i i ", +"j j j j j ", +"k k k k k ", +"l l l l l ", +"m m m m m ", +"n n n n n ", +"n n n n n ", +"o o o o o ", +"p p p p p ", +"q q q q q ", +"q q q q q ", +"r r r r r ", +"s s s s s ", +"t t t t t ", +"u u u u u ", +"v v v v v ", +"w w w w w ", +"x x x x x ", +"x x x x x ", +"y y y y y ", +"z z z z z ", +"A A A A A ", +"A A A A A ", +"B B B B B ", +"C C C C C ", +"D D D D D ", +"D D D D D ", +"E E E E E ", +"F F F F F ", +"G G G G G ", +"G G G G G ", +"H H H H H ", +"I I I I I ", +"I I I I I ", +"J J J J J ", +"K K K K K ", +"L L L L L ", +"M M M M M ", +"N N N N N ", +"O O O O O ", +"P P P P P ", +"P P P P P ", +"Q Q Q Q Q ", +"R R R R R ", +"S S S S S ", +"S S S S S ", +"T T T T T ", +"U U U U U ", +"V V V V V ", +"V V V V V ", +"W W W W W ", +"X X X X X ", +"Y Y Y Y Y ", +"Y Y Y Y Y ", +"Z Z Z Z Z ", +"` ` ` ` ` ", +" . . . . .", +"..........", +"+.+.+.+.+.", +"@.@.@.@.@.", +"#.#.#.#.#.", +"#.#.#.#.#.", +"$.$.$.$.$.", +"%.%.%.%.%.", +"&.&.&.&.&.", +"&.&.&.&.&.", +"*.*.*.*.*.", +"=.=.=.=.=.", +"-.-.-.-.-.", +";.;.;.;.;.", +";.;.;.;.;.", +">.>.>.>.>.", +",.,.,.,.,.", +"'.'.'.'.'.", +").).).).).", +"!.!.!.!.!.", +"~.~.~.~.~.", +"{.{.{.{.{.", +"].].].].].", +"^.^.^.^.^.", +"/././././.", +"(.(.(.(.(.", +"_._._._._.", +":.:.:.:.:.", +"<.<.<.<.<.", +"[.[.[.[.[.", +"}.}.}.}.}.", +"|.|.|.|.|.", +"1.1.1.1.1.", +"2.2.2.2.2.", +"3.3.3.3.3.", +"4.4.4.4.4.", +"5.5.5.5.5.", +"6.6.6.6.6.", +"7.7.7.7.7.", +"8.8.8.8.8.", +"9.9.9.9.9.", +"0.0.0.0.0.", +"a.a.a.a.a.", +"b.b.b.b.b.", +"c.c.c.c.c.", +"d.d.d.d.d.", +"e.e.e.e.e.", +"f.f.f.f.f.", +"g.g.g.g.g.", +"h.h.h.h.h.", +"i.i.i.i.i.", +"j.j.j.j.j.", +"k.k.k.k.k.", +"l.l.l.l.l.", +"m.m.m.m.m.", +"n.n.n.n.n.", +"o.o.o.o.o.", +"p.p.p.p.p.", +"q.q.q.q.q.", +"r.r.r.r.r.", +"s.s.s.s.s.", +"t.t.t.t.t.", +"u.u.u.u.u.", +"v.v.v.v.v.", +"w.w.w.w.w.", +"x.x.x.x.x.", +"y.y.y.y.y.", +"z.z.z.z.z.", +"A.A.A.A.A.", +"B.B.B.B.B.", +"C.C.C.C.C.", +"D.D.D.D.D.", +"E.E.E.E.E.", +"F.F.F.F.F.", +"G.G.G.G.G.", +"H.H.H.H.H.", +"I.I.I.I.I.", +"J.J.J.J.J.", +"K.K.K.K.K.", +"L.L.L.L.L.", +"M.M.M.M.M.", +"N.N.N.N.N.", +"O.O.O.O.O.", +"P.P.P.P.P.", +"Q.Q.Q.Q.Q.", +"R.R.R.R.R.", +"S.S.S.S.S.", +"T.T.T.T.T.", +"U.U.U.U.U.", +"V.V.V.V.V.", +"W.W.W.W.W.", +"X.X.X.X.X.", +"Y.Y.Y.Y.Y.", +"Z.Z.Z.Z.Z.", +"`.`.`.`.`.", +" + + + + +", +".+.+.+.+.+", +"++++++++++", +"@+@+@+@+@+", +"#+#+#+#+#+", +"$+$+$+$+$+", +"%+%+%+%+%+", +"&+&+&+&+&+", +"*+*+*+*+*+", +"=+=+=+=+=+", +"-+-+-+-+-+", +";+;+;+;+;+", +">+>+>+>+>+", +",+,+,+,+,+", +"'+'+'+'+'+", +")+)+)+)+)+", +"!+!+!+!+!+", +"~+~+~+~+~+", +"{+{+{+{+{+", +"]+]+]+]+]+", +"^+^+^+^+^+", +"/+/+/+/+/+", +"(+(+(+(+(+", +"_+_+_+_+_+", +":+:+:+:+:+", +"<+<+<+<+<+", +"[+[+[+[+[+", +"}+}+}+}+}+", +"|+|+|+|+|+", +"1+1+1+1+1+", +"2+2+2+2+2+", +"3+3+3+3+3+", +"4+4+4+4+4+", +"5+5+5+5+5+", +"6+6+6+6+6+", +"7+7+7+7+7+", +"8+8+8+8+8+", +"9+9+9+9+9+", +"0+0+0+0+0+", +"a+a+a+a+a+", +"b+b+b+b+b+", +"c+c+c+c+c+", +"d+d+d+d+d+", +"e+e+e+e+e+", +"f+f+f+f+f+", +"g+g+g+g+g+"}; diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc index 91f69a444e..c0f1a9eaa8 100644 --- a/gtk2_ardour/utils.cc +++ b/gtk2_ardour/utils.cc @@ -20,6 +20,8 @@ #include <cstdlib> #include <cctype> +#include <fstream> +#include <sys/stat.h> #include <libart_lgpl/art_misc.h> #include <gtkmm/window.h> #include <gtkmm/combo.h> @@ -589,3 +591,4 @@ get_xpm (std::string name) return (xpm_map[name]); } + diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h index bbfa5f4e52..983753a0dd 100644 --- a/gtk2_ardour/utils.h +++ b/gtk2_ardour/utils.h @@ -79,5 +79,6 @@ bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev); Glib::RefPtr<Gdk::Pixbuf> get_xpm(std::string); static std::map<std::string, Glib::RefPtr<Gdk::Pixbuf> > xpm_map; +const char* const *get_xpm_data (std::string path); #endif /* __ardour_gtk_utils_h__ */ diff --git a/libs/gtkmm2ext/fastmeter.cc b/libs/gtkmm2ext/fastmeter.cc index 82a04b5521..bf160441c2 100644 --- a/libs/gtkmm2ext/fastmeter.cc +++ b/libs/gtkmm2ext/fastmeter.cc @@ -32,6 +32,8 @@ using namespace Glib; using namespace Gtkmm2ext; using namespace std; +string FastMeter::v_image_path; +string FastMeter::h_image_path; RefPtr<Pixmap> FastMeter::v_pixmap; RefPtr<Bitmap> FastMeter::v_mask; gint FastMeter::v_pixheight = 0; @@ -56,16 +58,8 @@ FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o) pixrect.x = 0; pixrect.y = 0; - if (orientation == Vertical) { - pixrect.width = min (v_pixwidth, (gint) dimen); - pixrect.height = v_pixheight; - } else { - pixrect.width = h_pixwidth; - pixrect.height = min (h_pixheight, (gint) dimen); - } - - request_width = pixrect.width; - request_height= pixrect.height; + request_width = dimen; + request_height = dimen; } FastMeter::~FastMeter () @@ -73,31 +67,57 @@ FastMeter::~FastMeter () } void -FastMeter::set_vertical_xpm (const std::string& xpm_file) +FastMeter::on_realize () { - if (v_pixmap == 0) { - gint w, h; + DrawingArea::on_realize (); - v_pixmap = Pixmap::create_from_xpm(get_bogus_drawable(), Colormap::get_system(), v_mask, Gdk::Color(), xpm_file); + Glib::RefPtr<Gdk::Drawable> drawable = Glib::RefPtr<Gdk::Window>::cast_dynamic (get_window()); + Gdk::Color transparent; + + if (!v_image_path.empty() && v_pixmap == 0) { + gint w, h; + + v_pixmap = Pixmap::create_from_xpm (drawable, Colormap::get_system(), v_mask, transparent, v_image_path); v_pixmap->get_size(w, h); v_pixheight = h; v_pixwidth = w; } -} -void -FastMeter::set_horizontal_xpm (const std::string& xpm_file) -{ - if (h_pixmap == 0) { + if (!h_image_path.empty() && h_pixmap == 0) { gint w, h; - h_pixmap = Pixmap::create_from_xpm(get_bogus_drawable(), Colormap::get_system(), h_mask, Gdk::Color(), xpm_file); + h_pixmap = Pixmap::create_from_xpm (drawable, Colormap::get_system(), h_mask, transparent, h_image_path); h_pixmap->get_size(w, h); h_pixheight = h; h_pixwidth = w; } + + if (orientation == Vertical) { + pixrect.width = min (v_pixwidth, request_width); + pixrect.height = v_pixheight; + } else { + pixrect.width = h_pixwidth; + pixrect.height = min (h_pixheight, request_height); + } + + request_width = pixrect.width; + request_height= pixrect.height; + + set_size_request (request_width, request_height); +} + +void +FastMeter::set_vertical_xpm (std::string path) +{ + v_image_path = path; +} + +void +FastMeter::set_horizontal_xpm (std::string path) +{ + h_image_path = path; } void diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h index 5defcfae8f..87cfd0b836 100644 --- a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h +++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h @@ -46,14 +46,17 @@ class FastMeter : public Gtk::DrawingArea { long hold_count() { return hold_cnt; } void set_hold_count (long); - static void set_horizontal_xpm (const std::string&); - static void set_vertical_xpm (const std::string&); + static void set_horizontal_xpm (std::string); + static void set_vertical_xpm (std::string); protected: bool on_expose_event (GdkEventExpose*); void on_size_request (GtkRequisition*); + void on_realize (); private: + static std::string h_image_path; + static std::string v_image_path; static Glib::RefPtr<Gdk::Pixmap> h_pixmap; static Glib::RefPtr<Gdk::Bitmap> h_mask; static gint h_pixheight; diff --git a/libs/gtkmm2ext/gtkmm2ext/pix.h b/libs/gtkmm2ext/gtkmm2ext/pix.h index b06f6046ea..65526151d4 100644 --- a/libs/gtkmm2ext/gtkmm2ext/pix.h +++ b/libs/gtkmm2ext/gtkmm2ext/pix.h @@ -17,7 +17,7 @@ class Pix int refcnt; bool generated; std::vector<std::string *> *files; - std::vector<const char **> data; + std::vector<const char* const*> data; bool from_files; int pixmap_count; int last_pixmap; @@ -29,21 +29,21 @@ class Pix Pix (const std::string &dirpath, const std::string ®exp, bool homogenous = true); - Pix (std::vector<const char **> xpm_data, bool homogenous = true); + Pix (std::vector<const char* const*> xpm_data, bool homogenous = true); virtual ~Pix(); friend Pix *get_pix (const std::string &dirpath, const std::string ®exp, bool homogenous); friend Pix *get_pix (std::string name, - std::vector<const char **> xpm_data, + std::vector<const char* const*> xpm_data, bool homogenous); friend void finish_pix (Pix *); public: Pix (bool homogenous = true); - void generate (); + void generate (Glib::RefPtr<Gdk::Drawable>&); int n_pixmaps() { return pixmap_count; } int max_pixmap() { return last_pixmap; } bool homogenous () { return _homegenous; } diff --git a/libs/gtkmm2ext/gtkmm2ext/pixscroller.h b/libs/gtkmm2ext/gtkmm2ext/pixscroller.h index 4501a0c88c..55b84dfacc 100644 --- a/libs/gtkmm2ext/gtkmm2ext/pixscroller.h +++ b/libs/gtkmm2ext/gtkmm2ext/pixscroller.h @@ -20,11 +20,14 @@ class PixScroller : public Gtk::DrawingArea bool on_button_press_event (GdkEventButton*); bool on_button_release_event (GdkEventButton*); void on_size_request (GtkRequisition*); - + void on_realize (); + protected: Gtk::Adjustment& adj; private: + Pix& pix; + Glib::RefPtr<Gdk::Pixmap> rail; Glib::RefPtr<Gdk::Pixmap> slider; Glib::RefPtr<Gdk::Bitmap> rail_mask; diff --git a/libs/gtkmm2ext/pix.cc b/libs/gtkmm2ext/pix.cc index ba10715861..1d3696ffdc 100644 --- a/libs/gtkmm2ext/pix.cc +++ b/libs/gtkmm2ext/pix.cc @@ -57,7 +57,7 @@ Pix::Pix (bool homog) _homegenous = homog; } -Pix::Pix (vector<const char **> xpm_data, bool homog) +Pix::Pix (vector<const char* const*> xpm_data, bool homog) { if (xpm_data.size() == 0) { throw failed_constructor(); @@ -132,24 +132,22 @@ Pix::~Pix () } void -Pix::generate () - +Pix::generate (Glib::RefPtr<Gdk::Drawable>& drawable) { if (generated) { return; } for (int i = 0; i < pixmap_count; i++) { + + Gdk::Color transparent; + if (from_files) { - pixmaps[i] = Gdk::Pixmap::create_from_xpm (get_bogus_drawable(), Gdk::Colormap::get_system(), - bitmaps[i], Gdk::Color(), *(*files)[i]); + pixmaps[i] = Gdk::Pixmap::create_from_xpm(drawable, bitmaps[i], transparent, *(*files)[i]); } else { - gchar **xpm; - xpm = const_cast<gchar **> (data[i]); - - pixmaps[i] = Gdk::Pixmap::create_from_xpm(Gdk::Colormap::get_system(), - bitmaps[i], Gdk::Color(), xpm); + pixmaps[i] = Gdk::Pixmap::create_from_xpm(drawable, Gdk::Colormap::get_system(), bitmaps[i], Gdk::Color(), data[i]); } + int w, h; pixmaps[i]->get_size(w, h); @@ -161,7 +159,7 @@ Pix::generate () } Pix * -Gtkmm2ext::get_pix (string name, vector<const char **> xpm_data, bool homog) +Gtkmm2ext::get_pix (string name, vector<const char* const*> xpm_data, bool homog) { Pix *ret = 0; Pix::PixCache::iterator iter; diff --git a/libs/gtkmm2ext/pixscroller.cc b/libs/gtkmm2ext/pixscroller.cc index 9489a532ca..95861fd930 100644 --- a/libs/gtkmm2ext/pixscroller.cc +++ b/libs/gtkmm2ext/pixscroller.cc @@ -29,8 +29,9 @@ using namespace std; using namespace Gtk; using namespace Gtkmm2ext; -PixScroller::PixScroller (Adjustment& a, Pix& pix) - : adj (a) +PixScroller::PixScroller (Adjustment& a, Pix& p) + : adj (a), + pix (p) { dragging = false; add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK|Gdk::POINTER_MOTION_MASK|Gdk::SCROLL_MASK); @@ -38,7 +39,16 @@ PixScroller::PixScroller (Adjustment& a, Pix& pix) adj.signal_value_changed().connect (mem_fun (*this, &PixScroller::adjustment_changed)); default_value = adj.get_value(); - pix.generate (); +} + +void +PixScroller::on_realize () +{ + DrawingArea::on_realize (); + + Glib::RefPtr<Gdk::Drawable> drawable = Glib::RefPtr<Gdk::Window>::cast_dynamic (get_window()); + + pix.generate (drawable); rail = *(pix.pixmap (0)); rail_mask = *(pix.shape_mask (0)); @@ -61,6 +71,8 @@ PixScroller::PixScroller (Adjustment& a, Pix& pix) sliderrect.set_y((int) rint ((overall_height - sliderrect.get_height()) * (adj.get_upper() - adj.get_value()))); railrect.set_x((sliderrect.get_width() / 2) - 2); + + set_size_request (sliderrect.get_width(), overall_height); } void diff --git a/libs/gtkmm2ext/slider_controller.cc b/libs/gtkmm2ext/slider_controller.cc index ca75fbb7b4..4305c22738 100644 --- a/libs/gtkmm2ext/slider_controller.cc +++ b/libs/gtkmm2ext/slider_controller.cc @@ -43,8 +43,6 @@ SliderController::SliderController (Pix *pixset, bind_statemask (Gdk::CONTROL_MASK) { - pixset->generate (); - signal_button_press_event().connect (mem_fun (this, &SliderController::button_press)); spin.set_name ("SliderControllerValue"); spin.set_size_request (70,-1); // should be based on font size somehow diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc index 79b84aa26d..401ed3e8ad 100644 --- a/libs/gtkmm2ext/utils.cc +++ b/libs/gtkmm2ext/utils.cc @@ -83,15 +83,3 @@ void Gtkmm2ext::set_treeview_header_as_default_label(Gtk::TreeViewColumn* c) gtk_tree_view_column_set_widget( c->gobj(), GTK_WIDGET(0) ); } -Glib::RefPtr<Gdk::Drawable> -Gtkmm2ext::get_bogus_drawable() -{ - static Gtk::Button* button = 0; - - if (button == 0) { - button = new Gtk::Button ("blah"); //bogus button to extract a Gdk::Drawable from - } - static Glib::RefPtr<Gdk::Drawable> drawable = button->get_window(); - return drawable; -} - |