Author Topic: wxImage components  (Read 12814 times)

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
wxImage components
« on: April 19, 2009, 03:19:43 am »
I needed wxImage and wxImageList components for a recent project, and I wanted to define the images in wxSmith, and have the image files compiled directly into the source code.

So I created a new plugin for wxSmith.

This plugin provides wxImage and wxImageList as components for wxSmith, and allows the images to be selected at design-time, and to compile the images directly into the source code file.  This allows you to distribute your program without the need for an external image file or external resource file.

The images are all stored internally as XPM image files.  The images may be stored directly in the source code C++ file, or used as a "#include" file.

The wxImage component is normally used to hold small-to-medium sized images, but is capable of storing any size image.  However, larger images (for example 400 x 400 pixels) will show a noticible slowing of the wxSmith editor.

The component wxImageList has an integrated image-list-editor dialog that lets the programmer to add or delete images from an image-list, and to set an optional transparent color for added images.

For more info, see the Readme.txt file inside the zip.

This code has been developed and tested in MS Windows, but I think it should work under other OS's with few changes.

As always, I welcome any suggestions for improvement.  Feel free to use it (or abuse it) as you see fit.

Ringo



[attachment deleted by admin]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: wxImage components
« Reply #1 on: April 19, 2009, 09:21:45 am »
thanks, sounds great, will try it out.

Can it also be used for a simple icon creation ?


Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: wxImage components
« Reply #2 on: April 20, 2009, 12:30:32 am »
thanks, sounds great, will try it out.

Can it also be used for a simple icon creation ?



No, sorry, this editor just adds or removes bitmaps from an image-list.

However ... funny you should mention it.  I'm working on an icon editor to add to wxSmith for part of my current project.  When I have it working, I'll upload it and you can try it out.

Ringo

Offline JGM

  • Lives here!
  • ****
  • Posts: 518
  • Got to practice :)
Re: wxImage components
« Reply #3 on: April 23, 2009, 12:08:22 am »
really cool your work makes codeblocks even a more complete IDE

Offline Ganbito

  • Multiple posting newcomer
  • *
  • Posts: 79
Re: wxImage components
« Reply #4 on: April 24, 2009, 12:12:37 am »
It sounds great!

I've downloaded it to my Ubuntu, for give it a try (a fast try). As it is windows-only, I've created a project for build it on linux and tried to solve the errors I've found, but couldn't make it to work at this first attemp. I will give another try soon.

By the way, have you any plans to support linux (early) so I have only wait a little?  :D

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: wxImage components
« Reply #5 on: April 27, 2009, 06:45:43 pm »
By the way, have you any plans to support linux (early) so I have only wait a little?  :D

Due to limits where I work, I don't use C::B on a Linux machine; I do all developement on Windows, then when I need to build on Linux, I use the Makefile Generator plugin to make a Makefile.gen, then transfer all the code (and the Makefile.gen) to a Linux machine and compile it there.

Clear as mud, right?  Believe me, I have little choice in this matter.

So, I probably will not be working very hard to support Linux for the IDE, but I will be adding (and making available) several more components for wxSmith (I'm now working on the wxTreeCtrl to use bitmaps on the tree items; an icon & bitmap editor for wxSmith; and wxSheet which is an expaned wxGrid control).

Ringo

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxImage components
« Reply #6 on: April 28, 2009, 10:28:24 am »
Yesterday I tried to build it on linux the first time.
After some tweaking, it compiles and seems to build correctly.
Nevertheless, there seems to be an issue with the wxImageList dialog (eating up my cpu-resources and has to be killed), I hope I find time to look into it later.

I can post a patch to make it work with trunk from inside contrib-plugins tree this evening, if anyone is interested.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: wxImage components
« Reply #7 on: April 28, 2009, 12:33:28 pm »
if anyone is interested.
Ping! :-)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxImage components
« Reply #8 on: April 28, 2009, 01:25:33 pm »
if anyone is interested.
Ping! :-)

Here it is.

The same source-code works on windows (global cb-variable has to be set and *.zip and *.dll have to be copied manually).

On linux no global variable is needed.

If wanted the cbp-file has to be added to contrib-plugins workspace.

Nevertheless, there seems to be an issue with the wxImageList dialog (eating up my cpu-resources and has to be killed), I hope I find time to look into it later.

This error does not occur on windows, so it's is most likely not caused by my (marginal) changes.

[attachment deleted by admin]

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: wxImage components
« Reply #9 on: April 29, 2009, 07:47:55 am »
Nevertheless, there seems to be an issue with the wxImageList dialog (eating up my cpu-resources and has to be killed), I hope I find time to look into it later.

I reviewed the dialog code, and the only thing I can think of that might have something to do with this is the "OnPaint" events, which might get called non-stop on some systems.

I copied the code over to a 32-bit Red Hat Linux machine (specifically required for a customer) and with a few mods (done by hand) was able to make it compile.  It runs fine, with no cpu thrashing.  My Windows machine is running XP, and both machines are using wxWidgets 2.8

Ringo

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxImage components
« Reply #10 on: April 29, 2009, 10:40:01 am »
I reviewed the dialog code, and the only thing I can think of that might have something to do with this is the "OnPaint" events, which might get called non-stop on some systems.

If I saw it right yesterday evening (it was a little late), it's indeed in "OnPaint", but on 64-bit linux, and that can make a difference.
I will have a look into it this evening.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: wxImage components
« Reply #11 on: May 02, 2009, 08:59:22 pm »
Sorry for the late response.

The following patch works for me:

Code
--- wxSmithImage.orig/wxsImageListDialog/wxsImageListDialog.cpp	2009-04-13 19:31:06.000000000 +0200
+++ wxSmithImage.work/wxsImageListDialog/wxsImageListDialog.cpp 2009-05-02 20:42:34.000000000 +0200
@@ -852,7 +852,8 @@
 
     iw = aBitmap.GetWidth();
     ih = aBitmap.GetHeight();
-
+    if(iw < 0 || ih < 0)
+        return;
     aPanel->GetClientSize(&pw, &ph);
 
 // set scale to fit in panel

wxWidgets returns -1 for as width and height for empty bitmaps (at least on 64-bit linux), that leads to endless while-loops.

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: wxImage components
« Reply #12 on: May 03, 2009, 08:45:43 am »
The following patch works for me:

     iw = aBitmap.GetWidth();
     ih = aBitmap.GetHeight();
-
+    if(iw < 0 || ih < 0)
+        return;
     aPanel->GetClientSize(&pw, &ph);

Good catch!  I drink a toast to your coding acumen (please pour yourself a beer).

I added your patch to the code, and now I'm searching for similar code in all my projects.

Ringo

Offline rcoll

  • Almost regular
  • **
  • Posts: 150
Re: wxImage components
« Reply #13 on: May 17, 2009, 06:56:48 am »
This is an update to the earlier wxSmithImage package; this update contains a new component "wxImageTreeCtrl" that allows an individual bitmap from a wxImageList to be assigned to each item in the tree.

The wxImageTreeCtrl uses a much better editor/dialog to give the programmer greater control over the appearance of each item in the tree.

The wxBitmapCombo has been updated to use a much better editor/dialog also.

As before, these items have been developed and tested only on Windows XP, but I believe they should work with little or no changes on Linux.

See the ReadMe.txt file for details on using each component.

Everything was developed using wxWidgets 2.8; I don't know how it will work with 2.9 or later.

If you have any suggestions for improvement, please let me know and I'll make updates as soon as I can.

Ringo

[attachment deleted by admin]