2010-10-23 06:33:08 +04:00
|
|
|
/*
|
2013-02-07 06:05:00 +04:00
|
|
|
* Copyright 2010 Haiku, Inc. All rights reserved.
|
2010-10-23 06:33:08 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
2013-02-07 06:05:00 +04:00
|
|
|
* Authors:
|
|
|
|
* Alex Wilson, yourpalal2@gmail.com
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2015-01-28 03:15:11 +03:00
|
|
|
\page interface_intro Introduction to the Interface Kit
|
2021-10-09 21:57:54 +03:00
|
|
|
\ingroup interface
|
|
|
|
|
|
|
|
\section Overview
|
2013-02-07 06:05:00 +04:00
|
|
|
|
2010-10-23 06:33:08 +04:00
|
|
|
The Interface Kit holds all the classes you'll need to develop a GUI.
|
|
|
|
Building on the messaging facilities provided by the Application Kit,
|
2013-02-07 06:05:00 +04:00
|
|
|
the Interface Kit can be used to create a responsive and attractive
|
|
|
|
graphical user interface.
|
2010-10-23 06:33:08 +04:00
|
|
|
|
2013-02-07 06:05:00 +04:00
|
|
|
The most important class in the Interface Kit is the BView class, which
|
2010-10-23 06:33:08 +04:00
|
|
|
handles drawing and user interaction. Pointer and keyboard events are
|
|
|
|
processed in this class.
|
|
|
|
|
|
|
|
Another important class is the BWindow class, which holds BViews and makes
|
2013-02-07 06:05:00 +04:00
|
|
|
them visible to the user. The BWindow class also handles BView focusing
|
2010-10-23 06:33:08 +04:00
|
|
|
and BMessage dispatching, among other things.
|
|
|
|
|
|
|
|
A new addition Haiku has added over the BeOS API is the Layout API, which
|
|
|
|
is based around the BLayoutItem and BLayout classes. These classes will
|
|
|
|
take care of making sure all your GUI widgets end up where you want them,
|
|
|
|
with enough space to be useful. You can start learning the Layout API
|
2022-01-10 20:48:56 +03:00
|
|
|
by reading the \ref layout_intro.
|
2021-10-09 21:57:54 +03:00
|
|
|
|
2022-01-10 20:48:56 +03:00
|
|
|
\section coordinatespaces Coordinate spaces
|
2021-10-09 21:57:54 +03:00
|
|
|
|
2022-01-10 20:48:56 +03:00
|
|
|
All APIs using coordinates (such as BRect or BPoint) refer to
|
|
|
|
a specific space where these coordinates are interpreted. BView and
|
|
|
|
BWindow provide various conversion function to translate coordinates
|
2021-10-09 21:57:54 +03:00
|
|
|
between different spaces, as needed, or provide separate methods such as
|
|
|
|
BView Bounds() and Frame(), returning results in different spaces as needed.
|
|
|
|
|
|
|
|
The initial coordinate space, from which all others are derived, is the
|
|
|
|
screen space. Its origin is at the center of the screen's top-left pixel.
|
|
|
|
Coordinates can be converted between this and a specific window or view
|
|
|
|
space is done using the ConvertToScreen and ConvertFromScreen methods of
|
|
|
|
the corresponding object.
|
|
|
|
|
|
|
|
Each BWindow has its own coordinate space. Its origin is at the center of
|
|
|
|
the top-left pixel of the window client area (just inside the window border).
|
|
|
|
Root level views added to the window have their frame rectangle defined in
|
|
|
|
this space.
|
|
|
|
|
|
|
|
Each BView also gets its own coordinate space. The origin is initially at the
|
|
|
|
top left of the view, but this can be changed by scrolling the view
|
|
|
|
(programatically using ScrollBy or ScrollTo, or by the user acting on a scrollbar).
|
|
|
|
|
|
|
|
Additionally, each BView also has a drawing space. This is further transformed
|
|
|
|
from the BView coordinate space by calls to SetOrigin, SetScale, SetTransform,
|
|
|
|
ScaleBy, RotateBy, and TranslateBy. The effects of the first two of these
|
|
|
|
methods are independant from the other four, and it's not recommended to mix
|
|
|
|
the two types of transformations in the same BView. Note that this is the only space
|
|
|
|
that can be scaled and rotated, and translated by non-integer units. All other
|
|
|
|
coordinate spaces are only translations of the screen one and remain aligned on pixels.
|
|
|
|
|
|
|
|
All drawing operations in a BView use coordinates specified in the drawing space.
|
|
|
|
However, the update rect passed to the Draw method (or passed to the Invalidate
|
|
|
|
method) is in the BView base coordinate space. Conversion between the two can
|
|
|
|
be done using the affine transform returned by BView::Transform, or in case the
|
|
|
|
legacy transformation functions are used, by applying the scale and origin returned
|
|
|
|
by the Scale() and Origin() functions.
|
2010-10-23 06:33:08 +04:00
|
|
|
*/
|