Author Topic: How to add corner between scrollbars?  (Read 3780 times)

xterro

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
How to add corner between scrollbars?
« on: November 20, 2016, 11:21:15 AM »
Hello, is there an example how to add corner between scrollbars? I've wrote some code, but corner doesn't appears :(
I have looked at scrollarea.cpp, in my case corner->show() does not any effect.

Code: [Select]
// *.cpp

#include "TR_MainWindow.h"

// Map
FXDEFMAP(TR_MainWindow) TR_MainWindowMap[]={
    FXMAPFUNC(SEL_PAINT,             TR_MainWindow::ID_CANVAS, TR_MainWindow::onExpose),
    FXMAPFUNC(SEL_CONFIGURE,         TR_MainWindow::ID_CANVAS, TR_MainWindow::onConfigure),
    FXMAPFUNC(SEL_LEFTBUTTONPRESS,   TR_MainWindow::ID_CANVAS, TR_MainWindow::onMouseDown),
    FXMAPFUNC(SEL_LEFTBUTTONRELEASE, TR_MainWindow::ID_CANVAS, TR_MainWindow::onMouseUp),
    FXMAPFUNC(SEL_MOUSEWHEEL,        TR_MainWindow::ID_CANVAS, TR_MainWindow::onMouseWheel),
    FXMAPFUNC(SEL_MOTION,            TR_MainWindow::ID_CANVAS, TR_MainWindow::onMouseMove),
};


// Object implementation
FXIMPLEMENT(TR_MainWindow,FXMainWindow,TR_MainWindowMap, ARRAYNUMBER(TR_MainWindowMap))

TR_MainWindow::TR_MainWindow(FXApp* a)
    :FXMainWindow(a,"TR_MainWindow Test",NULL,NULL,DECOR_ALL,0,0,1000,700) {
         
     // Menu bar
    menubar=new FXMenuBar(this,LAYOUT_SIDE_TOP|LAYOUT_FILL_X|FRAME_RAISED);
   
    // Status bar
    status = new FXStatusBar(this,LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|STATUSBAR_WITH_DRAGCORNER);
   
    //Scrollbars
    vscrollbar = new FXScrollBar(this, this, ID_VSCROLL, SCROLLBAR_VERTICAL | LAYOUT_SIDE_RIGHT | LAYOUT_FILL_Y);
   
    int vw = vscrollbar->getDefaultWidth();
    fxmessage("vw: %i\n", vw);
   
    hscrollbar = new FXScrollBar(this, this, ID_HSCROLL, SCROLLBAR_HORIZONTAL | LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X);
   
    // trying to do something with scrollbars to add corner,
    vscrollbar->position(width-vw,0,vw,height-vw);
    hscrollbar->position(0,height-vw,width-vw,height-vw);
   
   
    FXScrollCorner *corner=new FXScrollCorner(this);
    corner->position(width-15,height-15, 15, 15);
    corner->setBackColor(FXRGBA(0,0,0,255));
   
    // HOW TO ADD CORNER?
   
   

   
    // no matter
    filemenu=new FXMenuPane(this);
    new FXMenuCommand(filemenu,"Load\tCtl-O",NULL,getApp(),ID_MENU_LOAD);
    new FXMenuSeparator(filemenu);
    new FXMenuCommand(filemenu,"Quit\tCtl-Q",NULL,getApp(),FXApp::ID_QUIT);
   
    new FXMenuTitle(menubar,"&File",NULL,filemenu);   
   
   
    FXComposite *glpanel=new FXVerticalFrame(this,FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT,0,0,0,0, 0,0,0,0);
   
    glvisual=new FXGLVisual(getApp(),VISUAL_DOUBLEBUFFER);
    glcanvas=new FXGLCanvas(glpanel, glvisual,this,ID_CANVAS,LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT);
   
   
}


TR_MainWindow::~TR_MainWindow(){
  delete filemenu;
  delete menubar;
  delete status;
  delete glcanvas;
  delete glvisual;
}

void TR_MainWindow::create(){
    FXMainWindow::create();
    show(PLACEMENT_SCREEN);
}


// Widget needs repainting
long TR_MainWindow::onExpose(FXObject*,FXSelector,void*) {
   
    drawScene();
    return 1;
}
 
// Widget has been resized
long TR_MainWindow::onConfigure(FXObject*,FXSelector,void*){
 

}



// Mouse button was pressed somewhere
long TR_MainWindow::onMouseDown(FXObject*,FXSelector,void*){
 
  return 1;
  }



// The mouse has moved, draw a line
long TR_MainWindow::onMouseMove(FXObject*, FXSelector, void* ptr){

  }



// The mouse button was released again
long TR_MainWindow::onMouseUp(FXObject*,FXSelector,void* ptr){

  }
 
long TR_MainWindow::onMouseWheel(FXObject*,FXSelector,void* ptr){
 
  }


void TR_MainWindow::drawScene() {
   

   
}







JVZ

  • JVZ
  • Administrator
  • Full Member
  • *****
  • Posts: 174
  • Karma: +3/-0
  • FOX Toolkit Developer
    • View Profile
    • FOX Toolkit
Re: How to add corner between scrollbars?
« Reply #1 on: December 08, 2016, 02:26:43 PM »
Unless you have unusual needs, it is probably easier to use FXScrollArea or FXScrollWindow instead of managing FXScrollBars directly.  FXScrollArea manages a paintable area of certain dimensions, and automatically provides scrollbars when the window size relative to the document size calls for them.  This includes a scroll corner.

FXScrollWindow is a layout manager, just like FXHorizontalFrame, except that the area inside may be larger than the visible viewport.  In other words, you use FXScrollWindow when you have a GUI which needs to be larger than available space (think for example a very large dialog running that potentially needs to be displayed on a small screen device).

In both cases, the placement and layout of the ScrollBars is automatic, with some flags that allow you to influence the layout scheme in some important ways. For example, HSCROLLER_ALWAYS forces horizontal ScrollBar to remain visible at all times.

Horizontal and vertical ScrollBars are shown when the document metrics returned by getContentWidth() and getContentHeight() exceed the viewport size.  If both are displayed the scroll corner is automatically shown as well.