|
Entering phase 3 of "My Life And Times With FLTK Version II": Note: these pix just keep my programming editor from indenting when it shouldn't. The position of the starting text and thc closed brace do it, but why not play with that effect a little... So.... --------- _\ /_ {='.'=} re. my rework of test/layout.cxx is bum. Needs "begin()" and also, my guess at LayoutGroup for the Groups (that layout) appears to be bad (causes a floating point error somethwere). But later... got some other stuff to do first. --------- / : \__ {.}}(.}} re. ask (message.cxx, renamed in my system to ask.cxx so it matches the header name). * ask needs a default window title \, // rs-> static char* default_label = "Notice:"; Window window(3*BORDER_W+ICON_W+INPUT_W, 3*BORDER_H+ICON_H+BUTTON_H); if(message_window_label && message_window_label[0] != 0) window.copy_label(message_window_label); // rs-> else window.label(default_label); // (Add a setter if you want to change it) or explicitly use "" if you want it blank * ask needs to measure the text and the buttons (whichever is greater) and if it's a one-liner and give about 32 pixels margin on the right instead of the long window originally created. The following requires no other mods to come very close to the ideal message box (defined by windows, qt, gnome,kde) shape. //#define INPUT_W 270 // this looks nicer with typically smaller fonts and is more than enough // to handle input text in test/ask, and the window IS resizable (along // with the input widget. #define INPUT_W 180 //#define MIN_BUTTON_W 75 #define MIN_BUTTON_W 64 ![]() [Default size after changes (tested with test/ask)] Andddddd.... ![]() [Minimum size after changes] --------- .' '.__ {.}}(.}} re. fluid * In fluid fhe file names are often horribly long and we only need to verify that we're in the right folder so when the "Wrote: .... " message is displayed it would be nice to clamp string length to something that won't ever extend past the limits of the screen, and in fact maybe even something readable, say about 32 to 40 chars. [1........01........01........01........0] [the/quick/brown/fox/jumped/over/the/lazy]/dog --> [the/quick/brown/fo...r/over/the/lazy/dog] Here's a fluid message clamped to 32 chars. ![]() Interested? Here's the code changes. [WARNING: This DOES modify the input string.] In fluid.cxx add: // rs-> // shifts (ascii) data in string to fit in field threshold // bytes long. DOES modify input string. static char* clamp_path(char* dynstr, int char_threshold) { int slen = strlen(dynstr); int first_half, second_half; if(slen <= char_threshold) return dynstr; second_half = (char_threshold / 2) - 1; // need room for three dots. first_half = (char_threshold - second_half) - 3; sprintf(dynstr + first_half, "...%s", dynstr + slen - second_half); return dynstr; } in fluid.cxx somewhere around line 700 - 724 (after insertion of the above text), change: // message("Wrote %s", cname, 0); message("Wrote %s", clamp_path(cname, 32), 0); Again, this routine does change the input string so it's private (static) in the above context and will almost certainly cause you headaches if you use it as written in other code. ;-) Fair warning. But it's perfect for this application and could easily be modified to return a 'newstring()'. Currently reworking my old v1.x files and learning the ropes here. It's quite different and quite nice. And away we go... 'cmon, kitty. _\ /_ {='.'=} ...or rabbit or whateve you are. [BTW my hard drive has apparently quit eating soggy cardboard and now only sounds like someone's popping plastic popcorn sometimes... I think it might just survive!! This is great. AND I have no idea in the world why it was making such a racket and vibrating like crazy. Still, I'm not sure I should have traded my UFO for a SATA drive. We'll see.] |
_______________________________________________ fltk-bugs mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk-bugs



