Issues with sub_windows redraw() in MacOSX..

38 views
Skip to first unread message

Marco Ladino

unread,
Oct 10, 2014, 9:56:44 PM10/10/14
to fltkg...@googlegroups.com
Greetings,
I found some troubles, when redrawing sub_windows with MacOSX,
but my best explaining about this issue, is in the next program:

/*-------------------------------------------------------------------------------------

    Theme: Issues with sub_windows redraw() in MacOSX..
    Author: Marco Ladino
    Using:  FLTK tookit v1.3.x abstraction layer
    Purpose: Shows some issues with MacOSX only,
             about sub-windows redraw..

    Comments:
    Running this program on MacOSX 10.5.x thru 10.9.x,
    shows the next behaviour:

     When redrawing sub-windows(child windows), from the parent group,
     kills the sub-windows borders, exactly 1 pixel wide line around them.

     Resizing the window, or clicking in "redraw All" button shows the problem.

     Perhaps there is a clipping region issue with OSX?
     With Linux and mswindoze works okay, but not with MacOSX.

     Also, in Window 1, i'm showing sub_windows (child windows) hierarchy,
     that not works in MacOSX.

     Perhaps there are some wrong in this code?

-------------------------------------------------------------------------------------*/

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Pixmap.H>
//#include <FL/fl_draw.H>

// this is a .xpm image..
static const char *pPixmapXPM[] =
{
"14 14 2 1",
"       c None",
"x      c #585858",
"              ",
"    xxxxx     ",
"  xxxxxxxxx   ",
"  xxxxxxxxx   ",
" xx  xxx  xx  ",
" xxx  x  xxx  ",
" xxxx   xxxx  ",
" xxxx   xxxx  ",
" xxx  x  xxx  ",
" xx  xxx  xx  ",
"  xxxxxxxxx   ",
"  xxxxxxxxx   ",
"    xxxxx     ",
"              "};

//callback..
void callback_redraw(Fl_Widget*, void *pParentWidget)
{
    Fl_Double_Window* pWin = (Fl_Double_Window*)pParentWidget;
    pWin->redraw();
    //pWin->show();
}

//MAIN..
int main()
{
 Fl_Pixmap pPixmapX(pPixmapXPM); // assign xpm to a pixmap..
 Fl_Button *pButX=0;
 Fl_Box *pBoxX=0;



//Main Window 1..
Fl_Double_Window *pWin1Main=new Fl_Double_Window(50,50,600,600,"Win1 main");
pWin1Main->resizable(pWin1Main);
pWin1Main->begin();
pButX=new Fl_Button(10,10,240,25,"Win1 Main - redraw all");
pButX->callback(callback_redraw, pWin1Main);

       Fl_Double_Window *pWin1SubWin1=new Fl_Double_Window(10,50,350,300,"SubWin1");
       pWin1SubWin1->begin();
       pBoxX=new Fl_Box(0,0,350,300);
       pBoxX->box(FL_DOWN_FRAME);
       pBoxX->color(18);
        //pBoxX->align(FL_ALIGN_INSIDE);
        pButX=new Fl_Button(10,10,240,25,"SubWin1 - Redraw_this");
        pButX->callback(callback_redraw, pWin1SubWin1);

        Fl_Double_Window *pWin1SubWin2=new Fl_Double_Window(10,50,300,200,"SubWin2");
        pWin1SubWin2->begin();
         pButX=new Fl_Button(10,10,240,25,"SubWin2 - Redraw_this");
         pButX->callback(callback_redraw, pWin1SubWin2);

          Fl_Double_Window *pWin1SubWin3=new Fl_Double_Window(10,50,250,100,"SubWin3");
          pWin1SubWin3->begin();
          pBoxX=new Fl_Box(0,0,200,100);
          pBoxX->image(pPixmapX);
           pButX=new Fl_Button(10,10,200,25,"SubWin3 - Redraw_this");
           pButX->callback(callback_redraw, pWin1SubWin3);
           //pBoxX->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER);
          pWin1SubWin3->end();
          pWin1SubWin3->color(FL_BLUE);

        pWin1SubWin2->end();
        pWin1SubWin2->color(FL_GREEN);

      pWin1SubWin1->end();
      pWin1SubWin1->color(FL_RED);
pWin1Main->end();
pWin1Main->show();



//Main Window 2..
Fl_Double_Window *pWin2Main=new Fl_Double_Window(200,200,600,600,"Win2 main");
pWin2Main->resizable(pWin2Main);
pWin2Main->begin();
pButX=new Fl_Button(10,10,240,25,"Win2 Main - redraw all");
pButX->callback(callback_redraw, pWin2Main);


    //subwindow 1..
    Fl_Double_Window *pWin2SubWin1=new Fl_Double_Window(50,50,300,200,"SubWin1");
    //pWin2SubWin1->box(FL_NO_BOX);
    //pWin2SubWin1->color(FL_GREEN/*,FL_CYAN*/);
    pWin2SubWin1->begin();
     Fl_Box *pWin2SubWin1box=new Fl_Box(0,0,300,200);
     pWin2SubWin1box->box(FL_DOWN_FRAME);
     pWin2SubWin1box->color(19);
     pWin2SubWin1box->align(FL_ALIGN_INSIDE);
     pWin2SubWin1box->image(pPixmapX);
     pButX=new Fl_Button(10,10,200,25,"SubWin1 - redraw_this");
     pButX->callback(callback_redraw, pWin2SubWin1);
    pWin2SubWin1->end();
    pWin2SubWin1->color(FL_GREEN);


    //subwindow X..
    Fl_Double_Window *pWin2SubWinX=new Fl_Double_Window(200,300,300,200,"SubWinX");
    //pWin2SubWinX->box(FL_NO_BOX);
    //pWin2SubWinX->color(FL_GREEN/*,FL_CYAN*/);
    pWin2SubWinX->begin();
     Fl_Box *pWin2SubWinXbox=new Fl_Box(0,0,300,200);
     pWin2SubWinXbox->box(FL_DOWN_FRAME);
     pWin2SubWinXbox->color(19);
     pWin2SubWinXbox->align(FL_ALIGN_INSIDE);
     pWin2SubWinXbox->image(pPixmapX);
     pButX=new Fl_Button(10,10,200,25,"SubWinX - redraw_this");
     pButX->callback(callback_redraw, pWin2SubWinX);
    pWin2SubWinX->end();
    pWin2SubWinX->color(FL_BLUE);


pWin2Main->end();
pWin2Main->show();





    return(Fl::run());
}

Thank you..



Ian MacArthur

unread,
Oct 12, 2014, 9:09:23 AM10/12/14
to fltkg...@googlegroups.com
On Sat Oct 11 2014 02:56:44, Marco Ladino wrote:
    Theme: Issues with sub_windows redraw() in MacOSX..
    Author: Marco Ladino
    Using:  FLTK tookit v1.3.x abstraction layer
    Purpose: Shows some issues with MacOSX only,
             about sub-windows redraw..

    Comments:
    Running this program on MacOSX 10.5.x thru 10.9.x,
    shows the next behaviour:

     When redrawing sub-windows(child windows), from the parent group,
     kills the sub-windows borders, exactly 1 pixel wide line around them.

     Resizing the window, or clicking in "redraw All" button shows the problem.

     Perhaps there is a clipping region issue with OSX?
     With Linux and mswindoze works okay, but not with MacOSX.

     Also, in Window 1, i'm showing sub_windows (child windows) hierarchy,
     that not works in MacOSX.

     Perhaps there are some wrong in this code?


I haven’t had a chance to really study your code, so can not comment on it specifically. 

However, I wonder why you are using sub-windows at all in this case - is there some specific reason why you need to do this?

The use of sub-windows as widget containers in a hierarchy like that is really not the fltk way - you really ought to use Fl_Group for that sort of thing.

Perhaps switching to Fl_Group rather than using sub-windows would allow you to avoid this issue in the first place?

As to whether there is something awry, there may well be; ISTR that OSX doesn’t really support the concept of sub-windows at all, so we tend to be “faking” sub-windows on OSX.

If that is indeed still true, then it may be that what you are doing is not feasible on OSX anyway, though I can not say for certain.

Others (maybe Manolo?) would probably know better?

-- 
Ian


Marco Ladino

unread,
Oct 13, 2014, 7:20:55 PM10/13/14
to fltkg...@googlegroups.com
>>However, I wonder why you are using sub-windows at all in this case - is there some specific reason why you need to do this?

Yes, It is because my APP uses multiple movable widgets inside a WM/Main Window,
and i'd like to have advantage from WM/Windows z-order clipping and redrawing properties,
(like preserving background widgets/windows under WM control)


>>The use of sub-windows as widget containers in a hierarchy like that is really not the fltk way - you really ought to use Fl_Group for that sort of thing.

>>Perhaps switching to Fl_Group rather than using sub-windows would allow you to avoid this issue in the first place?

I think like you, in fact i use groups, because groups is the strongest way to doing it with fltk,
my APP uses one "WM/Main Window" and several movable widgets inside, that looks and behave like SubWindows,
but i included this windows hierarchy example, only because in Linux and mswindoze work well.

if you see the example code for "Main Window 2", we are using simple sub_windows inside a Main_window,
there are not multilevel window hierarchy like shown in "Main Window 1",
and using "redraw(), show() or flush()" the fltk behaviour is the same.

In the case of "Main Window 2", the only issue is in one "1 pixel wide Window Border" not shown,
only 1 pixel wide in the four sides, perhaps this is not one Border?


>>As to whether there is something awry, there may well be; ISTR that OSX doesn’t really support the concept of sub-windows at all, so we tend to be “faking” sub-windows on OSX.

>>If that is indeed still true, then it may be that what you are doing is not feasible on OSX anyway, though I can not say for certain.

Yes, FLTK is a great Toolkit/Abtraction Layer, thank you for this.

OSX supports the sub_windows concept something like:
    NSWindow->
        ContentView->
            NSViews->SubViews

This make me think that fltk makes this okay on OSX, except for this.

Thanks to everybody, long living to FLTK
--MARCO--
Reply all
Reply to author
Forward
0 new messages