diff options
author | Aaron M. Ucko <ucko@debian.org> | 2010-10-25 23:09:08 -0400 |
---|---|---|
committer | Aaron M. Ucko <ucko@debian.org> | 2010-10-25 23:12:32 -0400 |
commit | 2d319ff9f1070c6965de420fa4584eb39ce62bd3 (patch) | |
tree | 8351ab0f0bd13b71b09ca6f3259c282012f8f777 /src | |
parent | deeeddd31d3c39dfb1a0df203cec3634f96a0d29 (diff) | |
parent | 95f5ee2210b7b1999eba0156d24566225eedf700 (diff) |
Merge commit 'upstream/1.3_r7725'
Diffstat (limited to 'src')
-rw-r--r-- | src/Fl_Double_Window.cxx | 43 | ||||
-rw-r--r-- | src/Fl_Gl_Choice.cxx | 37 | ||||
-rw-r--r-- | src/Fl_Gl_Device_Plugin.cxx | 5 | ||||
-rw-r--r-- | src/Fl_Group.cxx | 53 | ||||
-rw-r--r-- | src/Fl_Scroll.cxx | 21 | ||||
-rw-r--r-- | src/Fl_Tree.cxx | 10 | ||||
-rw-r--r-- | src/Fl_cocoa.mm | 2 | ||||
-rw-r--r-- | src/Fl_get_key_mac.cxx | 10 | ||||
-rw-r--r-- | src/fl_cursor.cxx | 6 |
9 files changed, 134 insertions, 53 deletions
diff --git a/src/Fl_Double_Window.cxx b/src/Fl_Double_Window.cxx index 13725b5..56ea98e 100644 --- a/src/Fl_Double_Window.cxx +++ b/src/Fl_Double_Window.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Double_Window.cxx 7671 2010-07-09 17:31:33Z manolo $" +// "$Id: Fl_Double_Window.cxx 7720 2010-10-12 12:34:19Z manolo $" // // Double-buffered window code for the Fast Light Tool Kit (FLTK). // @@ -67,6 +67,15 @@ void Fl_Double_Window::show() { static void fl_copy_offscreen_to_display(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy); +/** \addtogroup fl_drawings + @{ + */ +/** Copy a rectangular area of the given offscreen buffer into the current drawing destination. + \param x,y position where to draw the copied rectangle + \param w,h size of the copied rectangle + \param pixmap offscreen buffer containing the rectangle to copy + \param srcx,srcy origin in offscreen buffer of rectangle to copy + */ void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { if( fl_graphics_driver == fl_display_device->driver()) { fl_copy_offscreen_to_display(x, y, w, h, pixmap, srcx, srcy); @@ -79,6 +88,7 @@ void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx delete img; } } +/** @} */ #if defined(USE_X11) @@ -184,26 +194,35 @@ void fl_copy_offscreen_with_alpha(int x,int y,int w,int h,HBITMAP bitmap,int src extern void fl_restore_clip(); -#elif defined(__APPLE_QUARTZ__) +#elif defined(__APPLE_QUARTZ__) || defined(FL_DOXYGEN) char fl_can_do_alpha_blending() { return 1; } -Fl_Offscreen fl_create_offscreen(int w, int h) { +Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h) { void *data = calloc(w*h,4); CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); CGContextRef ctx = CGBitmapContextCreate( - data, w, h, 8, w*4, lut, kCGImageAlphaNoneSkipLast); + data, w, h, 8, w*4, lut, kCGImageAlphaPremultipliedLast); CGColorSpaceRelease(lut); return (Fl_Offscreen)ctx; } -Fl_Offscreen fl_create_offscreen_with_alpha(int w, int h) { +/** \addtogroup fl_drawings + @{ + */ + +/** + Creation of an offscreen graphics buffer. + \param w,h width and height in pixels of the buffer. + \return the created graphics buffer. + */ +Fl_Offscreen fl_create_offscreen(int w, int h) { void *data = calloc(w*h,4); CGColorSpaceRef lut = CGColorSpaceCreateDeviceRGB(); CGContextRef ctx = CGBitmapContextCreate( - data, w, h, 8, w*4, lut, kCGImageAlphaPremultipliedLast); + data, w, h, 8, w*4, lut, kCGImageAlphaNoneSkipLast); CGColorSpaceRelease(lut); return (Fl_Offscreen)ctx; } @@ -238,6 +257,9 @@ static void fl_copy_offscreen_to_display(int x,int y,int w,int h,Fl_Offscreen os CGDataProviderRelease(src_bytes); } +/** Deletion of an offscreen graphics buffer. + \param ctx the buffer to be deleted. + */ void fl_delete_offscreen(Fl_Offscreen ctx) { if (!ctx) return; void *data = CGBitmapContextGetData((CGContextRef)ctx); @@ -252,6 +274,9 @@ static CGContextRef stack_gc[stack_max]; static Window stack_window[stack_max]; static Fl_Surface_Device *_ss; +/** Send all subsequent drawing commands to this offscreen buffer. + \param ctx the offscreen buffer. + */ void fl_begin_offscreen(Fl_Offscreen ctx) { _ss = fl_surface; fl_display_device->set_current(); @@ -268,6 +293,8 @@ void fl_begin_offscreen(Fl_Offscreen ctx) { fl_push_no_clip(); } +/** Quit sending drawing commands to the current offscreen buffer. + */ void fl_end_offscreen() { Fl_X::q_release_context(); fl_pop_clip(); @@ -282,6 +309,8 @@ void fl_end_offscreen() { _ss->set_current(); } +/** @} */ + extern void fl_restore_clip(); #else @@ -428,5 +457,5 @@ Fl_Double_Window::~Fl_Double_Window() { } // -// End of "$Id: Fl_Double_Window.cxx 7671 2010-07-09 17:31:33Z manolo $". +// End of "$Id: Fl_Double_Window.cxx 7720 2010-10-12 12:34:19Z manolo $". // diff --git a/src/Fl_Gl_Choice.cxx b/src/Fl_Gl_Choice.cxx index a2b30b1..deb456b 100644 --- a/src/Fl_Gl_Choice.cxx +++ b/src/Fl_Gl_Choice.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Gl_Choice.cxx 7351 2010-03-29 10:35:00Z matt $" +// "$Id: Fl_Gl_Choice.cxx 7724 2010-10-18 10:49:04Z manolo $" // // OpenGL visual selection code for the Fast Light Tool Kit (FLTK). // @@ -349,11 +349,21 @@ void fl_set_gl_context(Fl_Window* w, GLContext context) { aglSetInteger( context, AGL_BUFFER_RECT, rect ); aglEnable( context, AGL_BUFFER_RECT ); } -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - aglSetWindowRef(context, MACwindowRef(w) ); -# else - aglSetDrawable( context, GetWindowPort( MACwindowRef(w) ) ); -# endif +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#if __LP64__ + // 64 bit version + aglSetWindowRef(context, MACwindowRef(w) ); +#else + // 32 bit version >= 10.5 + if (aglSetWindowRef != NULL) + aglSetWindowRef(context, MACwindowRef(w) ); + else + aglSetDrawable( context, GetWindowPort( MACwindowRef(w) ) ); +#endif +#else + // 32 bit version < 10.5 + aglSetDrawable( context, GetWindowPort( MACwindowRef(w) ) ); +#endif aglSetCurrentContext(context); # else # error unsupported platform @@ -370,12 +380,13 @@ void fl_no_gl_context() { wglMakeCurrent(0, 0); # elif defined(__APPLE_QUARTZ__) // warning: the Quartz version should probably use Core GL (CGL) instead of AGL - AGLContext ctx = aglGetCurrentContext(); -# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 - if (ctx) aglSetWindowRef(ctx, NULL); -# else - if (ctx) aglSetDrawable(ctx, NULL); -# endif + AGLContext ctx = aglGetCurrentContext(); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + if (aglSetWindowRef != NULL) + { if(ctx) aglSetWindowRef(ctx, NULL ); } + else +#endif + if(ctx) aglSetDrawable( ctx, NULL ); aglSetCurrentContext(0); # else # error unsupported platform @@ -401,5 +412,5 @@ void fl_delete_gl_context(GLContext context) { // -// End of "$Id: Fl_Gl_Choice.cxx 7351 2010-03-29 10:35:00Z matt $". +// End of "$Id: Fl_Gl_Choice.cxx 7724 2010-10-18 10:49:04Z manolo $". // diff --git a/src/Fl_Gl_Device_Plugin.cxx b/src/Fl_Gl_Device_Plugin.cxx index ab34432..c44941f 100644 --- a/src/Fl_Gl_Device_Plugin.cxx +++ b/src/Fl_Gl_Device_Plugin.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Gl_Device_Plugin.cxx 7613 2010-05-21 07:15:13Z manolo $" +// "$Id: Fl_Gl_Device_Plugin.cxx 7715 2010-10-11 18:10:32Z greg.ercolano $" // // implementation of class Fl_Gl_Device_Plugin for the Fast Light Tool Kit (FLTK). // @@ -25,6 +25,7 @@ // http://www.fltk.org/str.php // +#include <config.h> #include <FL/Fl_Printer.H> #include <FL/Fl_Gl_Window.H> #include "Fl_Gl_Choice.H" @@ -148,5 +149,5 @@ static Fl_Gl_Device_Plugin Gl_Device_Plugin; FL_EXPORT int fl_gl_load_plugin = 0; // -// End of "$Id: Fl_Gl_Device_Plugin.cxx 7613 2010-05-21 07:15:13Z manolo $". +// End of "$Id: Fl_Gl_Device_Plugin.cxx 7715 2010-10-11 18:10:32Z greg.ercolano $". // diff --git a/src/Fl_Group.cxx b/src/Fl_Group.cxx index 4e8b60f..fc9d7fa 100644 --- a/src/Fl_Group.cxx +++ b/src/Fl_Group.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Group.cxx 7693 2010-08-31 10:01:59Z AlbrechtS $" +// "$Id: Fl_Group.cxx 7718 2010-10-12 08:12:44Z AlbrechtS $" // // Group widget for the Fast Light Tool Kit (FLTK). // @@ -387,16 +387,51 @@ void Fl_Group::clear() { savedfocus_ = 0; resizable_ = this; init_sizes(); + + // we must change the Fl::pushed() widget, if it is one of + // the group's children. Otherwise fl_fix_focus() would send + // lots of events to children that are about to be deleted + // anyway. + + Fl_Widget *pushed = Fl::pushed(); // save pushed() widget + if (contains(pushed)) pushed = this; // set it to be the group, if it's a child + Fl::pushed(this); // for fl_fix_focus etc. + // okay, now it is safe to destroy the children: - while (children_) { - Fl_Widget* w = child(0); // *first* child widget - if (w->parent() == this) { // should always be true - remove(0); // remove child widget first - delete w; // then delete it - } else { // this should never happen ! - remove(0); // remove it only + +#define REVERSE_CHILDREN +#ifdef REVERSE_CHILDREN + // Reverse the order of the children. Doing this and deleting + // always the last child is much faster than the other way around. + if (children_ > 1) { + Fl_Widget *temp; + Fl_Widget **a = (Fl_Widget**)array(); + for (int i=0,j=children_-1; i<children_/2; i++,j--) { + temp = a[i]; + a[i] = a[j]; + a[j] = temp; } } +#endif // REVERSE_CHILDREN + + while (children_) { // delete all children + int idx = children_-1; // last child's index + Fl_Widget* w = child(idx); // last child widget + if (w->parent()==this) { // should always be true + if (children_>2) { // optimized removal + w->parent_ = 0; // reset child's parent + children_--; // update counter + } else { // slow removal + remove(idx); + } + delete w; // delete the child + } else { // should never happen + remove(idx); // remove it anyway + } + } + + if (pushed != this) Fl::pushed(pushed); // reset pushed() widget + } /** @@ -792,5 +827,5 @@ void Fl_Group::draw_outside_label(const Fl_Widget& widget) const { } // -// End of "$Id: Fl_Group.cxx 7693 2010-08-31 10:01:59Z AlbrechtS $". +// End of "$Id: Fl_Group.cxx 7718 2010-10-12 08:12:44Z AlbrechtS $". // diff --git a/src/Fl_Scroll.cxx b/src/Fl_Scroll.cxx index 4ac025c..0057ead 100644 --- a/src/Fl_Scroll.cxx +++ b/src/Fl_Scroll.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Scroll.cxx 7039 2010-02-07 21:14:35Z AlbrechtS $" +// "$Id: Fl_Scroll.cxx 7718 2010-10-12 08:12:44Z AlbrechtS $" // // Scroll widget for the Fast Light Tool Kit (FLTK). // @@ -32,13 +32,16 @@ /** Clear all but the scrollbars... */ void Fl_Scroll::clear() { - for (int i=children() - 1; i >= 0; i --) { - Fl_Widget* o = child(i); - if (o != &hscrollbar && o != &scrollbar) { - remove(o); - delete o; - } - } + // Note: the scrollbars are removed from the group before calling + // Fl_Group::clear() to take advantage of the optimized widget removal + // and deletion. Finally they are added to Fl_Scroll's group again. This + // is MUCH faster than removing the widgets one by one (STR #2409). + + remove(scrollbar); + remove(hscrollbar); + Fl_Group::clear(); + add(hscrollbar); + add(scrollbar); } /** Insure the scrollbars are the last children */ @@ -413,5 +416,5 @@ int Fl_Scroll::handle(int event) { } // -// End of "$Id: Fl_Scroll.cxx 7039 2010-02-07 21:14:35Z AlbrechtS $". +// End of "$Id: Fl_Scroll.cxx 7718 2010-10-12 08:12:44Z AlbrechtS $". // diff --git a/src/Fl_Tree.cxx b/src/Fl_Tree.cxx index 08516d9..57f7992 100644 --- a/src/Fl_Tree.cxx +++ b/src/Fl_Tree.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Tree.cxx 7691 2010-08-26 13:32:30Z greg.ercolano $" +// "$Id: Fl_Tree.cxx 7722 2010-10-12 15:46:30Z greg.ercolano $" // #include <stdio.h> @@ -304,8 +304,10 @@ Fl_Tree_Item *Fl_Tree::next_visible_item(Fl_Tree_Item *item, int dir) { } } -/// Set the item currently in focus. Handles calling redraw() -/// as needed to update the focus box. +/// Set the item that currently should have keyboard focus. +/// Handles calling redraw() to update the focus box (if its visible). +/// +/// \param[in] item The item that should take focus. If NULL, none will have focus. /// void Fl_Tree::set_item_focus(Fl_Tree_Item *item) { if ( _item_focus != item ) { // changed? @@ -892,5 +894,5 @@ void Fl_Tree::load(Fl_Preferences &prefs) } // -// End of "$Id: Fl_Tree.cxx 7691 2010-08-26 13:32:30Z greg.ercolano $". +// End of "$Id: Fl_Tree.cxx 7722 2010-10-12 15:46:30Z greg.ercolano $". // diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 2c0770d..ec45131 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -184,7 +184,7 @@ static unsigned short macKeyLookUp[128] = 0/*FL_Shift_L*/, 0/*FL_Caps_Lock*/, 0/*FL_Alt_L*/, 0/*FL_Control_L*/, 0/*FL_Shift_R*/, 0/*FL_Alt_R*/, 0/*FL_Control_R*/, 0, - 0, FL_KP+'.', FL_Right, FL_KP+'*', 0, FL_KP+'+', FL_Left, FL_Delete, + 0, FL_KP+'.', FL_Right, FL_KP+'*', 0, FL_KP+'+', FL_Left, FL_Num_Lock, FL_Down, 0, 0, FL_KP+'/', FL_KP_Enter, FL_Up, FL_KP+'-', 0, 0, FL_KP+'=', FL_KP+'0', FL_KP+'1', FL_KP+'2', FL_KP+'3', FL_KP+'4', FL_KP+'5', diff --git a/src/Fl_get_key_mac.cxx b/src/Fl_get_key_mac.cxx index 17617ad..84f0371 100644 --- a/src/Fl_get_key_mac.cxx +++ b/src/Fl_get_key_mac.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_get_key_mac.cxx 7615 2010-05-26 21:25:11Z manolo $" +// "$Id: Fl_get_key_mac.cxx 7725 2010-10-19 12:29:35Z manolo $" // // MacOS keyboard state routines for the Fast Light Tool Kit (FLTK). // @@ -34,7 +34,7 @@ #include <config.h> // convert an FLTK (X) keysym to a MacOS symbol: -// See also the inverse converter in Fl_mac.cxx +// See also the inverse converter in table macKeyLookUp of Fl_cocoa.mm // This table is in numeric order by FLTK symbol order for binary search: static const struct {unsigned short vk, fltk;} vktab[] = { @@ -54,7 +54,7 @@ static const struct {unsigned short vk, fltk;} vktab[] = { { 107, FL_Scroll_Lock }, { 53, FL_Escape }, { 0x73, FL_Home }, { 123, FL_Left }, { 126, FL_Up }, { 124, FL_Right }, { 125, FL_Down }, { 0x74, FL_Page_Up }, { 0x79, FL_Page_Down }, { 119, FL_End }, { 0x71, FL_Print }, { 127, FL_Insert }, - { 0x6e, FL_Menu }, { 114, FL_Help }, /*{ 0x47, FL_Num_Lock },*/ + { 0x6e, FL_Menu }, { 114, FL_Help }, { 0x47, FL_Num_Lock }, { 76, FL_KP_Enter }, { 67, FL_KP+'*' }, { 69, FL_KP+'+'}, { 78, FL_KP+'-' }, { 65, FL_KP+'.' }, { 75, FL_KP+'/' }, { 82, FL_KP+'0' }, { 83, FL_KP+'1' }, { 84, FL_KP+'2' }, { 85, FL_KP+'3' }, { 86, FL_KP+'4' }, { 87, FL_KP+'5' }, { 88, FL_KP+'6' }, { 89, FL_KP+'7' }, @@ -64,7 +64,7 @@ static const struct {unsigned short vk, fltk;} vktab[] = { { 0x65, FL_F+9 }, { 0x6D, FL_F+10 }, { 0x67, FL_F+11 }, { 0x6f, FL_F+12 }, { 56, FL_Shift_L }, { 56, FL_Shift_R }, { 59, FL_Control_L }, { 59, FL_Control_R }, { 57, FL_Caps_Lock }, { 55, FL_Meta_L }, { 55, FL_Meta_R }, - { 58, FL_Alt_L }, { 58, FL_Alt_R }, /*{ 0x75, FL_Delete },*/ { 0x47, FL_Delete }, + { 58, FL_Alt_L }, { 58, FL_Alt_R }, { 0x75, FL_Delete }, }; static int fltk2mac(int fltk) { @@ -114,5 +114,5 @@ int Fl::get_key(int k) { } // -// End of "$Id: Fl_get_key_mac.cxx 7615 2010-05-26 21:25:11Z manolo $". +// End of "$Id: Fl_get_key_mac.cxx 7725 2010-10-19 12:29:35Z manolo $". // diff --git a/src/fl_cursor.cxx b/src/fl_cursor.cxx index 2d45435..953c749 100644 --- a/src/fl_cursor.cxx +++ b/src/fl_cursor.cxx @@ -1,5 +1,5 @@ // -// "$Id: fl_cursor.cxx 7351 2010-03-29 10:35:00Z matt $" +// "$Id: fl_cursor.cxx 7714 2010-10-11 18:02:00Z greg.ercolano $" // // Mouse cursor support for the Fast Light Tool Kit (FLTK). // @@ -176,7 +176,7 @@ CGContextRef CreateWatchImage(void) fl_color(FL_WHITE); fl_circle(0, 0, r+1); fl_color(FL_BLACK); - fl_rectf(-r*0.7, -r*1.7, 1.4*r, 3.4*r); + fl_rectf(int(-r*0.7), int(-r*1.7), int(1.4*r), int(3.4*r)); fl_rectf(r-1, -1, 3, 3); fl_color(FL_WHITE); fl_pie(-r, -r, 2*r, 2*r, 0, 360); @@ -333,5 +333,5 @@ void Fl_Window::cursor(Fl_Cursor c, Fl_Color fg, Fl_Color bg) { #endif // -// End of "$Id: fl_cursor.cxx 7351 2010-03-29 10:35:00Z matt $". +// End of "$Id: fl_cursor.cxx 7714 2010-10-11 18:02:00Z greg.ercolano $". // |