News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

2.8 Compilation Error: CentreOnWindow

Started by wizzard, March 31, 2007, 07:25:21 PM

Previous topic - Next topic

wizzard

When compiling on Arch Linux (wxGTK 2.8) I got the following compilation error:

g++ -DHAVE_CONFIG_H -I. -I../../src/include -I/usr/lib/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -pthread -I../../src/include -I../../src/include/wxscintilla/include -I../../src/include/tinyxml -I../../src/include/scripting/include -I../../src/include/scripting/sqplus -I../../src/include/wxFlatNotebook/include -I../../src/include/propgrid/include -Ulinux -Uunix -O2 -ffast-math -g -O2 -DCB_PRECOMP -Winvalid-pch -fPIC -DPIC -fexceptions -MT globals.lo -MD -MP -MF .deps/globals.Tpo -c globals.cpp  -fPIC -DPIC -o .libs/globals.o
globals.cpp: In function 'void PlaceWindow(wxWindow*, cbPlaceDialogMode, bool)':
globals.cpp:875: error: 'class wxWindow' has no member named 'CentreOnScreen'
make[3]: *** [globals.lo] Error 1


commenting out the line allows me to compile & run. I have no idea why it gives that error, I looked up CentreOnScreen in the wxWidgets manual and yes it is a member function...

Biplab

AFAIK, this function has been deprecated in wx 2.8.

Just replace CentreOnScreen() to Centre(wxCENTRE_ON_SCREEN)

Couple of wx2.8 related patches have been reverted recently which is causing this compilation error. :)
Be a part of the solution, not a part of the problem.

stahta01

My patch for this was [ Patch #1762 ] CentreOnScreen patch for wxWidgets 2.8

http://developer.berlios.de/patch/?func=detailpatch&patch_id=1762&group_id=5358

What version number of wxWidgets 2.8 has this problem?

Change it to

Centre(wxBOTH | wxCENTRE_ON_SCREEN)


Tim S
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

killerbot

Thomas has reverted some of those patches. From the explanation he gave me, I think he is correct. A few places didn't need the patch. And for the other places of reversal to work he adjusted globals.cpp


void PlaceWindow(wxToplevelWindow *w, cbPlaceDialogMode mode, bool enforce)


PlaceWindows now takes a wxToplevelWindow pointer instead of a wxWindow pointer.

BUT, afb has reverted later on this back to wxWindow*. The commit comments were :
Quote- didn't compile, wxToplevelWindow -> wxWindow

@Afb : what exactly didn't compile ??

At the others, try to build with the PlaceWindow taking the wxToplevelWindow*, and see what happens and report back here if you can.

afb

Sorry, the compilation problems seem to have been all mine. But it was changed in once place (the source) and not in th other (the header) - as long as it is changed in both it works just fine.

as in: go right ahead and change wxWindow to wxToplevelWindow

killerbot

ok, I will do that, build on windows and commit. Will check later on in linux.

afb

It built OK for wxMac 2.8 in my sandbox, but that also had all the patches/changes.

killerbot

#7
committed, BUT doesn't build on linux --> working on it

undefined references to PlaceWindow --> hmm strange, and make clean was of no help

FIXED :I hate ifdefs

thomas

#8
Quote from: killerbot on April 01, 2007, 10:33:54 AM
committed, BUT doesn't build on linux --> working on it

undefined references to PlaceWindow --> hmm strange, and make clean was of no help

FIXED :I hate ifdefs
Hahaha... that was why I reverted Patch #1762. :)

You are really unable to tell what's going on with all those #ifdefs. Save the whales, kill #ifdefs instead :)

@Tim:
Although your patch did work just fine (thanks for spotting the issue, above all), I did not like it, sorry :P
For PlaceWindow, it really only makes sense to work on wxToplevelWindow*, if one thinks about it. I originally implemented it to take a wxWindow* because that was the class which contained all the CentreXXX functions (and still does in 2.8, according to the documentation!). The documentation would say "no effect on non-toplevel windows" and I said "yeah, fine with me, makes sense".
It would of course have been no mistake (and maybe more logical) to use wxToplevelWindow* in the first place, since you really only want to position dialogs and frames.

Now, they secretly moved those functions into wxTopLevelWindow (without updating the documentation, and without a fallback), so it would suddenly no longer compile.
Changing the function signature works fine for all versions, and takes no #ifdefs, which is more readable.

As to the other two locations in the reverted patch, cbSplashScreen is a wxFrame (thus it is a wxTopLevelWindow), so it is not necessary to patch anything here.
The call to PlaceWindow inside the config panel dialog is wrong alltogether. It is a relict from the times before all config panels were placed inside a list view (where it of course no longer makes sense to center anything on screen). It used to work without problems in 2.6, so nobody ever noticed. But, the correct solution here is to just delete the offending code alltogether.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

stahta01

Quote from: thomas on April 02, 2007, 10:25:12 AM
@Tim:
Although your patch did work just fine (thanks for spotting the issue, above all), I did not like it, sorry :P
For PlaceWindow, it really only makes sense to work on wxToplevelWindow*, if one thinks about it. I originally implemented it to take a wxWindow* because that was the class which contained all the CentreXXX functions (and still does in 2.8, according to the documentation!). The documentation would say "no effect on non-toplevel windows" and I said "yeah, fine with me, makes sense".
It would of course have been no mistake (and maybe more logical) to use wxToplevelWindow* in the first place, since you really only want to position dialogs and frames.

Yeah, you solution is much better than mine was, but I did NOT know enough to do your's at the time.
Do NOT think that I would have seen it even if I fixed it now.

Tim S
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

killerbot

the good thing is, all together we fixed it and ended up with a good solution.
Community team work rules ;-)