Fl_Buttons char names

closed account (91q28vqX)
Howdy I am trying to create a series of buttons in a window. I am having problems initializing a set of char to use as names for the buttons. Every time I try to compile it produces this error.
error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive]
Any suggestions or better way to make these buttons.
The eventual main goal of this program is for a button when pressed to change places with the button labeled 0 in the program.


#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>
using namespace std;

void button_cb( Fl_Widget*, void* );

void make_window()
{
Fl_Window* win= new Fl_Window( 500,400, "Buttons everywhere" );
win->begin();
const int arraySize = 4;
char elements[arraySize][arraySize] = { { '1','2','3','4' },
{ '5','6','7','8' },
{ '9','A','B','C' },
{ 'D','E','0','F' } };

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

for (int i = 0; i < arraySize; i++) {
for (int j = 0; j < arraySize; j++){
Fl_Button* but = new Fl_Button( pointsx[i][j], pointsy[i][j], 40, 40, (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* )
{
obj->label( "OFF" );

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.
[/code]


Last edited on
closed account (SECMoG1T)
hello Michmech: the function Fl_Button 5th argument -> "label" should be const char*, simply a c-style string not a character.

1
2
3
4
5
Fl_Button::Fl_Button(int x, int y, int w, int h, const char *label = 0)//it's declaration

//try this
Fl_Button* but = new Fl_Button( pointsx[i][j], pointsy[i][j], 40, 40, "my label" );
closed account (91q28vqX)
Thank you. very helpful.
Topic archived. No new replies allowed.