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 18-Jan-2007, 17:47
morrowsend morrowsend is offline
New Member
 
Join Date: Jan 2007
Posts: 7
morrowsend is on a distinguished road

Menu size using FLUID


Hello all,
I'm just starting with FLTK, been doing C++ for a couple years now, but I'm no expert.

I'm trying out FLUID and I seem to have a problem. I've made a normal window, size 915px by 589px, then added a menu bar with the submenu "File". I want the window resizable, but not the menu bar, so I ticked the appropriate boxes in the GUI tabs of the properties windows of the window itself and the menu bar. I wanted the menu bar 20px tall, always.

The problem occurs when I compile the program and test it. In the window I have made, everything looks perfect, except when I resize the window. If I make it smaller, the menu bar gets thinner, like down to what looks like 5px or so. When I make the window full sized, the menu bar is like 40px tall. The text of the "File" submenu stays the same size, but recenters itself in the new menu bar size.

I played around with it, and when I check the box for the menu bar to be resizable, it can go from 5px to like 100px when the window resized... so I am aware of the difference it makes.

I am using the Quincy 2005 IDE to compile everything, and it works great! It has examples included with the IDE, so I ran one for a simple text editor. The menu bar on that program stays the same size all the time. Comparing at the code, that program seems to have less "stuff" involved in the submenus.

Am I missing something, or is this just a problem I have to live with?

Thanx,
Adam
  #2  
Old 19-Jan-2007, 04: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

Re: menu size using FLUID


Hello and Welcome Adam.

Are you using 1.1.x or 2.0? I know I have an example for 1.1 around here somewhere. I'll see if I can't find it for you.

The trick is to constrain your resizing using an invisible box. I'll post something this evening when I get a chance.

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 19-Jan-2007, 20:22
morrowsend morrowsend is offline
New Member
 
Join Date: Jan 2007
Posts: 7
morrowsend is on a distinguished road

Re: menu size using FLUID


Hello,
I'm using FLUID version 1.1.7

thanx,
Adam
  #4  
Old 19-Jan-2007, 22:26
yondalf yondalf is offline
New Member
 
Join Date: Jan 2007
Posts: 1
yondalf is on a distinguished road

Re: menu size using FLUID


Do *not* click resizable on the window. Instead click resizable on one of the widgets in the window (directly below the window in the widget tree).

A tutorial:

Make a window and a menu bar (with a File entry), as usual.

Make a button in the centre of the window, and check Resizable for the button.

Run it. You should see that the window is resizable, and the button resizes according to the window size.
  #5  
Old 20-Jan-2007, 05:04
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

Re: menu size using FLUID


I knew there was an example around here somewhere.

The last reply in this thread has a fluid file with an example of what I'm talking about. The menubar will resize horizontally but not vertically. Some of the image button bins won't resize at all while others will.

Take a look to see if it helps with your understanding of resizing and constraining resizing.

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
  #6  
Old 26-Jan-2007, 09:30
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

Re: menu size using FLUID


Same example, stripped down a bit...

compiled with:
g++ -Wall menu_size2.cxx `fltk-config --cxxflags --ldflags --use-images` -s -o MenuSize

menu_size2.fld
Code:
// generated by Fast Light User Interface Designer (fluid) version 1.0108 #include "menu_size2.h" Fl_Menu_Item GIMapp::menu_[] = { {"file", 0, 0, 0, 64, FL_NORMAL_LABEL, 0, 14, 0}, {0,0,0,0,0,0,0,0,0}, {"edit", 0, 0, 0, 64, FL_NORMAL_LABEL, 0, 14, 0}, {0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0} }; GIMapp::GIMapp() { { main_win = new Fl_Double_Window(400, 103); main_win->user_data((void*)(this)); { Fl_Box* o = new Fl_Box(0, 20, 180, 60); o->labeltype(FL_NO_LABEL); o->hide(); Fl_Group::current()->resizable(o); } // Fl_Box* o { Fl_Group* o = new Fl_Group(0, 0, 400, 20); o->box(FL_THIN_UP_BOX); { menu_resize = new Fl_Box(0, 0, 220, 20); menu_resize->labeltype(FL_NO_LABEL); menu_resize->hide(); Fl_Group::current()->resizable(menu_resize); } // Fl_Box* menu_resize { Fl_Menu_Bar* o = new Fl_Menu_Bar(0, 0, 400, 20); o->menu(menu_); } // Fl_Menu_Bar* o o->end(); } // Fl_Group* o { Fl_Group* o = new Fl_Group(0, 80, 400, 21); o->box(FL_BORDER_BOX); { output_resize = new Fl_Box(220, 81, 180, 20); output_resize->labeltype(FL_NO_LABEL); output_resize->hide(); Fl_Group::current()->resizable(output_resize); } // Fl_Box* output_resize { modified_yn = new Fl_Output(0, 81, 30, 20); modified_yn->color(FL_LIGHT1); modified_yn->labeltype(FL_NO_LABEL); modified_yn->align(FL_ALIGN_CENTER); } // Fl_Output* modified_yn { current_tag = new Fl_Output(30, 81, 60, 20); current_tag->color(FL_LIGHT1); current_tag->labeltype(FL_NO_LABEL); current_tag->align(FL_ALIGN_CENTER); } // Fl_Output* current_tag { bool_openclose = new Fl_Output(90, 81, 30, 20); bool_openclose->color(FL_LIGHT1); bool_openclose->labeltype(FL_NO_LABEL); bool_openclose->align(FL_ALIGN_CENTER); } // Fl_Output* bool_openclose { thread_id = new Fl_Output(120, 81, 100, 20); thread_id->color(FL_LIGHT1); thread_id->labeltype(FL_NO_LABEL); thread_id->align(FL_ALIGN_CENTER); } // Fl_Output* thread_id { working_filename = new Fl_Output(220, 81, 180, 20); working_filename->color(FL_LIGHT1); working_filename->labeltype(FL_NO_LABEL); working_filename->align(FL_ALIGN_CENTER); } // Fl_Output* working_filename o->end(); } // Fl_Group* o main_win->end(); } // Fl_Double_Window* main_win } int main(int argc, char **argv) { GIMapp mainwin; mainwin.main_win->show(); return Fl::run(); }

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
  #7  
Old 26-Jan-2007, 11:35
morrowsend morrowsend is offline
New Member
 
Join Date: Jan 2007
Posts: 7
morrowsend is on a distinguished road

Re: menu size using FLUID


Thank you for all your help. I'm still learning a lot about FLUID. I really like it a lot! I'd been afraid of GUI designing because i didn't understand classes that much, but i am slowly learning (mostly by trial and error...) So far in my program, the menu bar is acting the same, however, it isn't very noticeable, unless you make the windows insanely small, and only slightly noticeable if the window is maximized.

I think its just my inexperience so far that's holding me back, I'm planning on leaving a few problems that i can't figure out yet until I port the rest of my program (originally written using BGI with the CS1300 package... search google for that one... It was for some college's class or something.)

At the moment, I am trying to figure out how to get the thing to open a text file with a series of points in it, and draw those points on the window. I've written a program that can draw it, and i've written a program that can let me select a file (won't actually open it tho...) so i'll be meshing these two together for a bit.

Thanks again for all your help. Once I learn more about it tho, i will be sure to learn from your example!

Adam
  #8  
Old 27-Jan-2007, 11:38
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

Re: menu size using FLUID


Don't hesitate to post any code to get input about. It is preferred if you post a working example that shows your problem. That way others might compile it and give some feedback. When posting code, please use [cpp] your code [/cpp] for regular code or just [code] your code [/code] for fluid files/output messages.

Using Fl_File_Browser or Fl_File_Chooser should get you going.

As for my example, its really not that complex. There are boxes that control the resizing behavior named either just "Box" or some name _resize.

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
  #9  
Old 30-Jan-2007, 13:16
morrowsend morrowsend is offline
New Member
 
Join Date: Jan 2007
Posts: 7
morrowsend is on a distinguished road

Re: menu size using FLUID


Ok, here's a stripped down version of my code. basically i want a nice GUI, then when you go to File=> open, and open a file, it takes points from the file (format shown below) and draws those points. The code below won't run right, again, its just a stripped down version.

Format for "input.plot" input file

Format:
NL = "new line" start a new line
OL = "old line" just move from the previous point to the next point

example:
NL x,y;
OL x2,y2;

Code:
NL 50,25; OL 37,42; OL 12,80; NL 27,62; OL 76,30;


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

#include "open2.h"
#include<fstream.h>
#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include <FL/Fl_File_Chooser.H>
#include <FL/fl_draw.H>
#define usleep(v) Sleep(v/1000);
static bool loaded;
static char *filename;
static char buffer[256];
static char buffer3[256];
static char buffer2[256];
static char buffer4[256];
static char namebuffer[256];
static char filename1[256];
static char buffer5[256];
static char filename2[256];
static char buffer9[256];
static char genbuffer[10];
static int x2;
static int y2;
int m=0;
int j=0;

void load_file(char *newfile) {

					//get name of project from "File==> open
  filename[0] = '\0';           		//make this string appendable
  strcat ( filename, namebuffer );   	//copy project name into filename string

class Drawing :public Fl_Widget
{
		void draw() 
	{
{
fl_color(FL_BLACK);
 ifstream infile;	   	   	   	   	   //create an instance of infile
	infile.open(filename);	   	   	   //open file

	if (infile.fail())					//if file open fail, display error  notice
  { 
    
	cout<<"                Error opening file                                          "<<endl;//print to screen
	cout<<"Please close program and start over.                                 "<<endl;//print to screen

 	}		

     
    /*******************************************************************************************
	*						pic drawer									*
	*				Written By: Adam Harris 					*
*****************************************************************************************/
		
while(!infile.eof()) 				//while not the end of file, do the following
{
infile.getline (buffer,40);			//read from file
m=2;								//set m=2 so it will skip the NL and OL commands
j=0; 								// it will start copying at the first position
while((j<39) && (buffer[m]!=',') ) 	// while its not the last position, do the follwoing
{
buffer2[j]=buffer[m];				//load bufer pos.m into buffer2 pos.j
j++;								//add 1 to j
m++;		        				//add 1 to m
}									//end of small while loop
j=0;
m++;
while(j<39)							// while its not the last position, do the follwoing
{
buffer3[j]=buffer[m];				//load bufer pos.m into buffer3 pos.j
j++;								//add 1 to j
m++;		         				//add 1 to m
}									//end small while loop	
if buffer[0]=='O'// draw command... "if Old_line
	{	
		if(n==0)					//and PD instance is 0
		{
		x5 = atof( buffer2 );	   	   //turn buffer2 from string to number
		y5 = atof(buffer3);	 	 	 //turn buffer3 from string to number
		x5 = (x5*.08749)+125;	  	  //convert from PLU to pixels per inch and shift right
		y5 = (-y5*.08749)+500;	  	  //flip convert from PLU to pixels per inch and shift right
		x2 = (int) x5;	 	 	 	 //turn double into int
		y2 = (int) y5;	 	 	 	 //turn double into int
         fl_color(FL_BLACK);
		 fl_vertex(x2,y2);
		}
		}
	}
	if(buffer[0]=='N')				//If new_line command
	{
	n+=1;							//Set new_line instance
		 fl_begin_line();		//begin new line
          fl_color(FL_BLACK);	//black
		  fl_vertex(x2,y2);		//at this point
	}
}	
infile.close();  					//close file  
infile.clear(); 					//clears infile path
    
    
   //////////////////////////////////////////////////////////////////////// 
    
    
    }}
public:
  Drawing(int X,int Y,int W,int H) :Fl_Widget(X,Y,W,H) 
  {
   align(FL_ALIGN_TOP);
   box(FL_FLAT_BOX);
   color(FL_WHITE);
  }

};
}

void quit_cb() {
  exit(0);
}

void open_cb() {
  char *newfile = fl_file_chooser("Open File?", "*.plot", filename);
  if (newfile != NULL) load_file(newfile);
}

static void cb_Open(Fl_Menu_*, void*) {
  open_cb();
}

static void cb_Quit(Fl_Menu_*, void*) {
  quit_cb();
}

Fl_Menu_Item menu_[] = {
 {"File", 0,  0, 0, 64, FL_NORMAL_LABEL, 0, 14, 0},
 {"Open", 0,  (Fl_Callback*)cb_Open, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
 {"Quit", 0,  (Fl_Callback*)cb_Quit, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
 {0,0,0,0,0,0,0,0,0},
 {0,0,0,0,0,0,0,0,0}
};

int main(int argc, char **argv) {
  Fl_Double_Window* w;
  { Fl_Double_Window* o = new Fl_Double_Window(800, 600, "SheekGeek PCB Package");
    w = o;
    { Fl_Menu_Bar* o = new Fl_Menu_Bar(0, 0, 800, 30);
      o->menu(menu_);
    }
    o->end();
    o->resizable(o);
  }
  if (argc > 1) load_file(argv[1]);
  w->show(argc, argv);
  return Fl::run();
}
 

Ok, that's all I got. When I get to the point that i assume its importing the file, i get an error and the program has to close. Using just the drawing algorithm, I've gotten it to work, but adding the open file thing is giving me problems.

Even when I make it automatically load a file so you don't select the file to open with file=> open, (just to skip the file selection process) it gives me the error.


Any help would be appreciated.
Thanx, Adam
  #10  
Old 31-Jan-2007, 06:57
bluekid bluekid is offline
Junior Member
 
Join Date: Apr 2006
Posts: 32
bluekid will become famous soon enough

Re: menu size using FLUID


i look your code quickly

CPP / C++ / C Code:
  filename[0] = '\0';           		
  strcat ( filename, namebuffer );
where is the memory allocation ?

extending a new widget within the callback ?
read this documentation
http://www.fltk.org/documentation.ph...ml#subclassing
look this codes
http://www.geocities.com/rferdiez/en/fltk/#fl_canvas
http://www.kiwacan.co.nz/fltk/Fl_PlotXY.html
 
 

Recent GIDBlogToyota - 2008 August Promotion by Nihal

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
Need Help With Recursive Functions jonas12rena C Programming Language 1 31-Jul-2006 11:12
Shapes Functions Version 2 - Arrays! Cecil C Programming Language 1 09-Jul-2006 20:39
GIMcontacts - a gim fltk fluid venture cable_guy_67 FLTK Forum 0 14-Feb-2005 14:18
Having a problem Chuckles Computer Hardware Forum 19 13-Sep-2004 12:17

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

All times are GMT -6. The time now is 18:38.


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