1. wxEuphoria - get_facenames() issue

Matt,

In testing, I've found that get_facenames() returns all font faces, even when
asked to only return fixed-width fonts. I've mocked up a font browser demo below.
Also, is there some way to get the available point sizes? Right now I'm just
hard-coding the "standard" values.

-Greg

-- wxFontDemo.exw

include wxeud.e
without warning

constant 
    frmMain     = create( wxFrame, {0, -1, "Font Demo", -1, -1, 640, 480} ),
    pnlMain     = create( wxPanel, {frmMain} ),
lblFace     = create( wxStaticText, {pnlMain, -1, "&Face", 10, 14, 100, 16}
    ),
    lstFace     = create( wxListBox, {pnlMain, new_id(), 10, 30, 200, 200} ),
lblSize     = create( wxStaticText, {pnlMain, -1, "&Size", 230, 14, 100, 16}
    ),
    txtSize     = create( wxTextCtrl, {pnlMain, -1, "10", 230, 30, 60, 20} ),
    lstSize     = create( wxListBox, {pnlMain, -1, 230, 50, 60, 180} ),
    grpExample  = create( wxStaticBox, {pnlMain, -1, "", 40, 260, 540, 60} ),
lblExample  = create( wxStaticText, {grpExample, -1, "The quick brown fox
    jumps over the lazy dog.", 20, 24, 420, 16} )

sequence faces, sizes
atom font

procedure init()

    -- should return fixed-width fonts *only*
    faces = get_facenames( {wxFONTENCODING_SYSTEM, wxTrue} )
    for i = 1 to length( faces ) do
        add_item( lstFace, faces[i] )
    end for
    
    sizes = {8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72}
    for i = 1 to length( sizes ) do
        add_item( lstSize, sprint(sizes[i]) )
    end for
    
    set_selection( lstFace, 0 )
    set_selection( lstSize, 2 )

    font = create( wxFont, {10, wxDEFAULT, wxDEFAULT, wxDEFAULT, 0, faces[1]} )
    set_default_font( lblExample, font )

end procedure

procedure lstFace_onSelect( atom this, atom event_type, atom id, atom event )

    sequence face

    face = get_string_selection( this )
    set_font_face_name( font, face )
    set_default_font( lblExample, font )
    
end procedure
set_event_handler( lstFace, get_id(lstFace), wxEVT_COMMAND_LISTBOX_SELECTED,
routine_id("lstFace_onSelect") )

procedure lstSize_onSelect( atom this, atom event_type, atom id, atom event )

    integer index, size
    
    index = get_selection( this )
    size = sizes[index+1]
    set_label( txtSize, sprint(size) )
    set_point_size( font, size )
    set_default_font( lblExample, font )

end procedure
set_event_handler( lstSize, get_id(lstSize), wxEVT_COMMAND_LISTBOX_SELECTED,
routine_id("lstSize_onSelect") )

procedure txtSize_onUpdate( atom this, atom event_type, atom id, atom event )

    sequence text
    object val
    integer size, pos
    
    text = get_label( txtSize )
    val = value( text )
    if val[1] = GET_SUCCESS then
        size = val[2]
        set_point_size( font, size )
        set_default_font( lblExample, font )
        pos = find( size, sizes )
        set_selection( lstSize, pos - 1 )
    end if

end procedure
set_event_handler( txtSize, get_id(txtSize), wxEVT_COMMAND_TEXT_UPDATED,
routine_id("txtSize_onUpdate") )

init()
wxMain( frmMain )


new topic     » topic index » view message » categorize

2. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:
> 
> 
> Matt,
> 
> In testing, I've found that get_facenames() returns all font faces, even when
> asked to only return fixed-width fonts. I've mocked up a font browser demo
> below. Also, is there some way to get the available point sizes? Right now I'm
> just hard-coding the "standard" values.

Yep, this is a bug.  Line 724 of wxGraphics.cpp should be:

    wxArrayString fn = enumerator.GetFacenames(encoding, fixed);

I don't see a way in the documentation to get 'valid' point sizes.  If you're
actually picking a font, the recommended way is to use font_selector().

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Yep, this is a bug.  Line 724 of wxGraphics.cpp should be:
> 
>     wxArrayString fn = enumerator.GetFacenames(encoding, fixed);

Good to see I'm not crazy. :-p
 
> I don't see a way in the documentation to get 'valid' point sizes.  If you're
> actually picking a font, the recommended way is to use font_selector().

Damn, I was really hoping I could embed the font selection of my app into the
options dialog. I don't really want to use the font_selector(). But my Googling
has not turned up any results on how to do this in wxWidgets. The one example I
saw just used 1 - 40, which is no better than what I'm doing now. I guess maybe
I'll re-arrange things and see how it goes...

-Greg

new topic     » goto parent     » topic index » view message » categorize

4. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:
> 
> Matt Lewis wrote:
> > 
> > I don't see a way in the documentation to get 'valid' point sizes.  If 
> > you're actually picking a font, the recommended way is to use
> > font_selector().
> 
> Damn, I was really hoping I could embed the font selection of my app into
> the options dialog. I don't really want to use the font_selector(). But my
> Googling has not turned up any results on how to do this in wxWidgets. The
> one example I saw just used 1 - 40, which is no better than what I'm doing
> now. I guess maybe I'll re-arrange things and see how it goes...

It looks like on Windows wxWidgets just uses the common dialog provided.  I
suspect that it uses the same thing on GTK.  In the generic font dialog,
they also just go 1-40.  

Quick googling doesn't give me an answer as to whether there's even an API 
for doing this.

Matt

new topic     » goto parent     » topic index » view message » categorize

5. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Quick googling doesn't give me an answer as to whether there's even an API 
> for doing this.

Pete knows how! Edita does this (that's actually where I got the idea from). But
obviously Edita uses ARWEN not wxEuphoria. At least we know there's a way to do
it in Windows.

-Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:
> 
> Matt Lewis wrote:
> > 
> > Quick googling doesn't give me an answer as to whether there's even an API 
> > for doing this.
> 
> Pete knows how! Edita does this (that's actually where I got the idea from).
> But obviously Edita uses ARWEN not wxEuphoria. At least we know there's a way
> to do it in Windows.

Interesting.  If there's a gtk way to do it, then we're set.

Matt

new topic     » goto parent     » topic index » view message » categorize

7. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Greg Haberek wrote:
> > 
> > Matt Lewis wrote:
> > > 
> > > Quick googling doesn't give me an answer as to whether there's even an API
> > >
> > > for doing this.
> > 
> > Pete knows how! Edita does this (that's actually where I got the idea from).
> > But obviously Edita uses ARWEN not wxEuphoria. At least we know there's a
> > way
> > to do it in Windows.
> 
> Interesting.  If there's a gtk way to do it, then we're set.
> 
> Matt

Fairly obviously, Edita/Arwen uses winAPI, eg from eafonts.ew:
cbid = CallBack(routine_id("EnumFontFamExProc"))
    void = c_func(xEnumFontFamiliesExA,{hDC,lf,cbid,0,0})

It just builds a list of allowed font sizes in EnumFonFamExProc(), which gets
called for each and every permitted facename/pointsize combo.

The only thing I can suggest is that if wxEuphoria is implementing
get_facenames() via:

>>wxFontEnumerator::GetFacenames
>>
>>static wxArrayString GetFacenames(wxFontEncoding encoding =
>>>>wxFONTENCODING_SYSTEM, bool fixedWidthOnly = false)
>>
>>Return array of strings containing all facenames found by 
>>EnumerateFacenames.

Then it might be possible to build valid sizes in a similar fashion via:

>>wxFontEnumerator::EnumerateFacenames
>>
>>virtual bool EnumerateFacenames( wxFontEncoding encoding =
>>>>wxFONTENCODING_SYSTEM, bool fixedWidthOnly = false)
>>
>>Call OnFacename for each font which supports given encoding (only if it is 
>>not wxFONTENCODING_SYSTEM) and is of fixed width (if fixedWidthOnly is 
>>true).
>>
>>Calling this function with default arguments will result in enumerating 
>>all fonts available on the system.

The above quotes are from
http://wxwidgets.org/manuals/stable/wx_wxfontenumerator.html#wxfontenumeratorenumeratefacenames

Not that I properly understand all that smile but it would seem to depend on
whether that OnFacename (some kind of virtual function it seems) gets called the
same way or not.

Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

8. Re: wxEuphoria - get_facenames() issue

Pete Lomax wrote:
> 
> Fairly obviously, Edita/Arwen uses winAPI, eg from eafonts.ew:
> }}}
<eucode>
>     cbid = CallBack(routine_id("EnumFontFamExProc"))
>     void = c_func(xEnumFontFamiliesExA,{hDC,lf,cbid,0,0})
> </eucode>
{{{

> It just builds a list of allowed font sizes in EnumFonFamExProc(), 
> which gets called for each and every permitted facename/pointsize combo.

Yeah, I took a look at that code as soon as Greg mentioned it.
 
> The only thing I can suggest is that if wxEuphoria is implementing 
> get_facenames() via:
> 
> >>wxFontEnumerator::GetFacenames
> >>
> >>static wxArrayString GetFacenames(wxFontEncoding encoding = 
> >>wxFONTENCODING_SYSTEM, bool fixedWidthOnly = false)
> 
> Then it might be possible to build valid sizes in a similar fashion via:
> 
> >>wxFontEnumerator::EnumerateFacenames
> >> [snipped]

> Not that I properly understand all that smile but
> it would seem to depend on whether that OnFacename (some kind of virtual 
> function it seems) gets called the same way or not.

Yes, wxEuphoria uses GetFaceNames.  Basically, GetFaceNames (if you look
at the wxWidgets source) uses a simple object that overrides OnFacename,
and just accumulates them for you into a wxArrayString, which I turn into a 
sequence and pass back.

Unfortunately, there is no way to get the available sizes through wxWidgets.
I did some research into doing this on GTK through pango (the GTK font lib 
or whatever), and didn't see any obvious way to do it, or if it were 
available at all.  I suspect that I may have to go down into X itself to 
get this information.

Matt

new topic     » goto parent     » topic index » view message » categorize

9. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Unfortunately, there is no way to get the available sizes through wxWidgets.
> I did some research into doing this on GTK through pango (the GTK font lib 
> or whatever), and didn't see any obvious way to do it, or if it were 
> available at all.  I suspect that I may have to go down into X itself to 
> get this information.

Heh, got a better look at the pango docs, and I saw this function:

void pango_font_face_list_sizes(PangoFontFace *face,
                                int **sizes,
                                int *n_sizes);

So I guess it's actually pretty simple to do...

Matt

new topic     » goto parent     » topic index » view message » categorize

10. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Matt Lewis wrote:
> > 
> > Unfortunately, there is no way to get the available sizes through wxWidgets.
> > I did some research into doing this on GTK through pango (the GTK font lib 
> > or whatever), and didn't see any obvious way to do it, or if it were 
> > available at all.  I suspect that I may have to go down into X itself to 
> > get this information.
> 
> Heh, got a better look at the pango docs, and I saw this function:
> 
> void pango_font_face_list_sizes(PangoFontFace *face,
>                                 int **sizes,
>                                 int *n_sizes);
> 
> So I guess it's actually pretty simple to do...

OK, I've got it working on Windows and Linux now.  I also made a couple of
changes to your demo.  First, it wasn't documented in wxeu (but it was in
wxWidgets), using a wxStaticBox as a parent will cause crashes in GTK.  The
solution is to use the wxStaticBoxSizer, which somehow didn't make the 
transition when I overhauled the library.  It was in the docs, but not 
the code.  I put that back.

I also changed it a bit to display the 'correct' sizes for bitmapped fonts.
It all uses sizers, too.  Obviously, you'd need to rebuild the dll and get
the newest wxeud.e to use this.
-- wxFontDemo.exw

include wxeud.e
without warning

constant 
    frmMain     = create( wxFrame, {0, -1, "Font Demo", -1, -1, 640, 480} ),
    pnlMain     = create( wxPanel, {frmMain} ),
    lblFace     = create( wxStaticText, {pnlMain, -1, "&Face"}),
    lstFace     = create( wxListBox, pnlMain ),
    lblSize     = create( wxStaticText, {pnlMain, -1, "&Size"}),
    txtSize     = create( wxTextCtrl, {pnlMain, -1, "10"}),
    lstSize     = create( wxListBox, pnlMain ),
    grpExample  = create( wxStaticBox, {pnlMain, -1, "Box"}),
lblExample  = create( wxStaticText, {pnlMain, -1, "The quick brown fox jumps
    over the lazy dog."})

sequence faces, sizes
atom font


procedure init()
    sequence sizer
    sequence string_sizes
    -- first put everything into sizers:
    sizer = {create( wxBoxSizer, wxVERTICAL)}
    set_sizer( pnlMain, sizer[$] )
    
    -- Add a sizer for the lists up top
    sizer &= create( wxBoxSizer, wxHORIZONTAL )
    add_sizer_to_sizer( sizer[$-1], sizer[$], 1, wxGROW, 0 )
    
    -- Sizer for the faces
    sizer &= create( wxBoxSizer, wxVERTICAL )
    add_sizer_to_sizer( sizer[$-1], sizer[$], 1, wxGROW, 0 )
    add_window_to_sizer( sizer[$], lblFace, 0, 0, 0 )
    add_window_to_sizer( sizer[$], lstFace, 1, wxGROW, 0 )
    sizer = sizer[1..$-1]  -- pop the face sizer
    
    -- Sizer for the sizes
    sizer &= create( wxBoxSizer, wxVERTICAL )
    add_sizer_to_sizer( sizer[$-1], sizer[$], 0, wxGROW, 0 )
    add_window_to_sizer( sizer[$], lblSize, 0, wxGROW, 0 )
    add_window_to_sizer( sizer[$], txtSize, 0, wxGROW, 0 )
    add_window_to_sizer( sizer[$], lstSize, 1, wxGROW, 0 )
    sizer = sizer[1..$-1]  -- pop the sizes sizer
    sizer = sizer[1..$-1]  -- pop the top sizer
    
    sizer &= create( wxStaticBoxSizer, { grpExample, wxHORIZONTAL } )
    add_sizer_to_sizer( sizer[$-1], sizer[$], 1, wxGROW, 0 )
    add_window_to_sizer( sizer[$], lblExample, 1, wxGROW, 0 )
    
    -- should return fixed-width fonts *only*
    faces = get_facesizes( {wxFONTENCODING_SYSTEM, wxTrue} ) 
    faces = append( faces, repeat( 0, length(faces[1]) ) )
	
	sizes = {8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72}
	string_sizes = sizes
    for i = 1 to length( sizes ) do
    	string_sizes[i] = sprint( sizes[i] )
        
    end for
    for i = 1 to length( faces[1] ) do
        add_item( lstFace, faces[1][i] )
        if length( faces[2][i] ) then
        	faces[3][i] = repeat( 0, length(faces[2][i]) )
        	for j = 1 to length(faces[2][i]) do
        		faces[3][i][j] = sprint( faces[2][i][j] )
        	end for
        else
        	faces[2][i] = sizes
        	faces[3][i] = string_sizes
        end if
    end for
    
    
    
    set_selection( lstFace, 0 )
    add_item( lstSize, faces[3][1] )
    set_selection( lstSize, 2 )
	
    font = create( wxFont, {10, wxDEFAULT, wxDEFAULT, wxDEFAULT, 0, faces[1]} )
    set_default_font( lblExample, font )

end procedure

procedure lstFace_onSelect( atom this, atom event_type, atom id, atom event )

    sequence face
	integer fx
	
	fx = get_selection( this ) + 1
	if not fx then
		return
	end if
    face = faces[1][fx]
    set_font_face_name( font, face )
    
    clear_list( lstSize )
   	add_item( lstSize, faces[3][fx] )

    set_default_font( lblExample, font )
    
end procedure
set_event_handler( lstFace, get_id(lstFace), 
    wxEVT_COMMAND_LISTBOX_SELECTED, routine_id("lstFace_onSelect"))

procedure lstSize_onSelect( atom this, atom event_type, atom id, atom event )

    integer index, size, face
    
    face = get_selection( lstFace ) + 1
    if not face then
    	return
    end if
    index = get_selection( this )
    size = faces[2][face][index+1]
    set_label( txtSize, sprint(size) )
    set_point_size( font, size )
    set_default_font( lblExample, font )

end procedure
set_event_handler( lstSize, get_id(lstSize), 
    wxEVT_COMMAND_LISTBOX_SELECTED, routine_id("lstSize_onSelect"))

procedure txtSize_onUpdate( atom this, atom event_type, atom id, atom event )

    sequence text
    object val
    integer size, pos
    
    text = get_label( txtSize )
    val = value( text )
    if val[1] = GET_SUCCESS then
        size = val[2]
        set_point_size( font, size )
        set_default_font( lblExample, font )
        pos = find( size, sizes )
        set_selection( lstSize, pos - 1 )
    end if

end procedure
set_event_handler( txtSize, get_id(txtSize), wxEVT_COMMAND_TEXT_UPDATED, 
    routine_id("txtSize_onUpdate"))

init()
wxMain( frmMain )


new topic     » goto parent     » topic index » view message » categorize

11. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> ...Obviously, you'd need to rebuild the dll and get the newest wxeud.e
> to use this.

I've put up a new beta release for windows (I'll try to get the other 
platforms up later):

http://sourceforge.net/project/showfiles.php?group_id=73684&package_id=73795&release_id=571552

Matt

new topic     » goto parent     » topic index » view message » categorize

12. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Matt Lewis wrote:
> > 
> > ...Obviously, you'd need to rebuild the dll and get the newest wxeud.e
> > to use this.
> 
> I've put up a new beta release for windows (I'll try to get the other 
> platforms up later):
> 
> <a
> href="http://sourceforge.net/project/showfiles.php?group_id=73684&package_id=73795&release_id=571552">http://sourceforge.net/project/showfiles.php?group_id=73684&package_id=73795&release_id=571552</a>
> 
> Matt

This is excellent! Thank you so much for adding this to wxEuphoria. It's got me
one more step closer to completing my current project. I hope to wrap it up this
week and post it to the User Contributions page. I haven't really posted much
there in a while.

My next step is to get wxScintilla implemented, but that seems like a larger
endeavor, and I don't absolutely need it to get out a working product. (If you
can't tell, I'm writing some sort of editor.)

Thanks again, Matt!

-Greg

new topic     » goto parent     » topic index » view message » categorize

13. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Matt Lewis wrote:
> > 
> > ...Obviously, you'd need to rebuild the dll and get the newest wxeud.e
> > to use this.
> 
> I've put up a new beta release for windows (I'll try to get the other 
> platforms up later):

Ubuntu binary and source tarball are up now:
http://sourceforge.net/project/showfiles.php?group_id=73684&package_id=73795&release_id=571552
 
Matt

new topic     » goto parent     » topic index » view message » categorize

14. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Matt Lewis wrote:
> > 
> > Unfortunately, there is no way to get the available sizes through wxWidgets.
> > I did some research into doing this on GTK through pango (the GTK font lib 
> > or whatever), and didn't see any obvious way to do it, or if it were 
> > available at all.  I suspect that I may have to go down into X itself to 
> > get this information.
> 
> Heh, got a better look at the pango docs, and I saw this function:
> 
> void pango_font_face_list_sizes(PangoFontFace *face,
>                                 int **sizes,
>                                 int *n_sizes);
> 
> So I guess it's actually pretty simple to do...
> 
> Matt

See http://support.microsoft.com/kb/200111/en-us , at the bottom, for a
discussion. The basic idea is that the EnumFontFamiliesEx() API will do the job
on Windows.
As outlined on that article, all sizes are available to a TrueType font because
of the way they are designed, so listing "available font sizes" for them doesn't
make sense.
What happens when you specify a font and candidly expect to get it is explained
here: http://msdn2.microsoft.com/en-us/library/ms969909.aspx .
You'll notice the "New in Windows 3.1" phrase, but GDI's font mapper is a core
component that has hardly changed ever since.

I don't how the same job is done under Linux/BSD. Under DOS, you have to send
escapes to your printer or have some software do that for you iirc.

CChris

new topic     » goto parent     » topic index » view message » categorize

15. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Ubuntu binary and source tarball are up now:
> <a
> href="http://sourceforge.net/project/showfiles.php?group_id=73684&package_id=73795&release_id=571552">http://sourceforge.net/project/showfiles.php?group_id=73684&package_id=73795&release_id=571552</a>

Matt,

I just downloaded this and it doesn't seem to include the libwxeu.so file. I
don't mind building it from source, but I wasn't prepared to do that.

I may or may not have had to scrap Windows XP after the installation corrupted
itself. So I gave up -- I'm running 100% Ubuntu from now on. No more Windows
development for me! w00t!!1!

So the question is... will you post the updated tar file before I finish
downloading everything I need to build it myself?

-Greg

new topic     » goto parent     » topic index » view message » categorize

16. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:
> 
> Matt Lewis wrote:
> > 
> > Ubuntu binary and source tarball are up now:
> > <a
> > href="http://sourceforge.net/project/showfiles.php?group_id=73684&package_id=73795&release_id=571552">http://sourceforge.net/project/showfiles.php?group_id=73684&package_id=73795&release_id=571552</a>
> 
> Matt,
> 
> I just downloaded this and it doesn't seem to include the libwxeu.so file. I
> don't mind building it from source, but I wasn't prepared to do that.
> 
> I may or may not have had to scrap Windows XP after the installation corrupted
> itself. So I gave up -- I'm running 100% Ubuntu from now on. No more Windows
> development for me! w00t!!1!
> 
> So the question is... will you post the updated tar file before I finish
> downloading
> everything I need to build it myself?

Heh, unless you have a very slow connection, looks like the answer was 
probably not (didn't get online all weekend).  Unfortunately, this was a 
casualty of changing the file name, and then me forgetting how the distro
script worked.  I should probably put it into the makefile.

I've uploaded a correct version to sourceforge, if you haven't already built
your own.

Matt

new topic     » goto parent     » topic index » view message » categorize

17. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> Heh, unless you have a very slow connection, looks like the answer was 
> probably not (didn't get online all weekend).  Unfortunately, this was a 
> casualty of changing the file name, and then me forgetting how the distro
> script worked.  I should probably put it into the makefile.
> 
> I've uploaded a correct version to sourceforge, if you haven't already built
> your own.

I wasn't online much over the whole weekend, either. I just downloaded the new
package last night and tried it out. Everything seemed to launch correctly, but
my menus don't work!

I give my corresponding menu items and toolbar buttons the same wxID_----
values, so they trigger the same events. To catch all these events in a single
handler, I pass -1 as the id to set_event_handler():

set_event_handler( frmMain, -1, wxEVT_COMMAND_MENU_SELECTED,
routine_id("menus_onClick") )
set_event_handler( tbrMain, -1, wxEVT_COMMAND_MENU_SELECTED,
routine_id("menus_onClick") )


On Windows, this worked great. But on Linux (Ubuntu 7.10), only the toolbar
events get passed, and the menus do nothing.

-Greg

new topic     » goto parent     » topic index » view message » categorize

18. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:
> 
> I give my corresponding menu items and toolbar buttons the same wxID_----
> values,
> so they trigger the same events. To catch all these events in a single
> handler,
> I pass -1 as the id to set_event_handler():

Clever. Hey! How you coming along on that wxEuphoria IDE? 8)

new topic     » goto parent     » topic index » view message » categorize

19. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:
> 
> Everything seemed to launch correctly, but my menus don't work!
> 
> I give my corresponding menu items and toolbar buttons the same wxID_----
> values,
> so they trigger the same events. To catch all these events in a single
> handler,
> I pass -1 as the id to set_event_handler():
> 
set_event_handler( frmMain, -1, wxEVT_COMMAND_MENU_SELECTED,
routine_id("menus_onClick") )
set_event_handler( tbrMain, -1, wxEVT_COMMAND_MENU_SELECTED,
routine_id("menus_onClick") )

> 
> On Windows, this worked great. But on Linux (Ubuntu 7.10), only the toolbar
> events get passed, and the menus do nothing.

Menu events have been a thorn in my side for quite some time.  I believe that
the problem arises from the differences in the GTK and Windows event systems.  
 From the Menus topic in the wxeu docs:

    When setting a wxEVT_COMMAND_MENU_SELECTED event, you should pass 
    the pointer to the wxMenu parent of the wxMenuItem. Use of the 
    {wxFrame, wxMenu} parameter is deprecated, and should not be used 
    on any platform.

I've fought this issue many times, and I think now I have the best solution.
Part of the problem is that I have to take whatever I'm handed by wxWidgets, 
and link it to a euphoria routine_id.  There are quirks on both systems,
and so I have to code around them.  Timers are another problem.

If you're interested in joining the fight, the relevant stuff is in 
wxEuphoria.cpp.  Look for wxEuClientData, EuEvent and set_event_handler.

Matt

new topic     » goto parent     » topic index » view message » categorize

20. Re: wxEuphoria - get_facenames() issue

c.k.lester wrote:
> 
> Clever. Hey! How you coming along on that wxEuphoria IDE? 8)

Shhhh!!! Don't tell. :p

Once I get this text editor done, I can begin work on a visual IDE. Now that I
don't use Windows, I'll be working quite a bit on writing things in (and for)
wxEuphoria. It's come a long way since its inception. I don't see why we
shouldn't have a simple cross-platform GUI library, since Euphoria itself is
already cross-platform.

Once I get this menu issue ironed out, I'd like to get Scintilla embedded as a
component in wxEuphoria, so I'll need to figure out how to merge the code
together. And honestly, I suck as C++, which is why I use Euphoria. I had one
class on C++ in high school and I barely passed it. So I'll keep banging my head
against the keyboard till it starts working. :)

-Greg

new topic     » goto parent     » topic index » view message » categorize

21. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> I've fought this issue many times, and I think now I have the best solution.
> Part of the problem is that I have to take whatever I'm handed by wxWidgets,

I got it to work. But... why do the docs say this method is depreciated, when
it's the only thing that works?

set_event_handler( {frmMain,mnuFile}, -1, wxEVT_COMMAND_MENU_SELECTED,
routine_id("menus_onClick") )


Also, could you make it so that we can pass multiple menus to the event handler?
Something like this would work well:

set_event_handler( {frmMain,mnuFile,mnuEdit,mnuView,mnuHelp}, -1,
wxEVT_COMMAND_MENU_SELECTED, routine_id("menus_onClick") )


-Greg

new topic     » goto parent     » topic index » view message » categorize

22. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:
> 
> Matt Lewis wrote:
> > 
> > I've fought this issue many times, and I think now I have the best solution.
> > Part of the problem is that I have to take whatever I'm handed by wxWidgets,
> 
> I got it to work. But... why do the docs say this method is depreciated, when
> it's the only thing that works?
> 
> }}}
<eucode>
> set_event_handler( {frmMain,mnuFile}, -1, wxEVT_COMMAND_MENU_SELECTED,
> routine_id("menus_onClick") )
> </eucode>
{{{


If you take a look at set_event_handler in wxeud.e, you'll see that it now
discards the frmMain, and just uses mnuFile (which is the documented
way to do it).

> Also, could you make it so that we can pass multiple menus to the event
>  handler?
> Something like this would work well:
> 
> }}}
<eucode>
> set_event_handler( {frmMain,mnuFile,mnuEdit,mnuView,mnuHelp}, -1,
> wxEVT_COMMAND_MENU_SELECTED, routine_id("menus_onClick")
> )
> </eucode>
{{{


This is a possibility.  Basically, it would just be a for loop in 
set_event_handler.  The only issue is that there is likely code out there
that still uses the deprecated way of doing it, so we'd start breaking things.
Maybe for the next release.  In the mean time, you could always wrap it 
to do that yourself.  Or maybe add a new function (set_handler).  That
way new code could take advantage without worrying about breaking old
code.

Matt

new topic     » goto parent     » topic index » view message » categorize

23. Re: wxEuphoria - get_facenames() issue

Matt Lewis wrote:
> 
> If you take a look at set_event_handler in wxeud.e, you'll see that it now
> discards the frmMain, and just uses mnuFile (which is the documented
> way to do it).

So on Windows, I have to use frmMain, and on Linux I use mnuFile, mnuEdit, etc.?
I can handle that.

> This is a possibility.  Basically, it would just be a for loop in 
> set_event_handler.  The only issue is that there is likely code out there
> that still uses the deprecated way of doing it, so we'd start breaking things.
> Maybe for the next release.  In the mean time, you could always wrap it 
> to do that yourself.  Or maybe add a new function (set_handler).  That
> way new code could take advantage without worrying about breaking old
> code.

I can do it myself. I'll just wrap this and the above into a single routine that
will handle it for both platforms.

-Greg

new topic     » goto parent     » topic index » view message » categorize

24. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:

> Once I get this text editor done, I can begin work on a visual IDE. Now that
> I don't use Windows, I'll be working quite a bit on writing things in (and
> for)
> wxEuphoria. It's come a long way since its inception. I don't see why we
> shouldn't
> have a simple cross-platform GUI library, since Euphoria itself is already
> cross-platform.

That's what I keep saying. PLUS... wxWidgets has so much more than just the
GUI windowing stuff. FTP. HTTP. HTML. etc. (Matt?) All cross platform. Nice!

Add integration with Mark Akita's SDL graphic libs and Euphoria will take over
the world! :D

new topic     » goto parent     » topic index » view message » categorize

25. Re: wxEuphoria - get_facenames() issue

c.k.lester wrote:
> That's what I keep saying. PLUS... wxWidgets has so much more than just the
> GUI windowing stuff. FTP. HTTP. HTML. etc. (Matt?) All cross platform. Nice!
> 
> Add integration with Mark Akita's SDL graphic libs and Euphoria will take over
> the world! :D

One more thing before Euphoria and wxEuphoria can take over the world.
wxEuphoria needs an automated installation process such as apt (Advance Packaging
Tool). Then people who download programs based on wxEuphoria from freshmeat will
have less difficulty making them work.

new topic     » goto parent     » topic index » view message » categorize

26. Re: wxEuphoria - get_facenames() issue

Greg Haberek wrote:
> 
> Matt Lewis wrote:
> > 
> > If you take a look at set_event_handler in wxeud.e, you'll see that it now
> > discards the frmMain, and just uses mnuFile (which is the documented
> > way to do it).
> 
> So on Windows, I have to use frmMain, and on Linux I use mnuFile, mnuEdit, 
> etc.? I can handle that.

No, they both use the menu.

Matt

new topic     » goto parent     » topic index » view message » categorize

27. Re: wxEuphoria - get_facenames() issue

c.k.lester wrote:
> 
> That's what I keep saying. PLUS... wxWidgets has so much more than just the
> GUI windowing stuff. FTP. HTTP. HTML. etc. (Matt?) All cross platform. Nice!
> 
> Add integration with Mark Akita's SDL graphic libs and Euphoria will take over
> the world! :D

FTP and HTTP are partially implemented right now. I need to get FTP working (I
have some more code around here...) so I can get another project off the ground.
So many ideas, so many partial or missing widgets...

Jerry Story wrote:
> 
> One more thing before Euphoria and wxEuphoria can take over the world.
> wxEuphoria
> needs an automated installation process such as apt (Advance Packaging Tool).
> Then people who download programs based on wxEuphoria from freshmeat will have
> less difficulty making them work.

I think Matt is working on a deb package for it. I used his deb package to
install Euphoria on Ubuntu 7.10, and that worked great! I'd love to be able to
use apt-get, but dpkg works fine. I'm gonna start exploring how to create deb
packages so I can easily distribute my applications.

-Greg

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu