Worklog for Brucey

Cutie

Return to Worklogs

Update(Posted 2007-04-14)
Finally got back to some Qt hacking.

It's been a busy old "break" it turns out, but the new modules have added a bit more depth to what's available on the website.

New in the latest release are Panel Pixmaps and Popup menus, amongst other things.
T'was a bit of digging to find out how to disable the default popup menu for text areas, but it's looking okay now.

:-)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

KitKat(Posted 2007-03-01)
Having a wee break from it for a bit, after 3 weeks of frantic keyboard tapping.

Learning a bit of SQL wrapping for now, which is a nice change, although a bit close to what I do for a living - not that I'm averse to taking work home with me from time to time ;-)

Anyways... no need to put as much time into it now that the core is basically working... (bug-fixes r us)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Or so he thought....(Posted 2007-02-21)
There you are, plodding along thinking how great everything is working, and then you discover to your horror that the Qt/Mac framework has been built using Carbon, rather than Cocoa!!!!

argh!!!

I can see how they decided to do it this way. For a start, Carbon is a C++ API and it would have been very easy for their developers to get into it without having to learn Object C from scratch.
However, it does make plugging the GL/Canvas stuff onto it a little on the almost impossible side, since the Max code assumes that it's working on a Cocoa widget and not a Carbon one (the two of which are not compatible!)

I've searched and searched, and can't see a way of getting an NSView onto a HIView... so I'm kind of stuck at the moment.
The only option I see is to write a new GLGraphics thingy specifically for Qt/Mac. Not something that thrills me too deeply.

I'm not going to call it a show-stopper, as for now, everything else on the Mac side is working as well as it does on the other platforms... It just requires a little thought.

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Almost there !(Posted 2007-02-19)
Well, flog me with a cold, wet sponge! It looks as though it's almost there...

After a weekend of battling through a large pile of enhancements and fixes (see topic in the Linux section for details) I've almost got a full implementation GUI in Qt.

I thought the hardest bit would be the Canvas, but on Windows at least it was just a case of getting the "Redrawing" working in the right places. I've no idea if it's only GL or works with DX too, but I'm just passing the window Id for the gadget to the graphics stuff, so whichever one it is using on my win2k, it seems to work ok.

Hopefully, with it working on one platform it will work on the rest now without change (well, that's how things have generally gone so far).

Funnily enough, the biggest problem I've had so far is with HIDDEN window creation. It's been a nightmare.
And if I remember correctly, windows were (and still are) a problem on GTK.
Which reminds me... I need to still look at CLIENTCOORDS...

Most of the tests work great. I think one of the Seb tests (to do with windows) is still a bit iffy.

Not too bad for 3 weeks very part-time effort.. ;-)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Progressing...(Posted 2007-02-16)
Into the second iteration of the TextArea code, I finally think I've got it now.
On Windows, the speed at loading and syntax-highlighting a large .bmx document in the IDE is faster than the default win32maxgui. Always a good sign, me thinks.
I had some trouble with editing, where the cursor was slowing down the further to the end you got. But some tweaks to the line/char counting code fixed that.
The only seeming issues left with the TextArea now are some of the key-bindings that are set up on it by default - like Ctrl-Z. Haven't as yet worked out how to disable these so that we can control them ourselves...

Of course, there's still plenty to do...
List and Tree views don't handle keyboard input presently, but this is my own fault. I'll need to redo the handling code for both to use a different mechanism - which doesn't look too difficult.

The biggest problem I see now, is with the Canvas.
I have absolutely no idea how I am going to plug the QGL stuff into Max... at all...
But then again, this GL/context stuff is all rather foreign to me anyways...

The other outstanding issue is with the HTMLView. The URL will need some tweaks to pass "file:///" etc, since currently on Windows, unless it has that, it can't find a file. Then there's the problem of the view only having access to local resources (ie. not web-stuff). Not figured that out yet either, despite trawling google for ideas.

I've been testing it on both the IDE and my smaller BLFBuilder app (the util that comes with my Localization module) and I'm happy with the way things are headed. In fact, for BLFBuilder there is enough of the GUI module finished for it to be a fully working app. Nice :-)

I have noticed a distinct lack of feedback on the forum, which doesn't surprise me at all, to be honest... :-p

At least *I* am having fun :-)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

The end of week 2(Posted 2007-02-12)
Things appear to be generally coming together now.

In fact... this is what the IDE looks like on KDE as of version 0.93 :


Still a long way to go tho, but a lot of the functionality is there.

What's still to do?
Well, Canvas and Stepper are still needing to be started, and HotKeys (all over) aren't implemented yet.
That, and I want to rework the internals of the TreeView and ListBox.
Other than that, I'm pretty happy with things.

Was a long, hard weekend though, and it was bloody hard work to get some of the things working. The worst being that of creating windows which start hidden. But hey, several hours later, and it's mostly working the way I want it to...

Am still struggling a bit with this C++, when it comes to doing casts, and playing with pointers... but I try to remember that I've only been playing with it for two weeks, so I can't be expected to know everything about it...

;-)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Fonts etc.(Posted 2007-02-09)
I think I'm finally getting to grips with this C++/class/pointers malarkey.

So much so that I've got the Font dialog working at last, and as such have applied most of the font stuff to the module, like loading fonts and setting gadgets with fonts. From my tests, it all seems to be working properly, including underlines and strikethrough (or StrikeOut as Qt calls it).

I've also implemented PANEL_GROUPs, which required a little hack because the client area doesn't take into account the group title text - I imagine it must be a bug with Qt? Anyhoo.. I've hardcoded a 15 pixel offset for now, until I ever come up with a better solution.

I quickly threw together the RequestDir dialog before bedtime, which seems to be fine. Next up is one for Files, which I think will complete the "system" driver support.

Still seems like a million and a half things to do though..

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

About time too...(Posted 2007-02-08)
Menus are almost finished now that I know what I'm doing.
Seems I had the C++ right all along, just my Max coding let me down somewhat - or rather, the lack of an empty Rethink() method.... sigh...
Funny tho, that once I added that, it all began working - as if by magic.

Still, if it's taught me something, it is not to assume I can't just make it up as I go :-)

Toolbar icons work great now that I've implemented that idea of mine. I've also had to use a "swap" function which switches red and blue, but I may have to flag that depending on which platform I'm on - maybe. (I'll know when I try the current code on Mac).

Oh well, I guess it's about time for another release...

Day 10 ;-)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Menus... again(Posted 2007-02-07)
Well, I had a go at rewriting the menu stuff last night.
The submenus at least appeared this time, but when I closed the application, glib threw an invalid pointer exception and dumped a backtrace on the console...
So, I guess I'm back to square one with that.

My Icon image problem answer dawned on me as I was heading to bed. Turns out that I'll need to cut each section of the big image up and create QImages out of each of those. The problem turning out to be the fact that there is no pitch parameter, so one simply can't do it the way I could with GTK.
Hopefully I'll have something going by tonight..

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Days, 6-9.(Posted 2007-02-06)
Not often the SuperBowl kicks off an hour into ones birthday... but it was well worth getting up for and having a Monday off :-)

Anyways, it's been a fairly productive weekend. This C++ business is coming on, to a point, and it turns out, as Skid predicted, that much of the coding for the wrapping would be done on that side of things. Which is both good and bad.
For the good, it makes the Blitz code extremely tidy indeed. One call usually does the job. It also means I get to learn more C++. Fortunately, this class stuff is very much like Java, so that end of it has gone very smoothly - so much so, that if something doesn't work first time I end up wondering why... ;-)
On the bad side, it also means that there are things I can't quite get my head around. The MENUs I've all but given up on for now. I simply can't seem to create them without a crash, even though I'm sure that I'm creating everything in exactly the same way as the examples do...
I spent a whole evening trying to figure what was seg-faulting, but alas to no success. The only consolation being that it crashed the same on both Linux and Mac - I would have been disappointed had it worked on one and not the other.

That's one great thing about this Qt, is its consistency across platforms. It ends up working identically on each - or so I've discovered up til now. And, anything that doesn't, it tends to be because I've not done it right to begin with, and have to re-work it til I do.

Leaving the menu stuff as is (that is, not working), I decided to go on with the rest of the Gadgets.
Over the course of the long weekend, I've got ListBox, TreeView and Tabber all working pretty well. ListBox is almost done, apart from icons (of which I haven't started on at all as of yet). Select, Action and Menu events are being raised as expected. The TreeView still has some stuff to sort out, mostly concerning events, but the createtreeview test is running fine barring that.
The Tabber is now working really well, but was a big job to sort out. I wanted to use QTabWidget but because it uses pages of widgets it wasn't compatible with the way Max works. I eventually decided to *base* a brand new widget on bits of that one, using a single page widget that would allow the Max gadgets to use as a parent, and let max worry about showing or hiding the gadgets on it. Once I'd written that and enabled the events, the createtabber test worked great!! (heh, at least on Linux... kind of should try it on Mac before I say any more...)

So, apart from the Menus, I've only the Toolbar and Canvas to do now. I think the Canvas may be a tad out of my league (as the menus appear to be), so I wonder if there are any nice peoples that want to help out...

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Day - 5(Posted 2007-02-02)
Another reasonably productive day on the module front.

Got ScrollBar and TrackBar working - with events.

Tried (in vain) to get the font dialog working without nuking Max. Me thinks it's a user problem - since my C++ experience is only as old as this project...
I think, once I release the code, I will ask - very nicely - for someone to have a look at it and see where I went wrong.

I've also started work on the TextArea gadget. Interestingly enough, most of the code looks like it's going to be on the C++ end of things. Which is fine, as it seems like with C++ I can avoid using pointers most of the time. So far, my TextArea text is at least able to set and add text. But since TextArea is a *big* control as far as access to content goes, it might take a while to get it finished.

Talking of pointers, I also tried my Linux build of Qt4.2.2 for the first time, having been working mainly on Mac and Windows for the last day or so.
Heh.. and wouldn't you know... it didn't bloody work! :-/
Kept segfaulting on application initialization.
It took me about an hour in all, to work out what was wrong, and how to fix it, using the usual tricks of gdb/strace and my helpful "launch the app in the background and try to attach gdb to it before it crashes" script.

The problem came down to how I was passing app-arg parameters into the QApplication constructor. You know, the usual argc and argv things.
Anyway, here's what I've come up with now :
QApplication * qt_init_application() {
	static int i = 0;
	static const char *const empty = "";
	return new QApplication(i, (char **)&empty);
}

which seems to do the job - at least on Linux... I've yet to try it on the other platforms... ;-)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Really cross-platform!(Posted 2007-02-01)
Day 4 - evening.

After my Qt 3 -> 4 port earlier in the day, I wanted to try it on the Mac, since it was going to be an hour or so to build Qt4 on my usual dev environment on Linux.

Once I set up the Imports, (requiring my Mac bmk hack (see Module Tweaks) to allow linking to .dylib files), I was amazed to see it build the module with no errors!
In fact, I was even more amazed when I ran each of the tests in succession... successfully :-)

Qt is *very* portable!

I spent the rest of the evening working through more of the MaxGUI requirements - of which there are a LOT. Your average MaxGUI developer doesn't realize just how much there is to it. Having already made the GTK module, I know that when you think you've covered everything someone will come along and say, such-and-such doesn't work... because I missed it out.

Anyhoo, I got Notify, Proceed and Confirm working. The Color dialog thing. Basic Panels implemented - currently supporting, PANEL_BORDER and PANEL_ACTIVE (sending all mouse events).
PANEL_GROUP is going to be interesting, as I'll have to use a different Qt Widget for that functionality. I've yet to look at keyboard handling.
Oh, and panel background colouring is working too.

The TODO list looks kinda scary though...
ListBox
TreeView
Canvas
ScrollBars
Slider
Stepper
...and lots more.

Oh, and yeah, to get it working on Windows, requires a fix to BMK on that platform to Link properly (that's link issues on two platforms I've met this month).

Max rocks ;-)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Day 4 - Lunchtime(Posted 2007-01-31)
Instead of lunch, I thought I'd see how hard it would be to get the module running on Windows.

Unfortunately, Qt 4.x is not very compatible with Qt 3.3 (which I've used up til now on Linux).

Anyhoo... I've rewritten the C++ glue to work with 4.x ...

...and wouldn't you know... all my tests ran first time :-)

Cross-platform, anyone?

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

Wot no callbacks?(Posted 2007-01-31)
Day 3 ;-)

Good grief !!
Qt has this interesting concept concerned with Signals and Slots. GTK uses callbacks, which I guess is the more traditional way to hook into events and suchlike. Callbacks are very easy to work in Max, since you simply declare a function with the appropriate parameters.

This Signal/Slot malarkey is a tad different. What happens is, a widget can generate a signal for, say, having its text change. If you want to know about it, you need to attach a slot to it, which is effectively just function on a class somewhere. When the signal is raised, all slots attached to it are called.

Well, after much head-scratching, and several abortive attempts at getting something not to seg-fault, I have (miraculously) come up with a way to work it in Max. In fact, it works fantastically well :-)

This was looking like it might be a major obstacle in getting the Qt module working properly. So, on with the show ...

After knocking that wee issue out of the way I beavered on with my "SetPointer" test app (I'm just working through all my GTK tests at the moment). This app presents a ComboBox with a list of pointer styles. You pick one, and the pointer changes.

I did the pointer (Cursor) stuff first, and then found out how ComboBoxes work.
Amazingly, it all worked first time! The ComboBox raised the signal, passed it to my "slot", from which I called back into Max to raise the change event, causing the app to change the pointer :-)

Discounting the fact that Qt is in C++, it's been very much easier to get working than GTK...

... so far...

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax

And so it begins(Posted 2007-01-30)
Just when you thought it was safe to go back into Linux...

...along comes yet another pet project by that fool who seems to have nothing better to do than generate new max modules for a living. (Which I really need to consider stopping at some point, given the sheer number of them that need to be maintained...)

Anyhoo, back to the module in hand.

Qt.

If you don't know already, it's the GUI framework/toolkit by Trolltech that KDE is built on. It is also, apparently, cross-platform.
Since I managed to create a (mostly) working GUI module of GTK, I thought I might have a stab (in the dark) at building the "other" one too.

My main reason for not trying this sooner than now (I've had a look at it before), is that the API is in C++, rather than the C that GTK is built on. Why would this be a problem? Well, given that I know bugger-all about C++ (and not too much in fact about C), it actually scared the bejeebees out of me to think that I could sit down and hack something workable out of it.

But hey, I like a challenge :-)
...added to the fact that since the FLTK GUI is C++ based, I thought I could use that as a reference on how get my Max stuff to communicate with the C++ stuff.

Now, some people would probably sit down with a C++ book at this point and learn how it works first. But I find that I just *can't* sit and read a reference book, however good it is, without starting to yawn by the end of the first paragraph, and ready for a nap by the bottom of the page. There are two wonderfully new-looking C++ books on my bookshelf that can confirm this.
And then there are the people who just dive in, hoping that it'll all eventually make sense somehow. That's me.
It's certainly not the most economical method, as it involves a *lot* of trial and error and rewrites. But after all the effort, things kind of come together, and my wee head thinks, "ahhhh, so *that* is how you create a method for a C++ class" :-)

Then comes the fun part of hooking into the API and having stuff happen.
It's a great feeling when you make your first API-driven window pop up on the screen. It's an even better feeling when you have your window pop up on the screen without subsequently seg-faulting ;-)

The route I've decided to take with this module is to base it on my Type structure for GTK. Why not? It's all there already, so I only have to change the API calls.
It certainly makes for some speedy development, especially if you've been there before.
By the end of day-1, I had a window raising Max Move, Size and Close events.

I was going to work on filling out the window with statusbar and the like last night, but I was getting tired of windows, so instead opted for the beginnings of the gadgets...





:o)

-+ Brucey +-

Come to Brucey's Modules for useful BlitzMax Modules!! . . . See my Modules Worklog - wxMax -

* The Definitive Module List * Qt-On-BlitzMax