Re: [fltk.general] how to select one line after browser widgetcreate

2012-04-25 Thread leowang
> On 04/25/12 07:10, leowang wrote:
> >>> I found that after the browser widget created, it is focused in the first
> >>> line, but the first line does not highlight, how to set it to highlight, I
> >>> tryed select(0, true), but has no effect.
> >>
> >> You might find that browser lines are numbered from 1, not from 0, IIRC, 
> >> th=
> >> ough you should check the docs in case I am remembering incorrectly.
> >
> > I have note it , but even I call select(1,  true), it still has
> > no highlight in the first line.
>
>   Works for me:
>
> #include 
> #include 
> #include 
> #include 
> void select_cb(Fl_Widget*w,void*data) {
> Fl_Browser *b = (Fl_Browser*)data;
> if ( w->label()[0] == 'O' ) { b->select(1,1); } // one
> if ( w->label()[0] == 'T' ) { b->select(2,1); } // two
> }
> int main() {
> Fl_Window win(300,450);
> Fl_Browser brow(10,10,300-20,450-60);
> brow.add("one");
> brow.add("two");
> brow.add("three");
> brow.add("four");
> Fl_Button b1(10 ,450-30,140,25,"One Select");
> b1.callback(select_cb, (void*)&brow);
> Fl_Button b2(160,450-30,140,25,"Two Select");
> b2.callback(select_cb, (void*)&brow);
> win.end();
> win.show();
> return(Fl::run());
> }

Thanks, now it also works for me, I have a mistake when I write code, it should 
call select(1, true) after add() function, but I called it before add item in 
browser.

Thanks all.

Best regards,
Leo
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] callback with lambda expression

2012-04-25 Thread testalucida
thank you.
Unfortunately vc10 is the one and only enterprise-wide used compiler so I 
really have no chance to use gcc at work.
So I'll follow your advice and try it like 1999 ;)

>
> On 25.04.2012, at 18:18, testalucida wrote:
>
> > Hi,
> >=20
> > this code:
> >=20
> > Fl_Button *pBtn =3D new Fl_Button(...);
> > pBtn->callback( [](Fl_Widget *w, void *u ) {printf(...);} );
> >=20
> > compiles fine with gcc but won't with vc10.
> > Error message says something like "can't convert lambda to =
> Fl_Callback*".
> >=20
> > Does anybody know the reason? Is there a way to use lambdas with FLTK =
> callbacks on Windows?
>
> Yes. The VC2010 compiler does not support local functions. One more =
> reason to use gcc on MSWindows. VC2010 uses an ancient single pass =
> concept and does not implement all the new standards, or if it does, it =
> diverges from the standard just enough to make life miserable. Try =
> writing C++ like it was 1999, and VC may understand you better.=
>

___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] callback with lambda expression

2012-04-25 Thread Matthias Melcher

On 25.04.2012, at 18:18, testalucida wrote:

> Hi,
> 
> this code:
> 
> Fl_Button *pBtn = new Fl_Button(...);
> pBtn->callback( [](Fl_Widget *w, void *u ) {printf(...);} );
> 
> compiles fine with gcc but won't with vc10.
> Error message says something like "can't convert lambda to Fl_Callback*".
> 
> Does anybody know the reason? Is there a way to use lambdas with FLTK 
> callbacks on Windows?

Yes. The VC2010 compiler does not support local functions. One more reason to 
use gcc on MSWindows. VC2010 uses an ancient single pass concept and does not 
implement all the new standards, or if it does, it diverges from the standard 
just enough to make life miserable. Try writing C++ like it was 1999, and VC 
may understand you better.
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to deactivate one line in browserwidgetin fltk1.3

2012-04-25 Thread Matthias Melcher

On 25.04.2012, at 15:52, MacArthur, Ian (SELEX GALILEO, UK) wrote:

>> I use the browser widget to display files, and the files are sorted by
>> name, it looks like follows:
>> 
>> a
>> a.txt
>> ab.txt
>> b.txt
>> c
>> ch.txt
>> 
>> so the lines which has index character should not be focused.
>> Now I have implement this function by modify Fl_Browser.cxx and
>> Fl_Browser_.cxx.
> 
> OK... would Fl_Tree not be a more natural container for that sort of thing 
> then, anyway?

You can also use a combination of groups and a widget hierarchy to create that 
effect:

To make a scrollable list, start with an Fl_Scroll. Inside the Fl_Scroll, put 
an Fl_Pack as the only child. Set the type to VERTICAL. Then generate an 
Fl_Toggle_button for every entry in you list. The Fl_Pack will keep the buttons 
neatly arranged, and keyboard navigation should work just fine, You now have 
full controll over every toggle button, including hide() or deactivate().

 - Matthias
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to select one line after browser widgetcreate

2012-04-25 Thread Greg Ercolano
On 04/25/12 07:10, leowang wrote:
>>> I found that after the browser widget created, it is focused in the first
>>> line, but the first line does not highlight, how to set it to highlight, I
>>> tryed select(0, true), but has no effect.
>>
>> You might find that browser lines are numbered from 1, not from 0, IIRC, th=
>> ough you should check the docs in case I am remembering incorrectly.
>
> I have note it , but even I call select(1,  true), it still has
> no highlight in the first line.

Works for me:

#include 
#include 
#include 
#include 
void select_cb(Fl_Widget*w,void*data) {
Fl_Browser *b = (Fl_Browser*)data;
if ( w->label()[0] == 'O' ) { b->select(1,1); } // one
if ( w->label()[0] == 'T' ) { b->select(2,1); } // two
}
int main() {
Fl_Window win(300,450);
Fl_Browser brow(10,10,300-20,450-60);
brow.add("one");
brow.add("two");
brow.add("three");
brow.add("four");
Fl_Button b1(10 ,450-30,140,25,"One Select");
b1.callback(select_cb, (void*)&brow);
Fl_Button b2(160,450-30,140,25,"Two Select");
b2.callback(select_cb, (void*)&brow);
win.end();
win.show();
return(Fl::run());
}
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


[fltk.general] callback with lambda expression

2012-04-25 Thread testalucida
Hi,

this code:

Fl_Button *pBtn = new Fl_Button(...);
pBtn->callback( [](Fl_Widget *w, void *u ) {printf(...);} );

compiles fine with gcc but won't with vc10.
Error message says something like "can't convert lambda to Fl_Callback*".

Does anybody know the reason? Is there a way to use lambdas with FLTK callbacks 
on Windows?

Thank you

testalucida
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to select one line after browser widgetcreate

2012-04-25 Thread leowang
>
> > I found that after the browser widget created, it is focused in the first
> > line, but the first line does not highlight, how to set it to highlight, I
> > tryed select(0, true), but has no effect.
> > =
>
> > Then is there some other API to make one line highlight after browser
> > widget create.
>
> You might find that browser lines are numbered from 1, not from 0, IIRC, th=
> ough you should check the docs in case I am remembering incorrectly.
>
>
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS=
> 14 3EL
> A company registered in England & Wales.  Company no. 02426132
> 
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> 
>

I have note it , but even I call select(1,  true), it still has no highlight in 
the first line.

Best regards,
Leo
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to select one line after browser widget create

2012-04-25 Thread MacArthur, Ian (SELEX GALILEO, UK)

> I found that after the browser widget created, it is focused in the first
> line, but the first line does not highlight, how to set it to highlight, I
> tryed select(0, true), but has no effect.
> 
> Then is there some other API to make one line highlight after browser
> widget create.

You might find that browser lines are numbered from 1, not from 0, IIRC, though 
you should check the docs in case I am remembering incorrectly.




SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to deactivate one line in browserwidgetin fltk1.3

2012-04-25 Thread MacArthur, Ian (SELEX GALILEO, UK)
> I use the browser widget to display files, and the files are sorted by
> name, it looks like follows:
> 
> a
> a.txt
> ab.txt
> b.txt
> c
> ch.txt
> 
> so the lines which has index character should not be focused.
> Now I have implement this function by modify Fl_Browser.cxx and
> Fl_Browser_.cxx.


OK... would Fl_Tree not be a more natural container for that sort of thing 
then, anyway?




SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


[fltk.general] how to select one line after browser widget create

2012-04-25 Thread leowang
Dear All,
I found that after the browser widget created, it is focused in the first line, 
but the first line does not highlight, how to set it to highlight, I tryed 
select(0, true), but has no effect.

Then is there some other API to make one line highlight after browser widget 
create.

Best regards,
Leo
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to deactivate one line in browserwidgetin fltk1.3

2012-04-25 Thread leowang
> > > > I have a browser widget in a window, there has some lines in this
> > browser,
> > > > press up/down key can select one by one, how can I set one line(or
> > item)
> > > > deactivate, then the focus will not move to this line.
> > >
> > > Sorry, I'm not understanding your question clearly enough to formulate
> > an a=3D
> > > nswer - can you expand the description to clarify this, please?
>
>
>
> > =
>
> > my meaning is I have a browser widget, suppose it has three lines(line 1,
> > line 2, line 3). the code is :
> > =
>
>
> > =
>
> > press up/down key can make the focus move switch from line 1 to line 3,
> > but I do not want the focus on the line2, then press up/down key can only
> > make the focus on  the line1 or line3.
> > =
>
> > Is that clearly to you?
>
> Ah, OK.
>
> I don't think Fl_Browser can support that; it is either all-active or all-d=
> eactive.
>
> You might be able to get the desired result using an Fl_Tree rather than an=
>  Fl_Browser as your container, but maybe setting the tree indent "off" so i=
> t looks a bit more browser-like.
>
> That will allow to activate / deactivate indidual items in the view...
>
> Any use?
>
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS=
> 14 3EL
> A company registered in England & Wales.  Company no. 02426132
> 
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> 
>

I use the browser widget to display files, and the files are sorted by name, it 
looks like follows:

a
a.txt
ab.txt
b.txt
c
ch.txt

so the lines which has index character should not be focused.
Now I have implement this function by modify Fl_Browser.cxx and Fl_Browser_.cxx.

Best regards,
Leo
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to deactivate one line in browser widgetin fltk1.3

2012-04-25 Thread MacArthur, Ian (SELEX GALILEO, UK)
> > > I have a browser widget in a window, there has some lines in this
> browser,
> > > press up/down key can select one by one, how can I set one line(or
> item)
> > > deactivate, then the focus will not move to this line.
> >
> > Sorry, I'm not understanding your question clearly enough to formulate
> an a=
> > nswer - can you expand the description to clarify this, please?



> 
> my meaning is I have a browser widget, suppose it has three lines(line 1,
> line 2, line 3). the code is :
> 

> 
> press up/down key can make the focus move switch from line 1 to line 3,
> but I do not want the focus on the line2, then press up/down key can only
> make the focus on  the line1 or line3.
> 
> Is that clearly to you?

Ah, OK.

I don't think Fl_Browser can support that; it is either all-active or 
all-deactive.

You might be able to get the desired result using an Fl_Tree rather than an 
Fl_Browser as your container, but maybe setting the tree indent "off" so it 
looks a bit more browser-like.

That will allow to activate / deactivate indidual items in the view...

Any use?



SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to deactivate one line in browser widgetin fltk1.3

2012-04-25 Thread leowang
>
> > I have a browser widget in a window, there has some lines in this browser,
> > press up/down key can select one by one, how can I set one line(or item)
> > deactivate, then the focus will not move to this line.
>
> Sorry, I'm not understanding your question clearly enough to formulate an a=
> nswer - can you expand the description to clarify this, please?
>
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS=
> 14 3EL
> A company registered in England & Wales.  Company no. 02426132
> 
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> 
>

my meaning is I have a browser widget, suppose it has three lines(line 1, line 
2, line 3). the code is :

#include 
#include 
#include 
#include 


int main(int argc, char *argv[]) {

  Fl_Double_Window *window = new Fl_Double_Window(800, 500);
Fl_Select_Browser *b = new Fl_Select_Browser(0, 0, 750, 400);
  b->type(FL_HOLD_BROWSER);
  b->add("line 1");
  b->add("line 2");
  b->add("line 3");
  window->end();
  window->show();
  return Fl::run();
}

press up/down key can make the focus move switch from line 1 to line 3, but I 
do not want the focus on the line2, then press up/down key can only make the 
focus on  the line1 or line3.

Is that clearly to you?

Best regards,
Leo

___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to deactivate one line in browser widget in fltk1.3

2012-04-25 Thread MacArthur, Ian (SELEX GALILEO, UK)

> I have a browser widget in a window, there has some lines in this browser,
> press up/down key can select one by one, how can I set one line(or item)
> deactivate, then the focus will not move to this line.

Sorry, I'm not understanding your question clearly enough to formulate an 
answer - can you expand the description to clarify this, please?



SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


[fltk.general] how to deactivate one line in browser widget in fltk1.3

2012-04-25 Thread leowang
Dear All,
I have a browser widget in a window, there has some lines in this browser, 
press up/down key can select one by one, how can I set one line(or item) 
deactivate, then the focus will not move to this line.

Best regards,
Leo
___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to set font in fltk1.3

2012-04-25 Thread leowang
>
> > I have a question of how to set my custom font, for example, I have a font
> > named MY_FONT, then how can I use this font type to display the text in
> > Browser widget?
> > =
>
> > I see it has a fl_font API, but the first parameter is a int type, so I
> > don't know how to set my font for Browser widget.
> > =
>
> > Can anyone give me a sample code? Thanks.
>
>
> You are just trying to load a font "by name" from the OS and then use it in=
>  your own code?
>
> Then the easiest thing is probably to use Fl::set_font(...) to load the new=
>  face into a fltk font indea then use that index.
>
> Example, suppose you decide to replace the FL_SYMBOL font with your own fon=
> t face, you could do...
>
>
>Fl::set_font(FL_SYMBOL, " MY_FONT");
>
> and then later assign that font to the text you are drawing inside a draw()=
>  method with...
>
>fl_font(FL_SYMBOL, size);
>
> or assign that font to a widget with...
>
>my_widget->lablefont(FL_SYMBOL);
>
> etc...
>
>
>
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS=
> 14 3EL
> A company registered in England & Wales.  Company no. 02426132
> 
> This email and any attachments are confidential to the intended
> recipient and may also be privileged. If you are not the intended
> recipient please delete it from your system and notify the sender.
> You should not copy it or use it for any purpose nor disclose or
> distribute its contents to any other person.
> 
>

Ian,
Thanks. Now I can use my custom font in my browser widget, thanks.

Best regards,
Leo

___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to set font in fltk1.3

2012-04-25 Thread MacArthur, Ian (SELEX GALILEO, UK)

> I have a question of how to set my custom font, for example, I have a font
> named MY_FONT, then how can I use this font type to display the text in
> Browser widget?
> 
> I see it has a fl_font API, but the first parameter is a int type, so I
> don't know how to set my font for Browser widget.
> 
> Can anyone give me a sample code? Thanks.


You are just trying to load a font "by name" from the OS and then use it in 
your own code?

Then the easiest thing is probably to use Fl::set_font(...) to load the new 
face into a fltk font indea then use that index.

Example, suppose you decide to replace the FL_SYMBOL font with your own font 
face, you could do...


   Fl::set_font(FL_SYMBOL, " MY_FONT");

and then later assign that font to the text you are drawing inside a draw() 
method with...

   fl_font(FL_SYMBOL, size);

or assign that font to a widget with...

   my_widget->lablefont(FL_SYMBOL);

etc...




SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk


Re: [fltk.general] how to change text color when select the text in fltk1.3

2012-04-25 Thread MacArthur, Ian (SELEX GALILEO, UK)

> In fltk2.0, it has a API called selection_textcolor(int color), this can
> change text color if the text is select.
> 
> But in fltk1.3, I can't find the similar API, can anyone else tell me
> where is this API, thanks.

Which widget are you asking about?

I'm not sure if this is an API that fltk-1.x supports, though doesn't seem like 
it would be that hard to derive your own subclass of whichever widget that 
would "adjust" the text colour at draw time...



SELEX Galileo Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132

This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.


___
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk