GIDForums

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-Apr-2008, 09:06
shiva_crazy02 shiva_crazy02 is offline
New Member
 
Join Date: Apr 2008
Posts: 12
shiva_crazy02 is on a distinguished road
Thumbs up

IP settings


Dear all
I want to setup IP Address on fltk 1.0.x.
It should look like
IP.................
name server.........
gateway.............
clearbutton save button exit button





I did some coding but it is not working (without save option as I don't know how to do it.
also clear is working for gateway button only.here is code :-

CPP / C++ / C Code:
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#define XBOX 10
#define YBOX 10





class Application
{

                                                                 // All the fltk widgets here, so each callback can access them   
     Fl_Window        *win;
     Fl_Input         *input1, *input2, *input3,*input4;
     Fl_Button        *savebut, *clearbut, *exitbut;

     // Button callback snapshots current contents of input widget to display
/*     static void SaveBut_CB(Fl_Widget*, void* data)
     {
       Application *o = (Application*)data;
       o->disp->SetText(o->input->value(), o->Xinput->value(), o->Yinput->value());
       o->disp->redraw(); //draw the new string and it position in our widget
     }*/

     static void ClearBut_CB(Fl_Widget*, void* data) //Refresh all input fields
     {
 Application *o = (Application*)data;
       o->input1->value(0);
       o->input2->value(0);
       o->input3->value(0);
       o->input4->value(0);
     }

     static void ExitBut_CB(Fl_Widget*, void*)
     {
       exit(0);
     }

  public:

     Application(int w, int h, const char *l, int argc, char *argv[])
     {

       win    = new Fl_Window(w,h,l);
       input1 = new Fl_Input(60,30,300,25, "IP Address");
       input2 = new Fl_Input(60,70,300,25, "Net Mask");
       input3 = new Fl_Input(60,110,300,25, "Gateway");
       input4 = new Fl_Input(60,150,300,25, "Name server");
       savebut = new Fl_Button(200,300,50,30, "Save");
       clearbut = new Fl_Button(50,300,50,30, "Clear");
       exitbut = new Fl_Button(350,300,50,30, "Exit");

                                                 //Callback functions
/*     savebut->callback(SaveBut_CB,this);*/
       clearbut->callback(ClearBut_CB, this);
       exitbut->callback(ExitBut_CB);
       win->show(argc, argv);
     }
};
int main (int argc, char *argv[])
{
     Application(600,600, "IP Settings", argc, argv); //Create our application.
     return Fl::run();
}


please help me..
I am very confused ....
thanks in advance
shiva kumar
Last edited by LuciWiz : 16-Apr-2008 at 14:51. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 17-Apr-2008, 01:16
shiva_crazy02 shiva_crazy02 is offline
New Member
 
Join Date: Apr 2008
Posts: 12
shiva_crazy02 is on a distinguished road

Re: IP settings


Dear all,
I have solved the problem :- here is code
CPP / C++ / C Code:
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Box.H>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include<cstdlib>





class Application
{

                                                                 // All the fltk widgets here, so each callback can access them    
     Fl_Window        *win;
     Fl_Input         *input1, *input2, *input3,*input4;
     Fl_Button        *savebut, *clearbut, *exitbut;

                                                                // Button callback  current contents of input widget to save
     static void SaveBut_CB(Fl_Widget*, void* data)
     {
       Application *o = (Application*)data;
       const char *ptrl1=(const char*)(o->input1->label());
       const char *ptrl2=(const char*)(o->input2->label());
       const char *ptrl3=(const char*)(o->input3->label());
       const char *ptrl4=(const char*)(o->input4->label());
       const char *ptrv1=(const char*)(o->input1->value());
       const char *ptrv2=(const char*)(o->input2->value());
       const char *ptrv3=(const char*)(o->input3->value());
       const char *ptrv4=(const char*)(o->input4->value());
       FILE *fp ;
 if( fp = fopen("/home/flnx/test/ipsettings.doc","a")){
        fprintf(fp,"\n");
        fprintf(fp,"\n");
        fprintf(fp,"*********************************************************************");
        fprintf(fp,"\n");
        fprintf(fp,"\n");
        fprintf(fp,ptrl1);
        fprintf(fp,"\t");
        fprintf(fp,ptrv1);
        fprintf(fp,"\n");
        fprintf(fp,"\n");
        fprintf(fp,"\n");
        fprintf(fp,ptrl2);
        fprintf(fp,"\t");
        fprintf(fp,ptrv2);
        fprintf(fp,"\n");
        fprintf(fp,"\n");
        fprintf(fp,"\n");
        fprintf(fp,ptrl3);
        fprintf(fp,"\t");
        fprintf(fp,ptrv3);
        fprintf(fp,"\n");
        fprintf(fp,"\n");
        fprintf(fp,"\n");
        fprintf(fp,ptrl4);
        fprintf(fp,"\t");
        fprintf(fp,ptrv4);
        }
   else {
        printf("error in file opening");
        }

     }
  static void ClearBut_CB(Fl_Widget*, void* data) //Refresh all input fields
     {
       Application *o = (Application*)data;
       o->input1->value(0);
       o->input2->value(0);
       o->input3->value(0);
       o->input4->value(0);
     }

     static void ExitBut_CB(Fl_Widget*, void*)
     {
       exit(0);
     }

  public:

     Application(int w, int h, const char *l, int argc, char *argv[])
     {

       win    = new Fl_Window(w,h,l);
       input1 = new Fl_Input(70,30,300,25, "IP Address");
       input2 = new Fl_Input(70,70,300,25, "Net Mask");
       input3 = new Fl_Input(70,110,300,25, "Gateway");
       input4 = new Fl_Input(70,150,300,25, "Name server");
       savebut = new Fl_Button(200,300,50,30, "Save");
       clearbut = new Fl_Button(50,300,50,30, "Clear");
       exitbut = new Fl_Button(350,300,50,30, "Exit");
                                              //Callback functions
       savebut->callback(SaveBut_CB,this);
       clearbut->callback(ClearBut_CB,this);
       exitbut->callback(ExitBut_CB);
       win->show(argc, argv);
     }
};

int main (int argc, char *argv[])
{
     Application(600,600, "IP Settings", argc, argv); //Create our application.
     return Fl::run();
}
Last edited by cable_guy_67 : 17-Apr-2008 at 03:13. Reason: Please surround your C++ code with [cpp] your code [/cpp]
 

Recent GIDBlogGoing to Iraq by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
May I have help with problems about Project settings Dominic MS Visual C++ / MFC Forum 0 09-Nov-2006 00:54
Changing Network settings (TCP/IP) with MFC or WinAPI RobertS. MS Visual C++ / MFC Forum 0 15-Apr-2006 10:14
proxy settings kai85 Open Discussion Forum 1 14-Apr-2005 03:03
Need PHP settings like ipower shared servers druman MySQL / PHP Forum 1 11-Feb-2005 08:13
Outlook Express - Customize Settings WinME bubitutor Open Discussion Forum 1 02-Jul-2004 12:23

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 12:48.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.