Exposing cursorPos in IGUIEditBox

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
tasulife
Posts: 20
Joined: Sat Sep 21, 2013 8:09 pm

Exposing cursorPos in IGUIEditBox

Post by tasulife »

I'm using a IGUIEditBox to act as a very simple text editor. I need to retrieve the line# and column# of the cursor from the IGUIEditBox.
I dove into the source code and saw that in CGUIEditBox.h and CGUIEditBox.cpp, there's a "s32 CursorPos" variable that seems to be the raw location, and the method "CGUIEditBox::getLineFromPos(s32 Pos)" which seems to decompose that into a line number.

However, getLineFromPos() and CursorPos are both protected, and there are no public getters/setters for the CursorPos, so I cannot use the irrlicht classes straight up.

My Idea is to subclass the CGUIEditBox class, and write new public functions to expose the inherited function/variable that I need. However, when I do this, I get linking errors saying that it can't find CGUIEditBox's constructor. I'm linking to the DLL's .a file, and I just built it fresh a second ago. I'm using codeblocks for everything. Oh, there's more errors: a "undefined reference to X" for every member of CGUIEditBox.

Am I even approaching this right? The real object code is stored in the dll file, and trying to link subclasses to the exported definitions .a file. Except, the linker can't find any of the variables or functions.

here's the first error:

Code: Select all

 
 
||=== Build: Debug in VMG Screen Demo (compiler: GNU GCC Compiler) ===|
obj\Debug\GUIStatEditBox.o||In function `ZN14GUIStatEditBoxC2EPN3irr3gui15IGUIEnvironmentEPNS1_11IGUIElementEiNS0_4core4rectIiEE':|
D:\work\code\vmg_screen\GUIStatEditBox.cpp|13|undefined reference to `irr::gui::CGUIEditBox::CGUIEditBox(wchar_t const*, bool, irr::gui::IGUIEnvironment*, irr::gui::IGUIElement*, int, irr::core::rect<int> const&)'
 
here's the build log:

Code: Select all

mingw32-g++.exe -Wall -fexceptions -g -IC:\irrlicht-1.8\include -ID:\work\code\vmg_screen\ -IC:\irrlicht-1.8\source\Irrlicht -c D:\work\code\vmg_screen\GUIStatEditBox.cpp -o obj\Debug\GUIStatEditBox.o
mingw32-g++.exe -LC:\irrlicht-1.8\lib\Win32-gcc -o bin\Debug\Irrlight_GRTT.exe obj\Debug\GUIStatEditBox.o   C:\irrlicht-1.8\lib\Win32-gcc\libIrrlicht.a
obj\Debug\GUIStatEditBox.o: In function `ZN14GUIStatEditBoxC2EPN3irr3gui15IGUIEnvironmentEPNS1_11IGUIElementEiNS0_4core4rectIiEE':
D:/work/code/vmg_screen/GUIStatEditBox.cpp:13: undefined reference to `irr::gui::CGUIEditBox::CGUIEditBox(wchar_t const*, bool, irr::gui::IGUIEnvironment*, irr::gui::IGUIElement*, int, irr::core::rect<int> const&)'
obj\Debug\GUIStatEditBox.o: In function `ZN14GUIStatEditBoxC1EPN3irr3gui15IGUIEnvironmentEPNS1_11IGUIElementEiNS0_4core4rectIiEE':
D:/work/code/vmg_screen/GUIStatEditBox.cpp:13: undefined reference to `irr::gui::CGUIEditBox::CGUIEditBox(wchar_t const*, bool, irr::gui::IGUIEnvironment*, irr::gui::IGUIElement*, int, irr::core::rect<int> const&)'
 
here's my header file:

Code: Select all

#include "irrlicht.h"
#include "CGUIEditBox.h"
 
using namespace irr;
using namespace gui;
 
class GUIStatEditBox:public CGUIEditBox
{
    public:
        GUIStatEditBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
        s32 getCursorLine();
 
    protected:
    private:
};
 
and here's my cpp file:

Code: Select all

 
 
#include <irrlicht.h>
#include <GUIStatEditBox.h>
 
GUIStatEditBox::GUIStatEditBox(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
    :CGUIEditBox(L"initText", false, environment, parent, id, rectangle)
{
 
}
 
Thank you in advance for your time.

EDIT:
I ran nm on the dll that I built using codeblocks in the irrlicht debug dll mode and I can see the CGUIEditBox constructor is exposed in the dll.
I'm linking to the LibIrrlicht.a file, which is generated at the same time as the DLL because I think it's the import library. When I look at the import library using NM, and the .def file using a text editor, it looks like none of the .dll funcions are exported except for "create device".

FINAL EDIT BEFORE BEDTIME:
I'm trying to subclass an irrlicht class in my user project which links to the irrlicht dll. I think this method is destined to fail, since the import library doesn't expose constructors for the classes. Tomorrow I'm just going to add my special class to irrlicht, then compile a special modified .dll and use that.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Exposing cursorPos in IGUIEditBox

Post by CuteAlien »

You can't derive from the implementation classes outside of Irrlicht. What you can do is copy the source-files and use them to implement your own class.

The reason cursor-pos functions are not exposed is that this part needs to be reworked (it's basically about internal information where newlines are removed - but the removing of newlines means that currently a setText followed by getText can return different information which is bad. And also text-wrapping which is the reason for all this should be handled completely different and implemented in an own class. But don't wait for it - this has been open for years and I don't see any chance of working on this anytime soon).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply