Search code examples
c++user-interfacefltk

Which origin does FLTK draw function use ? Widget or Window?


I'm trying to create a custom rpm gauge widget. everything looks fine when i test it by itself. But when i try to draw it at a different position in the parent window it seems to always draw using the origin of the window and not that of the widget no matter what x or y value i am passing to the constructor.

a printf() after calling the constructor confirmed that the widget "knows" the intended x and y. gauge showing at window (0,0) and not (0,400) initialization of new gauge object

Is this the default behavior ? i thought that the draw function uses the widgets 0,0 and not the window. do i need to explicitly call the x() and y() in the draw function and apply transforms to correct this ?


Solution

  • Yep, that's correct. All coordinates in FLTK 1.x are relative to the window. Subwindows create their own coordinate space, i.e. coordinates in subwindows are relative to the subwindow, not the main window.