PDF-версия статьи “Пишем скринсейвер на wxWidgets”

Выложил русскую PDF-версию статьи “Пишем скринсейвер на wxWidgets“. В статье рассмотрено:

  • Создание собственных компонентов
  • Отрисовка графики, double-buffering с использованием wxBufferedPaintDC
  • Обработка событий от мыши и клавиатуры
  • Обработка аргументов командной строки с помощью wxCmdLineParser
  • Хостинг wxWidgets-окна на внешнем нативном окне

Скачать статью “Пишем скринсейвер на wxWidgets”.
Скачать исходный код примера и проекты для Win32 и Windows Mobile + исполняемый файл для Win32.

wxJSON 1.0 Released

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition – December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

This is the first stable release of the wxJSON library. The major version had changed because I introduced some compatibility breaks with the old 0.x versions as well as some new features.
To know more about this read this page


Отправка SMS под wxWinCE с помощью CE MAPI

Появилась необходимость программно отправлять SMS с телефона под управлением Windows Mobile. Решил не изобретать велосипед и поиспользовать MAPI для этих целей. После недолгих поисков набрел на эту статью на CodeProject. Немного переделал код для использования с wxWidgets. Вот что получилось
Continue reading…

How to Draw Gradient Buttons (wxWidgets Way)

Several days ago I found How to draw gradient buttons post at Native Mobile blog. Looks nice but I think that using GradienFill() is not very convenient because you need to fill all these TRIVERTEX structures. wxWidgets provides more convenient way of drawing gradients by using wxDC::GradientFillLinear(). Here is how it can be done in wxWidgets:
Continue reading…

Getting Acquainted with Document/View Framework – Simple Image Viewer

In my previous posts here and here I showed how to create a simple application which uses Document/View framework. Now I’m going to show more complex example – image viewer with scrolling and selection rectangle. As far as I can see from wxForum, implementation of selection-related functionality is some kind of complex but very useful task.

So, let’s start from simple part. The simplest task here is modification of our wxDocument-related class.

Continue reading…

wxJSON 0.5.0 Released

This wxJSON release adds support for 64-bits integers on those platforms that have native support for it such as, for example, Windows and GNU/Linux.

You can disable 64-bits integer support if you do not need (or do not want) it. The new version is compatible wih the past: if you do not need 64-bits integers you can still use this new version of the library without the need to rewrite your application.

To know more about the new feature read the this page:

Реализация Job Queue на wxWidgets (+исходник)

При работе с потоками часто приходится делать кучу однотипных задач: создавать класс, производный от wxThread, реализовывать метод Entry() для этого класса, синхронизацию с главным потоком и т.д.

Eran, автор CodeLite IDE поделился кодом класса JobQueue, который реализует пул потоков и позволяет выполнять задачи в фоновом режиме.

class MyJob : public Job {
        // Implement your processing code here
        void Process() {
                wxPrintf(wxT("Just doing my work...n"));

// define some custom job with progress report
class MyJobWithProgress : public Job {
        MyJobWithProgress(wxEvtHandler *parent) : Job(parent){}
        // Implement your processing code here
        void Process() {
                // report to parent that we are at stage 0
                Post(0, wxT("Stage Zero"));
                // do the work
                wxPrintf(wxT("Just doing my work...n"));
                // report to parent that we are at stage 1
                Post(1, wxT("Stage Zero Completed!"));

// somewhere in your code, start the JobQueue
// for the demo we use pool of size 5

// whenever you want to process MyJob(), just create new instance of MyJob() and add it to the JobQueue
JobQueueSingleton::Instance()->AddJob( new MyJob() );

// at shutdown stop the job queue and release all its resources

// OR, you can use JobQueue directly without the JobQueueSingleton wrapper class
// so you could have multiple instances of JobQueue 

Главный поток получает уведомления таким вот образом:

// in the event table

void MyFrame::OnJobStatus(wxCommandEvent &e)
wxString msg;
msg << wxT("Job progress: Stage: ") << e.GetInt() << wxT(" Message: ") << e.GetString(); wxLogMessage(msg) } [/sourcecode] Скачать исходный код
Читать обсуждение на wxForum

wxJSON 0.4 Released

This release adds the ‘copy-on-write’ feature to the copy ctor and assignment operator of JSON value class.
Note that this new feature only affects the internal representation of JSON values and does not add new features in the class’s interface.
Also note that for JSON value objects, COW is not as efficient as expected.
To know more about this topic read this page:

The wxJSON library is now complete and this release should be considered a final beta release.
JSON data format is very stable. It is accredited to be stable forever or, at least, until programming language’s variables are based on numbers, strings, booleans, structures and arrays.

No other feature should have to be added to the library and I think that, after a few months used for discovering and fixing bugs, I will release the stable version 1.0

This will be the good occasion to, eventually, break the compatibility with the old versions 0.x by changing memberfunction’s names and/or parameters.
If you have any comment, suggestion or hint, feel free to write to me or post an answer to this topic.