Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
About The Best Formula In The World
Architecture details
Benchmarks
Books
By Reference Argument Passing
Compatibility between versions
Creating And Using Libraries
Database Datatype Mapping
Database Request Quoting
Date & time management
Dates and calendars
DBus and Gambas
Differences Between Shell And Exec
Differences From Visual Basic
Distributions & Operating Systems
Drag & Drop
DrawingArea Internal Behaviour
External functions datatype mapping
Frequently Asked Questions
Gambas Farm Server Protocol
Gambas Mailing List Netiquette
Gambas Markdown Syntax
Gambas Naming Conventions
Gambas Object Model
Gambas Scripting
Gambas Server Pages
Gambas Unit Testing
Gambas Wiki Markup Syntax
Getting Started With Gambas
Hall Of Fame
Housekeeping, cleaning up
Image Management In Gambas
Including Help Comments in Source Code
Interpreter limits
Introduction
Just In Time Compiler
Just In Time Compiler (old version)
License
Localisation and Internationalization
Mailing Lists & Forums
Naming Conventions
Network Programming
ODBC Component Documentation
PCRE Pattern Syntax
Porting from Gambas 2 to Gambas 3
Previous News
Project Directory Structure
Release Notes
Reporting a problem, a bug or a crash
Rich Text Syntax
Screenshots
Text highlighting definition file syntax
The Program has stopped unexpectedly by raising signal #11
Variable Naming Convention
WebPage Syntax
Web site home page
What Is Gambas?
Window & Form Management
Window Activation & Deactivation
Window Life Cycle
XML APIs
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

DrawingArea Internal Behaviour

Here is more information about the DrawingArea internal stuffs.

It is related to the way qt manages draw events sent by the X Server.

First, you must know that a draw event is a rectangle in your window that you must redraw.

Then there is two ways:

  1. All X11 draw events are merged by QT into a Region object, that is not rectangular, and then the QT paint event is called, and thus the Gambas Draw event. All drawings during the draw event handler will be clipped by this region.

    It worked like that before my modifications.

  2. QT merges nothing, and you get one Gambas draw event for each X11 draw event. The drawing is clipped by the rectangle.

    It works like that now.

Why doing that ?

Logically, during the drawing event handler, you have to draw the less possible things to speed up the drawing.

The only way in Gambas to know what to draw is using the Clip property. of the Draw class.

In the first case, as drawing is clipped by the region, Draw.Clip.[X/Y/W/H] returns the smallest rectangle that includes the region.

But, for example, when you enlarge a little a window, the region contains two rectangles: one at the right of the window, the other at the bottom. And so, the including rectangle is the entire window!

+--------------------------------+---+
|                                | x |      xxx = The region used by Qt
|                                | x |
|                                | x |
|                                | x |
|                                | x |
|                                | x |
|                                | x |
|                    Old size    | x |
|                                | x |
+--------------------------------+ x |
|xxxxxxxxxxxxxxxxxxxxx New size xxxx |
+------------------------------------+

When you can easily draw any sub-rectangle of your drawing area, the second way is the better.

When you can't easily do that, i.e. when your drawing is too complex to be easily splitted into a rectangle, you prefer drawing everything each time you receive a Draw event. And so, you do the job twice or more times comparing to the first way. So it is twice or more slower.

The solution is having a property in the DrawingArea to tell it merging or not drawing events.

This is the merge ? property.