Lucas,

What do you expect this code to do? This version seems to work, as far
as I can see, on winXP. All I did was fix the typos to make it compile,
and added a main, and it seems to be OK.
Maybe I don't understand what it is meant to do?
In future though, please post *compileable* examples...

-----------------------------------------

#include<stdlib.h>
#include<stdio.h>

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

class Container : public Fl_Double_Window
{
public:
        int border;
private:
  int xPos;
  bool bSplit;

  void Container::draw(){
    Fl_Double_Window::draw();
    fl_color(FL_BLACK);
    fl_line_style( FL_DOT, 1);

    if(bSplit){
      fl_push_clip(x(), y(), w(), h());

      fl_line(xPos - 1, y() + border, xPos - 1, y() + h() - (border *
2));
      fl_line(xPos, y() + border, xPos, y() + h() - (border * 2));
      fl_line(xPos + 1, y() + border, xPos + 1, y() + h() - (border *
2));

      fl_pop_clip();
    }
    else{
      fl_push_clip(x(), y(), w(), h());
      fl_pop_clip();
    }
  }

  public:

    Container(int x, int y, int w, int h, char *l = 0)
    : Fl_Double_Window(x, y, w, h, l)
    {
//      set_non_modal(); this should not be here...
      box(FL_DOWN_BOX);

      bSplit = false;
      border = Fl::box_dx(FL_DOWN_BOX);
    }

    inline void setSplit(bool split){bSplit = split;}
    inline void setXPos(int x){xPos = x;}
};



class VrtSplitter : public Fl_Group
{
  Container *container1, *container2;
  int splitPos, oldXPos;
  bool bSplit;

  void setSplitCtnr(bool split){
    container1->setSplit(split);
    container2->setSplit(split);
  }


  int VrtSplitter::handle(int e){
    int ret = Fl_Group::handle(e);

    switch(e){
      case FL_MOVE:

        if(Fl::event_x() > container1->w() - container1->border &&
Fl::event_x() < container1->w() + container1->border)
        {
          fl_cursor(FL_CURSOR_WE);
          bSplit = true;
        }
        else
        {
          fl_cursor(FL_CURSOR_DEFAULT);
          bSplit = false;
        }

        return 1;

      case FL_PUSH:

        if(Fl::event_button() == FL_LEFT_MOUSE && bSplit){
          setSplitCtnr(true);
          oldXPos = Fl::event_x();
          container1->setXPos(container1->w());
          container2->setXPos(0);
          container1->redraw();
          container2->redraw();
        }

        return 1;

      case FL_RELEASE:

        if(Fl::event_button() == FL_LEFT_MOUSE && bSplit){
          splitPos = Fl::event_x();
          setSplitCtnr(false);
          container1->resize(x(), y(), splitPos, h());
          container2->resize(x() + splitPos, y(), w() - splitPos, h());
          bSplit = false;
          container1->redraw();
          container2->redraw();
        }

        return 1;

      case FL_DRAG:

        if(bSplit && Fl::event_state(FL_BUTTON1) != 0){
          splitPos = Fl::event_x();
          if(splitPos < oldXPos)
          {
            container1->setXPos(splitPos);
            container1->redraw();
          }
          else
          {
            container2->setXPos(splitPos - oldXPos);
            container2->redraw();
          }
        }

        return 1;
    }

    return(ret);
  }

  public:

  VrtSplitter(int x, int y, int w, int h, const char *l = 0)
    : Fl_Group(x, y, w, h, l)
  {
    begin();
    container1 = new Container(x, y, w / 2, h);
    container1->color((Fl_Color) FL_RED);
    end();

    begin();
    container2 = new Container(x + (w / 2), y, w / 2, h);
    container2->color((Fl_Color) FL_BLUE);
    end();

    bSplit = false;
  }
};

int main(int argc, char **argv)
{
        VrtSplitter *vrt;
        Fl_Double_Window *main_win = new Fl_Double_Window(300, 300,
"test");
        main_win->begin();

        vrt = new VrtSplitter(5, 5, 290, 290);
        vrt->end();
        main_win->end();

        main_win->show(argc, argv);

        return Fl::run();
}

/* end of file */



SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to