Tag Archive: c#


When I purchased Foundations of Qt Development (Expert’s Voice in Open Source) by Johan Thelin a few months back, I hoped to get to it right away but work and life diverted my attention. Today at lunch I dived into it. Even though I’m still going through chapter 1, I think I can give a hint of it:

Foundations of Qt® Development (Expert’s Voice in Open Source) is well written. He assumes that you have a little bit of C++ knowledge, avoiding into the trap that so many other authors do. You wouldn’t believe how many technical books I have where the first half or more of the book is simply a rehash of the basics. Forget that!

What I really like is that when he shows you an example of code, he explains why you would want to write it this way and how it differs from the Standard Template Language (STL – see C++ Programming Language, The (3rd Edition)). Where there are performance gains or penalties of using Qt instead of STL, he demonstrates it.

I never realized just how easy it is to write C++ using the Qt framework! Just the Signals and Slots alone make it very very powerful and that’s just the beginning. I’m completely blown away :)

I wrote a simple image viewer that will load a photo image into a Gtk.Image widget using a Gdk.Pixbuf.  I then added a tool bar with four clickable icons.  Zoom out, zoom in, fit to window and original size.

All but the fit to window worked well.  When I pulled the width and height from image1.GetSizeRequest(out width, out height), width & height were returned as -1.  Not helpful.  Google didn’t give me many clues either :(

What I needed was something that would provide the visible area of the Gdk.Image widget:

In order to get the visible area, we need to:

  • upcast Gtk.Image to a Gtk.GdkWindow
  • retrieve a Gdk.Region from the VisibleRegion method
  • retrieve the first Gdk.Rectangle from the array returned from the visibleRegion.GetRectangles method
  • extract the Height and Width from the Gdk.Rectangle

Now that we have the height and the width of the visible area of the Gtk.Image widget, we need to scale the image (Gdk.Pixbuf) while keeping the aspect. Assigning the image to the Gtk.Image widget will automatically redraw itself.

protected virtual void zoomToWindow (object sender, System.EventArgs e)
{
   if (image1.Pixbuf != null) {
     int new_width, new_height;
     int height = image1.Pixbuf.Height;
     int width = image1.Pixbuf.Width;

     Gdk.Region visibleRegion = image1.GdkWindow.VisibleRegion;
     Gdk.Rectangle rectangle = visibleRegion.GetRectangles()[0];
     new_height = rectangle.Height;
     new_width = rectangle.Width;
     scaleImage(height, width, ref new_height, ref new_width, 0);
     image1.Pixbuf = pictureBuf.ScaleSimple(new_width, new_height, Gdk.InterpType.Bilinear);
   }
}

There we go :)
While the code above is C#, the same principle goes for any language that uses Gtk.

The following is MY perception of Sybase’s PowerBuilder:

Years ago PowerBuilder was king.  No one could touch it.  It was relatively inexpensive.  Microsoft’s Visual Basic matured and the Pascal based Borland’s Delphi was released.  Then it fell and fall it did.

Sybase

Sybase

As it was falling from the throne Sybase purchased Powersoft, makers of PowerBuilder.  As the the market share continued to shrink, PowerBuilder developers had more difficulty in finding new projects.  Most new development was written in Visual Basic or Java.

Years went by with marketing of PowerBuilder little more than the occasional road show, TechWave presentations and the ISUG Technical Journal ads catered towards existing customers.  Little to no effort was put forth by Sybase to gain new PowerBuilder customers.

During this week’s Sybase TechWave, PowerBuilder version 12 was released.  It has all the whistles and kitchen sinks you could ask for.   An amazing tool for development!  Too bad no one outside of the die hard PowerBuilder programmers will use it.

Blasphemy!  Heretic!

Consider this:

Sybase owns PowerBuilder.  It owns the PowerBuilder software, PowerBuilder language, PowerScript, the PowerBuilder vm, and everything PowerBuilder.

No problem right?

What will happen to PowerBuilder when Sybase is bought out by another company?  Products with tiny market share like PowerBuilder would likely be killed or in a state of limbo for several years.  Anyone remember what happened when IBM bought Informix?

Do you really want to bet your career and business on a software development tool that is locked to a single smallish vendor?

Maybe, perhaps, if Sybase were to release the PowerBuilder 4GL language and PowerScript to the world like Microsoft did with the C# and Visual Basic languages and Sun with Java…   Perhaps if Sybase would allow 3rd parties to develop tools based around the PowerBuilder language royalty free…

Sybase:  PLEASE FREE THE POWERBUILDER 4GL LANGUAGE!

I mean, really, what benefit could Sybase have to cripple the PowerBuilder developers?