Sunday, December 23, 2007

Changes to wxWidgets 2.9 SVN repo

To get everything to compile correctly under Maemo 4.0 with the new Hildon-1 library and ScratchBox, I needed to do the following:

- Change pkg-config files to use new library, without needing to edit configure script
> ln -s /usr/lib/pkgconfig/hildon-1.pc /usr/lib/pkgconfig/hildon-lgpl.pc

- Edit source files for compatibility.
Replace any hildon #include statements with #include <hildon/hildon.h>

I needed to edit the following files:
M src/gtk/checklst.cpp
M src/gtk/frame.cpp
M src/gtk/toplevel.cpp
M src/gtk/msgdlg.cpp
M src/gtk/hildon/notifmsg.cpp
M src/gtk/colordlg.cpp
M src/gtk/app.cpp

I'll provide a full listing of the changes after the directions are complete.

- Configure
> ./configure --with-hildon

- Make
> make && make install
(this will put the includes and utils and libs in /usr/local/)

That should pretty much do it. To transfer it to the tablet, I just tar/gzip it up and dump the whole ScratchBox /usr/local into the tablet's /usr/local, then add /usr/local/lib to /etc/ld.so.conf, and run ldconfig as root.

If you don't want to compile this all yourself, I've posted the tar.gz:

http://caflor.net/iosix/wxMaemo4-2.9.tar.gz
(6347243 bytes, md5: c2fcc4c646b67f1cfa3506a479deffdc)

This also includes nano (the useful command-line text editor, very much like pico).

To extract on either ScratchBox or the N800/N810 (need xterm or ssh on the tablet):
> cd /usr/local
> wget http://caflor.net/iosix/wxMaemo4-2.9.tar.gz
> tar -zxf wxMaemo4-2.9.tar.gz

Any applications you run under ScratchBox may crash unless you run them like this:
> run-standalone.sh wxWidgets/samples/dialogs/dialogs

Thanks.



Now for the changes (I'm hoping someone with a. write access to wxWidgets SVN and b. a good idea of how to integrate this portably will merge these into the main SVN) :

-- This is to allow the checkboxes in a list with a select capability to work correctly. They are not wide enough for the Hildon checkboxes by default.

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff checklst.cpp
Index: checklst.cpp
===================================================================
--- checklst.cpp (revision 50770)
+++ checklst.cpp (working copy)
@@ -87,7 +87,7 @@
gtk_tree_view_column_new_with_attributes( "", renderer,
"active", 0,
NULL );
- gtk_tree_view_column_set_fixed_width(column, 20);
+ gtk_tree_view_column_set_fixed_width(column, 40); // hildon
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_column_set_clickable(column, TRUE);


-- Compatibility with Hildon-1 library

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff frame.cpp
Index: frame.cpp
===================================================================
--- frame.cpp (revision 50770)
+++ frame.cpp (working copy)
@@ -21,7 +21,7 @@
#include <gtk/gtk.h>

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-window.h>
+ #include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON

// ----------------------------------------------------------------------------


-- To make wxWidgets see the window sizes correctly, as it seems to be off by 24 pixels in the non-fullscreen view. This would cause widgets to be drawn off-screen unintentionally.

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff toplevel.cpp
Index: toplevel.cpp
===================================================================
--- toplevel.cpp (revision 50770)
+++ toplevel.cpp (working copy)
@@ -46,8 +46,7 @@
#include <X11/Xatom.h>

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-program.h>
- #include <hildon-widgets/hildon-window.h>
+ #include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON

// ----------------------------------------------------------------------------
@@ -905,8 +904,22 @@
size -= m_decorSize;
if (size.x < 0) size.x = 0;
if (size.y < 0) size.y = 0;
- if (width) *width = size.x;
- if (height) *height = size.y;
+ if (width) {
+ if (size.x == 720)
+ *width = 696;
+ else
+ *width = size.x;
+ }
+ if (height) {
+ if (size.y == 420)
+ *height = 396;
+ else if (size.y == 270)
+ *height = 246;
+ else
+ *height = size.y;
+ }
}

void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags )


-- Compatibility with Hildon-1 library

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff msgdlg.cpp
Index: msgdlg.cpp
===================================================================
--- msgdlg.cpp (revision 50770)
+++ msgdlg.cpp (working copy)
@@ -28,7 +28,7 @@
#include <gtk/gtk.h>

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-note.h>
+ #include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON

IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
@@ -67,7 +67,7 @@
m_widget = (GtkWidget *)g_object_new
(
HILDON_TYPE_NOTE,
- "note_type", HILDON_NOTE_CONFIRMATION_BUTTON_TYPE,
+ "note_type", HILDON_NOTE_TYPE_CONFIRMATION_BUTTON,
"description", (const char *)GetFullMessage().utf8_str(),
"icon", stockIcon,
NULL


-- Compatibility with Hildon-1 library

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff hildon/notifmsg.cpp
Index: hildon/notifmsg.cpp
===================================================================
--- hildon/notifmsg.cpp (revision 50770)
+++ hildon/notifmsg.cpp (working copy)
@@ -31,7 +31,7 @@
#include "wx/notifmsg.h"
#include "wx/toplevel.h"

-#include <hildon-widgets/hildon-banner.h>
+#include <hildon/hildon.h>

// ============================================================================
// wxNotificationMessage implementation


-- Compatibility with Hildon-1 library

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff app.cpp
Index: app.cpp
===================================================================
--- app.cpp (revision 50770)
+++ app.cpp (working copy)
@@ -30,7 +30,7 @@
#include "wx/apptrait.h"

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-program.h>
+ #include <hildon/hildon.h>
#endif // wxUSE_LIBHILDON

#include <gdk/gdkx.h>


-- This was the big one; much of the color API was changed from hildon-lgpl to hildon-1... Also, the new include files do not seem to work equally well with C and C++...

[sbox-CHINOOK_ARMEL: ~/wxWidgets/src/gtk] > svn diff colordlg.cpp
Index: colordlg.cpp
===================================================================
--- colordlg.cpp (revision 50770)
+++ colordlg.cpp (working copy)
@@ -27,7 +27,9 @@
#include "wx/gtk/private.h"

#if wxUSE_LIBHILDON
- #include <hildon-widgets/hildon-color-selector.h>
+extern "C" {
+ #include <hildon/hildon.h>
+}
#endif // wxUSE_LIBHILDON

IMPLEMENT_DYNAMIC_CLASS(wxColourDialog, wxDialog)
@@ -47,7 +49,7 @@
: NULL;

#if wxUSE_LIBHILDON
- m_widget = hildon_color_selector_new(parentGTK);
+ m_widget = hildon_color_chooser_dialog_new();
#else // !wxUSE_LIBHILDON
wxString title(_("Choose colour"));
m_widget = gtk_color_selection_dialog_new(wxGTK_CONV(title));
@@ -96,8 +98,17 @@
: NULL;

#if wxUSE_LIBHILDON
- HildonColorSelector * const sel = HILDON_COLOR_SELECTOR(m_widget);
- hildon_color_selector_set_color(sel, wx_const_cast(GdkColor *, col));
+ GdkColor clr;
+ if (col)
+ clr = *col;
+ else {
+ clr.pixel = 0;
+ clr.red = 32768;
+ clr.green = 32768;
+ clr.blue = 32768;
+ }
+
+ hildon_color_chooser_dialog_set_color((HildonColorChooserDialog *)m_widget, &clr);
#else // !wxUSE_LIBHILDON
GtkColorSelection *sel =
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);
@@ -129,10 +140,23 @@
void wxColourDialog::DialogToColourData()
{
#if wxUSE_LIBHILDON
- HildonColorSelector * const sel = HILDON_COLOR_SELECTOR(m_widget);
- const GdkColor * const clr = hildon_color_selector_get_color(sel);
- if ( clr )
- m_data.SetColour(*clr);
+ const GdkColor * const
+ col = m_data.GetColour().Ok() ? m_data.GetColour().GetColor()
+ : NULL;
+
+ GdkColor clr;
+ if (col)
+ clr = *col;
+ else {
+ clr.pixel = 0;
+ clr.red = 32768;
+ clr.green = 32768;
+ clr.blue = 32768;
+ }
+ GdkColor new_color = clr;
+ hildon_color_chooser_dialog_get_color((HildonColorChooserDialog *)m_widget, &new_color);
+
+ m_data.SetColour(new_color);
#else // !wxUSE_LIBHILDON
GtkColorSelection *sel =
GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(m_widget)->colorsel);

Tuesday, December 18, 2007

First, some screenshots

I'm working on getting wxWidgets to work nicely under OS2008 on the n800 (should work on n810 as well). Some nice work was done by a few developers previously, but as far as I can tell, it's for the old hildon-lgpl library, instead of the new hildon-1 library. Here are some links to those posts:

http://wxwidgets.blogspot.com/2007/11/hildonizing-wxgtk.html

http://maemogeek.blogspot.com/2007/12/wxgtk-working-on-maemo.html

I've spent the past few days trying to further modify wxWidgets to behave nicely on Maemo 4.x; here are some results from the dialogs sample. I'll post the details of my changes and some library binaries soon, once I've cleaned them up a bit. From what I can tell, wxWidgets is getting an incorrect impression of the window space available in normal (non-fullscreen) mode, seeing 720x420 pixels, when it's supposed to be seeing 696x396. I had to modify the TopLevelWindow code to return 696x396 if it thinks it's 720x420, and that keeps the widgets on the screen... Full screen seems behaved. A key issue is that the wxPosition for windows should be (0,0) or weird things will happen (I think since Hildon windows don't have visible borders, it just looks offset...). The dialogs look like they're working OK.

The window layout for Maemo 4.x.

The file and directory widgets seem to crash the dialogs sample when launched in the simulator, but not on the n800.

Without further ado, here are some screenshots, from the actual n800 (instead of the simulator):

I had to widen the constant for the checkbox column from 20 pixels to 40 pixels.




I needed to convert all of the HildonColorSelector stuff to HildonColorChooserDialog stuff. The color choosing dialog seems to work well. However, the GTK one is actually pretty cool and might be better...


Font selection works (barely fits) ... if you increase the font size too much it starts to cover up the scroll bars, however.


Just to show that the menus behave nicely and don't stack on top of each other.



This should probably be replaced with the Hildon file dialog ... this one has a tendency to barely fit, and also doesn't present the user-friendly Nokia filesystem, instead showing a standard Unix layout...



Multiple-select doesn't really work, probably since we don't have a shift or control key...


This one just does not fit...

And it's even worse if you try to type something ... definitely something to work on...







The error log dialog boxes look downright pretty and very well-integrated.






The mini-frames are a disaster - you can't even close 'em...



There's a funny little blue line up above the word 'Load' ... not sure what that's about...

Notifications work surprisingly well ... I couldn't really capture the 'request attention' one but it looks like the application icon is pulsing.





So, that's where I'm at. Thanks.

-Robert