FLTK logo

STR #1678

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]

STR #1678

Application:FLTK Library
Status:1 - Closed w/Resolution
Priority:2 - Low, e.g. a documentation error or undocumented side-effect
Scope:3 - Applies to all machines and operating systems
Subsystem:Core Library
Summary:fl_down() and fl_frame() functions incorrect
Version:1.1-current
Created By:d.zimmer
Assigned To:matt
Fix Version:1.1-current (SVN: v5834)
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

No files


Trouble Report Comments:


Name/Time/Date Text  
 
#1 d.zimmer
21:15 May 14, 2007
fl_down(FL_NO_BOX) produces FL_FLAT_BOX, when it should return FL_NO_BOX

fl_frame(), although apparently unused by the library, seems to be completely wrong.

see following demo:

void main(void)
{
# define old_fl_down(b)  (b|1)
# define old_fl_frame(b) (b|2)

# define new_fl_down(b)  ((b<FL_UP_BOX)?b:(b|1))
# define new_fl_frame(b) ((b%4<2)?b:(b+2))
# define new_fl_box(b)   ((b<FL_UP_BOX||b%4>1)?b:(b-2))

  char *names[] = {
  "FL_NO_BOX", "FL_FLAT_BOX",
  "FL_UP_BOX", "FL_DOWN_BOX",
  "FL_UP_FRAME", "FL_DOWN_FRAME",
  "FL_THIN_UP_BOX", "FL_THIN_DOWN_BOX",
  "FL_THIN_UP_FRAME", "FL_THIN_DOWN_FRAME",
  "FL_ENGRAVED_BOX", "FL_EMBOSSED_BOX",
  "FL_ENGRAVED_FRAME", "FL_EMBOSSED_FRAME",
  "FL_BORDER_BOX", "FL_SHADOW_BOX",
  "FL_BORDER_FRAME", "FL_SHADOW_FRAME"
  };
  int i;

  printf("***fl_down()\n\n");
  for(i=FL_NO_BOX; i<=FL_BORDER_BOX; i++)
  {
    printf("original for %s, down=%s\n", names[i], names[old_fl_down(i)]);
    printf(" revised for %s, down=%s\n", names[i], names[new_fl_down(i)]);
    printf("\n");
  }

  printf("***fl_frame()\n\n");
  for(i=FL_NO_BOX; i<=FL_BORDER_BOX; i++)
  {
    printf("original for %s, frame=%s\n", names[i], names[old_fl_frame(i)]);
    printf(" revised for %s, frame=%s\n", names[i], names[new_fl_frame(i)]);
    printf("\n");
  }

  printf("***fl_box()\n\n");
  for(i=FL_NO_BOX; i<=FL_BORDER_BOX; i++)
  {
    printf("test for %s, box=%s\n", names[i], names[new_fl_box(i)]);
    printf("\n");
  }
}

Suggested fixes to FL/Enumerations.H:

inline Fl_Boxtype fl_down(Fl_Boxtype b) {return (Fl_Boxtype)((b<FL_UP_BOX)?b:(b|1));}
inline Fl_Boxtype fl_frame(Fl_Boxtype b) {return (Fl_Boxtype)((b%4<2)?b:(b+2));}

addition, if desired:

inline Fl_Boxtype fl_box(Fl_Boxtype b) {return (Fl_Boxtype)((b<FL_UP_BOX||b%4>1)?b:(b-2));}

It also occurs to me that a caveat should be added to the documentation when defining new box types... that at least both up/down styles should be defined, since Fl_Button will automatically call fl_down().

Don.
 
 
#2 matt
01:33 May 16, 2007
Fixed in Subversion repository.

Thanks for these good suggestions. I hope that my additions in the documentation are understandable. Maybe some native speaker finds the time to "de-germanfy" my blurbs.
 
     

Return to Bugs & Features ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.