FLTK function help

closed account (91q28vqX)
I'm having trouble grabbing the x and y coordinates of button using the functions x() and y() included in the fl/fl_widget.h file.
And how could i create a button in the space that is left vacated by the moved space?

#include "std_lib_facilities_5.h"
#include "Window.h"
//#include "Graph.h"

#include <iostream>
#include <FL/Fl.H>
#include "Window.h"
#include <FL/Fl_Button.H>
#include <FL/Fl_Widget.H>

using namespace std;

void button_cb( Fl_Widget*, void* );
//short Fl_Widget::x() const
//short Fl_Widget::y() const
int pxx=120;// position of the space.
int pyy=120;
void make_window()
{
Fl_Window* win= new Fl_Window( 500,400, "Buttons everywhere" );
win->begin();
const int arraySize = 16;



const char * v[]={"1","2","3","4","5","6","7","8" ,"9","10","11","12" ,"13","14","15"," " };

//int pointsx[arraySize][arraySize] ={{0,40,80,120},

int pointsx[arraySize]={0,40,80,120,0,40,80,120,0,40,80,120,0,40,80,120};
int pointsy[arraySize]={0,0,0,0,40,40,40,40,80,80,80,80,120,120,120,120};





for (int j = 0; j < arraySize; j++){

Fl_Button* but = new Fl_Button( pointsx[j], pointsy[j], 40, 40, v[j] );
//elements[i][j]
but -> callback( ( Fl_Callback* ) button_cb );

}
win->end();
//but -> callback( ( Fl_Callback* ) button_cb );
win->show();
}

void button_cb( Fl_Widget* obj , void* )
{
int positionx=x();
int positiony=y()
obj->resize(pxx,pyy,40,40)
obj->label( "OFF" );
pxx=positionx;
pyy=positiony;
//obj->resize( 0,0,40,40 );
obj->redraw();
}

int main() //int argc, char* argv[] )
{
make_window();
return Fl::run();
}

Put the code you need help with here
void button_cb( Fl_Widget* obj , void* )
{
int positionx=x();
int positiony=y()
obj->resize(pxx,pyy,40,40)
obj->label( "OFF" );
pxx=positionx;
pyy=positiony;
//obj->resize( 0,0,40,40 );
obj->redraw();
}
Topic archived. No new replies allowed.