July 24, 2009 | Filed Under Qt4 | No Comments
Just pushed at GitHub the first draft of the Qt4 Google Contacts Service…
Contacts APIs allows client applications to view and update Contacts content in the form of Google Data API feeds. Your client application can request a list of a user’s contacts, edit or delete content in an existing contact.
// Setup Contact
THGoogleContact *contact = new THGoogleContact;
contact->setFullName("John Doe");
THGoogleIm *im = new THGoogleIm;
im->setRel(THGoogleIm::relWork());
im->setAddress("john.doe@aim.com");
im->setProtocol(THGoogleIm::protocolAim());
contact->addImAddress(im);
THGoogleEmail *email = new THGoogleEmail;
email->setAddress("john.doe@mail.com");
email->setRel(THGoogleEmail::relWork());
contact->addEmailAddress(email);
// Insert Contact
THGoogleContactsService *gContacts = new THGoogleContactsService;
gContacts->setAuthToken(...);
gContacts->insertContact(contact);
Take a look at contacttest.cpp for a more complete usage example.
July 18, 2009 | Filed Under OpenMoko | 3 Comments
Today, I’ve spent half of my day to do something for the “Moko Touch” Project. I need a simple keyboard that I can use without use a stylus or a toothpick. I need something “Bigger”, so I’ve made a couple of experiments and this is the “best” result. Maybe it hasn’t a great look’n feel now but it’s really usable.

Vertical Keyboard (480x295 px)
The concept is really simple. Use less space as possible for the keyboard and use the “Maximum Size” available for the buttons. And as you can see with just 12 buttons you’ve all your Letters, numbers and Symbols in the smallest usable space (480×295 px for the Vertical Keyboard and 640×195 px for the Horizontal Keyboard).

Horizontal Keyboard (640x195 px)
But as always there’s a “Bad side”. You’ve to tap twice to pike on key, for Example: Tap on “QWER” button on the “12 keys keyboard” a 4×4 box will appear, and you’ll have to tap on the key to select it. So for each letter you’ve to tap twice. But maybe there’s no type mistake even if you’re using your phone while you’re running
This is just the 1st concept of the Moko Touch Keyboard. If you’ve ideas to improve it, send a comment or a mail. It will be really appreciated. Thanks!
July 14, 2009 | Filed Under OpenGL | No Comments
Second hour with OpenGL, last time I’ve written a simple 2D example to learn what Vertex are, and now a little step forward using 3D, Rotation, Translation and Texts.

Using GLUT writing 2D texts is really simple, and here is how to do it. Setup Text Color, X and Y Location, pick up a font and set your string, and it’s done.
glColor3f(1.0, 0.0, 0.0);
glRasterPos2f(-4.6, 2.3);
glutBitmapString(GLUT_BITMAP_TIMES_ROMAN_24, 'Hello Text');
To handle left, right, up, down keys to move the cube use the glutSpecialFunc() that allows you to handle GLUT_KEY_LEFT, GLUT_KEY_RIGHT, GLUT_KEY_UP, GLUT_KEY_DOWN keys and others. Translation and rotation are made using glTranslatef() and glRotatef().
The source code is available here: Python OpenGL 3D Cube Source Code.
July 12, 2009 | Filed Under OpenGL | No Comments
I’m not a Computer Graphics fan, but I’ve spent my the last year working on Report Engine, and User Interfaces… drawLine, drawRect.. setLocation… (I don’t know.. I’m a malloc/memset boy).
But I need to learn more about Computer Graphics for the future, and today I’ve started playing with OpenGL… No more 2D points!!!

Below you can see a couple of lines of code that draws the example above…
static void drawTriangle (void) {
glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f( 0.0f, 0.6f, 0.0f);
glVertex3f(-0.2f, -0.3f, 0.0f);
glVertex3f( 0.2f, -0.3f, 0.0f);
glEnd();
}
static void drawSquare (void) {
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_TRIANGLE_FAN);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.0f, 0.0f);
glVertex3f(0.5f, 0.5f, 0.0f);
glVertex3f(0.0f, 0.5f, 0.0f);
glEnd();
}
static void drawSquareMode2 (void) {
const GLfloat squareVertices[] = {
-0.2, 0.2, 0.2,
-0.2, -0.2, 0.2,
0.2, -0.2, 0.2,
0.2, 0.2, 0.2
};
glColor3f(0.0f, 1.0f, 0.0f);
glVertexPointer(3, GL_FLOAT, 0, squareVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
I’ve used NSOpenGLView to display the GL, so the drawing code is inside a drawRect method.
- (void)drawRect:(NSRect)bounds {
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
glTranslatef(-0.2f, 0.0f, 0.0f);
drawTriangle();
glTranslatef(0.2f, 0.0f, 0.0f);
drawSquare();
drawSquareMode2();
glFlush();
}
July 12, 2009 | Filed Under Qt4 | No Comments
I’ve received a couple of requests about Google Maps and Qt4. Today I’ve written a simple Widget that allows you to interact with Google Maps and Google Geocoder. You can set Map Type (Roadmap, Satellite, Terrain and Hybrid), you can set your center Coordinate, add Markers, add Info Windows get the User Click Coordinates and other things that Google Maps allows to do.

With few lines of code, you can interact with Google Maps, and below you can see how to do it. (Other methods and overloads are available, check the GKMapView.h in the Source Code packet, link is at the end of the post).
GKMapView mapView;
// Change the Default MapType (Roadmap, Satellite, Terrain, Hybrid)
mapView.setMapType(GKMapTypeSatellite);
// Use Geocoder to Get Location from Address or Viceversa.
// See the Signals locationFound, locationNotFound() and
// addressFound(), addressNotFound() to get your results.
mapView.locationFromAddress("San Mateo");
mapView.addressFromLocation(32.718834, -117.164);
// Add Marker With Info Window at Specified Address (or Location)
mapView.addMarkerWithWindow("Bedford MA Marker",
"<b>Bedford MA</b> Marker",
"Bedford MA");
// Add Info Window without Marker using Address or Coordinates
mapView.addInfoWindow("Hello from <b>San Mateo</b>", "San Mateo");
mapView.addInfoWindow("Hello from <b>San Diego</b>", 32.718834, -117.164);
// Change your Current Location
mapView.setLocation("Phoenix AZ");
The Source Code is available Here with a small example: Qt4 Google Map View Source Code.