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 23-May-2005, 11:02
iga iga is offline
New Member
 
Join Date: May 2005
Posts: 8
iga is on a distinguished road

Fluid + class derived from Fl_Window


Hi, first of all sorry for my poor english

I'm trying to build a gui interface with fluid (v 1.1.4). It's a new class that is derived from Fl_Window (I mean: class myWindow : public Fl_Window).

What i have done:
1- declaration (include Fl_Window)
2- class (myWindow and subclass Fl_Window)
3- method (constructor)
4- code

That's all right. Now the problem is that I want fluid to build that window graphically. But fluid doesn't show me the window to put widgets on it. Only if I add a new window, but that is not what I want (I don't want to have two windows).

I hope I have explained me well and also that there's a way to do this Thank you!

IGA
  #2  
Old 23-May-2005, 12:51
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough
Hello and Welcome to GIDForums IGA.

A few things. Is there a particular reason you are still using 1.1.4? If you aren't locked in (say for work or school) I would really recomend upgrading to 1.1.7. While not quirk free it is very solid and can be found at fltk.org or fltk.net where I think they have very up to date devpacks.

As far as your fluid question. I know exactly what you are talking about. It really is not as big a deal as it sounds since groups and windows are so closely related. Here is an example fluid project that helped me get a grip on this same thing with fluid.

Fluid is a bit restrictive in some ways but this code, which may have been originally posted by Greg E in the fltk newsgroups, should answer your question.

Code:
# data file for the Fltk User Interface Designer (fluid) version 1.0107 header_name {.h} code_name {.cxx} decl {\#include <FL/Fl_Group.H>} {public } class Foo {open : {public Fl_Group} } { Function {Foo(int X, int Y, int W, int H): Fl_Group(X,Y,W,H)} {open } { Fl_Window group {open xywh {288 404 104 100} type Double color 9 code0 {o->resize(this->x(),this->y(),this->w(),this->h());} class Fl_Group visible } { Fl_Button {} { label button xywh {25 25 53 25} } } } } Function {} {open } { Fl_Window mainwin {open xywh {459 362 309 246} type Double box UP_BOX code0 {mainwin->show();} visible } { Fl_Group {} {open selected xywh {12 15 284 225} class Foo } {} } }

The latest version of fluid has many updates as well as a better class builder and a sytax highlighter in the editor so if you can get updated. If you have svn you can grab the latest source and build for your platform.

Well, I hope this is what you were looking for.
Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #3  
Old 23-May-2005, 14:09
iga iga is offline
New Member
 
Join Date: May 2005
Posts: 8
iga is on a distinguished road
Yes, that is what I was looking for, thank you.

But I'm only half convinced, because after all I'm having two Fl_Groups... Well, I hope next fluid releases will improve that...

I'm a Debian gnu/linux user. So I just type apt-get fltk and I've fltk libraries and fluid running I was only a bit lazy. But if new versions have syntax highlighting, then I will upgrade, sure.

You said version 1.1.7? That version isn't on fltk.org (fltk.net is now down). Should I install svn and get that version? Or can I have syntax highlighting with 1.1.6? Well, I will try

Thank you again,

IGA
  #4  
Old 24-May-2005, 09:42
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough
Quote:
Originally Posted by iga
Yes, that is what I was looking for, thank you.

But I'm only half convinced, because after all I'm having two Fl_Groups... Well, I hope next fluid releases will improve that...
Yes, but it is the smaller of the Widgets to use as a base and from what I know it is the best way to do what you want. The only other thing I have to add is you may want to invert the resize behavior to maintain your class groups size using ->parent() then resizing the placeholder group.
Quote:
Originally Posted by iga
I'm a Debian gnu/linux user. So I just type apt-get fltk and I've fltk libraries and fluid running I was only a bit lazy. But if new versions have syntax highlighting, then I will upgrade, sure.

You said version 1.1.7? That version isn't on fltk.org (fltk.net is now down). Should I install svn and get that version? Or can I have syntax highlighting with 1.1.6? Well, I will try
IGA

Do'h, 1.1.6 is the latest released version. The 1.1.7 in located in the subversion repo. I could have been a little clearer on that. If you have svn by all means checkout and build the library from there. It is IMHO, the way to go.

Is there anything else you find disturbing/enlightening while using fluid? I have a laundry list started and have been working on a different design to fluid. It will eventually start showing up in the /Applications line at fltk.org but as I am still doing core design nothing is avalable yet. I would love to hear from any Fluid UI Builder users out there. What you like and what you dislike. I use fluid for almost everything I do with FLTK and really like the tool.

I really should just start a thread for that and get my wants/desires list together but for now, feel free to let me know how you use fluid and things that would make it easier to do what you want.

Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #5  
Old 25-May-2005, 10:14
iga iga is offline
New Member
 
Join Date: May 2005
Posts: 8
iga is on a distinguished road
Hi again.

Now I'm using version 1.1.7 (get it with svn). It has sintax highlighting and also the undo command!

I was building the project like you said. But just now I have discovered a new thing: New->Code->Widget Class... And I think it's exactly what I was looking for! It creates automatically the constructors and put all the resizes and customization of the window in it.

Well, now I have to rebuild my project

I'm not an expert fluid user (nor an expert fltk user), but I can contribute to your list two things. First, very usefull the shell command, but the errors aren't shown in the shell window that opens. And second, when a callback is created, the inline function (i.e. cb_Open_i) isn't created as 'inline'.

I hope you understand my poor english

IGA
  #6  
Old 25-May-2005, 11:28
iga iga is offline
New Member
 
Join Date: May 2005
Posts: 8
iga is on a distinguished road
I have done a quick test and I think it has a bug :_(

What I have:
1 // don't need to include Fl_Window, Widget class does it automatically
2 Widget Class (in c++ tab: class Fl_Window and name myWindow)
3 // don't need any constructors, widget class does it for me
4 Menu_Bar
5 Submenu
6 MenuItem

And when I put some code into the menuitem's callback and try to write code, then it gives me a segmentation fault. Well, it must be a bug...

What should I do now? Should I tell this the fltk team?

IGA
  #7  
Old 25-May-2005, 11:50
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough
Before you jump on the bug bandwagon post your code here and we can go over it. Many times it is some silly simple thing that fluid assumes you knew you should do. Unfortunately sometimes it is a few tabs over and a layer or two deep.

Glad you got up to speed with the svn version though. You really will be happier for it. Post your code using the markup tags:

[c++]
// your code here
[/c++]

or the generic (no highlighting) code markup for the fluid project file by using code not c++.

I will take a look as many times fluids little quirks cause the problem.

Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #8  
Old 25-May-2005, 13:56
iga iga is offline
New Member
 
Join Date: May 2005
Posts: 8
iga is on a distinguished road
Ok, but I have done the same before using the widget class and it works, so I thought it was a bug...

Here it is:
Code:
# data file for the Fltk User Interface Designer (fluid) version 1.0107 i18n_type 1 i18n_include <libintl.h> i18n_function gettext header_name {.hh} code_name {.cc} decl {\#include "AreaFile.hh"} {public } widget_class MainWindow {open xywh {316 49 700 525} type Double class Fl_Window visible } { Fl_Menu_Bar {} {open private xywh {5 5 700 20} } { Submenu {} { label {&Fichero} open private xywh {10 10 100 20} labelsize 12 } { MenuItem {} { label {&Nuevo...} callback {//sdfg} selected private xywh {10 10 100 20} labelsize 12 } } } }
Fluid code (callback is only a comment)


CPP / C++ / C Code:
// generated by Fast Light User Interface Designer (fluid) version 1.0107

#ifndef MainWindow_hh
#define MainWindow_hh
#include <FL/Fl.H>
#include "AreaFile.hh"
#include <FL/Fl_Window.H>
#include <FL/Fl_Menu_Bar.H>

class MainWindow : public Fl_Window {
  void _MainWindow();
public:
  MainWindow(int X, int Y, int W, int H, const char *L = 0);
  MainWindow(int W, int H, const char *L = 0);
  static Fl_Menu_Item menu_[];
};
#endif



// generated by Fast Light User Interface Designer (fluid) version 1.0107

#include <libintl.h>
#include "MainWindow.hh"

Fl_Menu_Item MainWindow::menu_[] = {
 {gettext("&Fichero"), 0,  0, 0, 64, FL_NORMAL_LABEL, 0, 12, 56},
 {gettext("&Nuevo..."), 0,  0, 0, 0, FL_NORMAL_LABEL, 0, 12, 56},
 {0,0,0,0,0,0,0,0,0},
 {0,0,0,0,0,0,0,0,0}
};
MainWindow::MainWindow(int X, int Y, int W, int H, const char *L)
  : Fl_Window(X, Y, W, H, L) {
  _MainWindow();
}

MainWindow::MainWindow(int W, int H, const char *L)
  : Fl_Window(0, 0, W, H, L) {
  clear_flag(16);
  _MainWindow();
}

void MainWindow::_MainWindow() {
  MainWindow *w = this;
  MainWindow *o = this;
o->box(FL_FLAT_BOX);
o->color(FL_BACKGROUND_COLOR);
o->selection_color(FL_BACKGROUND_COLOR);
o->labeltype(FL_NO_LABEL);
o->labelfont(0);
o->labelsize(14);
o->labelcolor(FL_BLACK);
o->align(FL_ALIGN_TOP);
o->when(FL_WHEN_RELEASE);
{ Fl_Menu_Bar* o = new Fl_Menu_Bar(5, 5, 700, 20);
  o->menu(menu_);
}
end();
}
Code generated by fluid _without_ the callback


Hope you can help me... again

IGA
  #9  
Old 25-May-2005, 15:14
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Nescopeck, PA
Posts: 1,109
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough
Well that didn't work out very well for me. I can't write the code from your fluid project file (fluid crashes horribly) most likely to do with the internationalization stuff. I can almost compile your examples from your outputted code though. There is no AreaFile.hh though and I get errors because of the gettext stuff in the menu's. I'll do a little reading tonight and see if I can't come up with something. I should be able to modify your code enough to compile it though.

Disclaimer, I know very little about cross platform stuff as it is but the cross language support is, well, like reading a foreign tongue.

I'll let you know how I make out. If you haven't already do a search of the fltk newsgroups and see if you can't find any relevent threads or articles. There may be a problem, I just want to do a little digging first.

Mark
__________________
"Opportunity is missed by most people because it comes dressed in overalls and looks like work."
--Thomas Alva Edison
"Those who would give up essential liberty to purchase a little temporary safety, deserve neither liberty nor safety."
--Benjamin Franklin
"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs
  #10  
Old 25-May-2005, 16:02
iga iga is offline
New Member
 
Join Date: May 2005
Posts: 8
iga is on a distinguished road
I have found the same problem with another widget:

http://www.fltk.org/str.php?L805

But it seems to be fixed... Perhaps it's not in the new widget_class...

I think it has only to do with the callback code, because in my computer it crashes only when I put some code and it's ok when I leave it blank.

IGA
 
 

Recent GIDBlogMeeting the populace 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
FLTK && fluid In Motion cable_guy_67 FLTK Forum 4 20-Mar-2008 03:52
GIMcontacts - a gim fltk fluid venture cable_guy_67 FLTK Forum 0 14-Feb-2005 14:18
Error C2146: syntax error : missing ',' before identifier 'C4' mattchew008 C++ Forum 2 19-Dec-2004 06:06
Help! Some basal questions about MFC xutingnjupt MS Visual C++ / MFC Forum 1 05-Dec-2004 03:38

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

All times are GMT -6. The time now is 11:27.


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