|
<html><head><title>dlib C++ Library - drawable_abstract.h</title></head><body bgcolor='white'><pre> |
|
<font color='#009900'>// Copyright (C) 2005 Davis E. King ([email protected]) |
|
</font><font color='#009900'>// License: Boost Software License See LICENSE.txt for the full license. |
|
</font> |
|
<font color='#0000FF'>#undef</font> DLIB_DRAWABLe_ABSTRACT_ |
|
<font color='#0000FF'>#ifdef</font> DLIB_DRAWABLe_ABSTRACT_ |
|
|
|
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../gui_core.h.html'>../gui_core.h</a>" |
|
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='fonts_abstract.h.html'>fonts_abstract.h</a>" |
|
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='canvas_drawing_abstract.h.html'>canvas_drawing_abstract.h</a>" |
|
|
|
<font color='#0000FF'>namespace</font> dlib |
|
<b>{</b> |
|
|
|
<font color='#009900'>/*! |
|
GENERAL REMARKS |
|
This file defines the drawable interface class and the drawable_window which |
|
is just a window that is capable of displaying drawable objects (i.e. objects |
|
that implement the drawable interface). |
|
|
|
The drawable interface is a simple framework for creating more complex |
|
graphical widgets. It provides a default set of functionality and a |
|
set of events which a gui widget may use. |
|
|
|
THREAD SAFETY |
|
All objects and functions defined in this file are thread safe. You may |
|
call them from any thread without serializing access to them. |
|
!*/</font> |
|
|
|
<font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font><font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font> <font color='#009900'>// class drawable_window |
|
</font><font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font><font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font> |
|
<font color='#0000FF'>class</font> <b><a name='drawable_window'></a>drawable_window</b> : <font color='#0000FF'>public</font> base_window |
|
<b>{</b> |
|
<font color='#009900'>/*! |
|
WHAT THIS OBJECT REPRESENTS |
|
This object represents a window on the desktop that is capable of |
|
containing drawable objects. |
|
|
|
INITIAL STATE |
|
The initial state of the drawable_window is to be hidden. This means |
|
you need to call show() to make it appear. |
|
|
|
EVENTS |
|
The drawable_window object uses all the events provided by base_window |
|
except for the on_window_close() event. This means that if you |
|
define handlers for these events yourself you will have to call |
|
the drawable_window's version of them so that the drawable_window |
|
can continue to process and forward these events to its drawable |
|
objects. |
|
!*/</font> |
|
<font color='#0000FF'>public</font>: |
|
|
|
<b><a name='drawable_window'></a>drawable_window</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>bool</u></font> resizable <font color='#5555FF'>=</font> <font color='#979000'>true</font>, |
|
<font color='#0000FF'><u>bool</u></font> undecorated <font color='#5555FF'>=</font> <font color='#979000'>false</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
requires |
|
- if (undecorated == true) then |
|
- resizable == false |
|
ensures |
|
- #*this has been properly initialized |
|
- #background_color() == rgb_pixel(212,208,200) |
|
- if (resizable == true) then |
|
- this window will be resizable by the user |
|
- else |
|
- this window will not be resizable by the user |
|
- if (undecorated == true) then |
|
- this window will not have any graphical elements outside |
|
of its drawable area or appear in the system task bar. |
|
(e.g. a popup menu) |
|
throws |
|
- std::bad_alloc |
|
- dlib::thread_error |
|
- dlib::gui_error |
|
This exception is thrown if there is an error while |
|
creating this window. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> ~<b><a name='drawable_window'></a>drawable_window</b><font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- if (this window has not already been closed) then |
|
- closes the window |
|
- does NOT trigger the on_window_close() event |
|
- all resources associated with *this have been released |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>void</u></font> <b><a name='set_background_color'></a>set_background_color</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> red, |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> green, |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> blue |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #background_color().red == red |
|
- #background_color().green == green |
|
- #background_color().blue == blue |
|
!*/</font> |
|
|
|
rgb_pixel <b><a name='background_color'></a>background_color</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns the background color this window paints its canvas |
|
with before it passes it onto its drawable widgets |
|
!*/</font> |
|
|
|
<font color='#0000FF'>private</font>: |
|
<font color='#009900'>// restricted functions |
|
</font> <b><a name='drawable_window'></a>drawable_window</b><font face='Lucida Console'>(</font>drawable_window<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// copy constructor |
|
</font> drawable_window<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>drawable_window<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// assignment operator |
|
</font> |
|
<font color='#0000FF'>friend</font> <font color='#0000FF'>class</font> drawable; |
|
<b>}</b>; |
|
|
|
<font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font><font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font> <font color='#009900'>// class drawable |
|
</font><font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font><font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font> |
|
<font color='#0000FF'>enum</font> |
|
<b>{</b> |
|
MOUSE_MOVE <font color='#5555FF'>=</font> <font color='#979000'>1</font>, |
|
MOUSE_CLICK <font color='#5555FF'>=</font> <font color='#979000'>2</font>, |
|
MOUSE_WHEEL <font color='#5555FF'>=</font> <font color='#979000'>4</font>, |
|
WINDOW_RESIZED <font color='#5555FF'>=</font> <font color='#979000'>8</font>, |
|
KEYBOARD_EVENTS <font color='#5555FF'>=</font> <font color='#979000'>16</font>, |
|
FOCUS_EVENTS <font color='#5555FF'>=</font> <font color='#979000'>32</font>, |
|
WINDOW_MOVED <font color='#5555FF'>=</font> <font color='#979000'>64</font>, |
|
STRING_PUT <font color='#5555FF'>=</font> <font color='#979000'>128</font> |
|
<b>}</b>; |
|
|
|
<font color='#0000FF'>class</font> <b><a name='drawable'></a>drawable</b> |
|
<b>{</b> |
|
<font color='#009900'>/*! |
|
INITIAL VALUE |
|
top() == 0 |
|
left() == 0 |
|
right() == -1 |
|
bottom() == -1 |
|
get_rect().is_empty() == true |
|
is_hidden() == false |
|
is_enabled() == true |
|
z_order() == 0 |
|
main_font() == default_font::get_font() |
|
|
|
WHAT THIS OBJECT REPRESENTS |
|
This is an interface that all drawable widgets implement. It |
|
provides a standard method (draw()) to draw a widget onto a canvas |
|
and many other convenient functions for drawable objects. |
|
|
|
EVENT FORWARDING |
|
All the events that come to a drawable object are forwarded from its |
|
parent window. Additionally, there is no filtering. This means that |
|
if a drawable registers to receive a certain kind of event then whenever |
|
its parent window receives that event the drawable object will get a |
|
forwarded copy of it as well even if the event occurred outside the |
|
drawable's rectangle. |
|
|
|
The only events that have anything in the way of filtering are the |
|
draw() and on_user_event() events. draw() is only called on a drawable |
|
object when that object is not hidden. on_user_event() is only called |
|
for drawables that the on_user_event()'s first argument specifically |
|
references. All other events are not filtered at all though. |
|
|
|
Z ORDER |
|
Z order defines the order in which drawable objects are drawn. The |
|
lower numbered drawables are drawn first and then the higher numbered |
|
ones. So a drawable with a z order of 0 is drawn before one with a |
|
z order of 1 and so on. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>public</font>: |
|
|
|
<font color='#0000FF'>friend</font> <font color='#0000FF'>class</font> drawable_window; |
|
|
|
<b><a name='drawable'></a>drawable</b> <font face='Lucida Console'>(</font> |
|
drawable_window<font color='#5555FF'>&</font> w, |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> events <font color='#5555FF'>=</font> <font color='#979000'>0</font> |
|
<font face='Lucida Console'>)</font> : |
|
m<font face='Lucida Console'>(</font>w.wm<font face='Lucida Console'>)</font>, |
|
parent<font face='Lucida Console'>(</font>w<font face='Lucida Console'>)</font>, |
|
hidden<font face='Lucida Console'>(</font><font color='#979000'>false</font><font face='Lucida Console'>)</font>, |
|
enabled<font face='Lucida Console'>(</font><font color='#979000'>true</font><font face='Lucida Console'>)</font> |
|
<b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
ensures |
|
- #*this is properly initialized |
|
- #parent_window() == w |
|
- #*this will not receive any events or draw() requests until |
|
enable_events() is called |
|
- once events_are_enabled() == true this drawable will receive |
|
the on_user_event() event. (i.e. you always get this event, you don't |
|
have to enable it by setting something in the events bitset). |
|
- if (events & MOUSE_MOVE) then |
|
- once events_are_enabled() == true this drawable will receive |
|
the following events related to mouse movement: on_mouse_move, |
|
on_mouse_leave, and on_mouse_enter. |
|
- if (events & MOUSE_CLICK) then |
|
- once events_are_enabled() == true this drawable will receive |
|
the following events related to mouse clicks: on_mouse_down and |
|
on_mouse_up. |
|
- if (events & MOUSE_WHEEL) then |
|
- once events_are_enabled() == true this drawable will receive |
|
the following events related to mouse wheel scrolling: |
|
on_wheel_up and on_wheel_down. |
|
- if (events & WINDOW_RESIZED) then |
|
- once events_are_enabled() == true this drawable will receive |
|
the following event related to its parent window resizing: |
|
on_window_resized. |
|
- if (events & KEYBOARD_EVENTS) then |
|
- once events_are_enabled() == true this drawable will receive |
|
the following keyboard event: on_keydown. |
|
- if (events & FOCUS_EVENTS) then |
|
- once events_are_enabled() == true this drawable will receive |
|
the following focus events: on_focus_gained and on_focus_lost. |
|
- if (events & WINDOW_MOVED) then |
|
- once events_are_enabled() == true this drawable will receive |
|
the following event related to its parent window moving: |
|
on_window_moved. |
|
- if (events & STRING_PUT) then |
|
- once events_are_enabled() == true this drawable will receive |
|
the following event related to wide character string input: |
|
on_string_put. |
|
throws |
|
- std::bad_alloc |
|
- dlib::thread_error |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> ~<b><a name='drawable'></a>drawable</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == false |
|
ensures |
|
- any resources associated with *this have been released |
|
- *this has been removed from its containing window parent_window() and |
|
its parent window will no longer try to dispatch events to it. |
|
Note that this does not trigger a redraw of the parent window. If you |
|
want to do that you must do it yourself. |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>long</u></font> <b><a name='z_order'></a>z_order</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns the z order for this drawable. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='set_z_order'></a>set_z_order</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>long</u></font> order |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #z_order() == order |
|
- if (events_are_enabled() == true) then |
|
- parent_window() is updated to reflect the new state of #*this |
|
throws |
|
- std::bad_alloc |
|
!*/</font> |
|
|
|
<font color='#0000FF'>const</font> rectangle <b><a name='get_rect'></a>get_rect</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns the rectangle that defines the area and position of this |
|
drawable inside its containing window parent_window(). |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>long</u></font> <b><a name='bottom'></a>bottom</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns get_rect().bottom() |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>long</u></font> <b><a name='top'></a>top</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns get_rect().top() |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>long</u></font> <b><a name='left'></a>left</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns get_rect().left() |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>long</u></font> <b><a name='right'></a>right</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns get_rect().right() |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='width'></a>width</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns get_rect().width() |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> <b><a name='height'></a>height</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns get_rect().height() |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='set_pos'></a>set_pos</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>long</u></font> x, |
|
<font color='#0000FF'><u>long</u></font> y |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #top() == y |
|
- #left() == x |
|
- #width() == width() |
|
- #height() == height() |
|
- if (events_are_enabled() == true) then |
|
- parent_window() is updated to reflect the new state of #*this |
|
- i.e. This just sets the upper left corner of this drawable to the |
|
location (x,y) |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>bool</u></font> <b><a name='is_enabled'></a>is_enabled</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns true if this object is enabled and false otherwise. |
|
(it is up to derived classes to define exactly what it means to be |
|
"enabled") |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='enable'></a>enable</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #is_enabled() == true |
|
- if (events_are_enabled() == true) then |
|
- parent_window() is updated to reflect the new state of #*this |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='disable'></a>disable</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #is_enabled() == false |
|
- if (events_are_enabled() == true) then |
|
- parent_window() is updated to reflect the new state of #*this |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='set_main_font'></a>set_main_font</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'>const</font> shared_ptr_thread_safe<font color='#5555FF'><</font>font<font color='#5555FF'>></font><font color='#5555FF'>&</font> f |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #main_font() == f |
|
- if (events_are_enabled() == true) then |
|
- parent_window() is updated to reflect the new state of #*this |
|
!*/</font> |
|
|
|
<font color='#0000FF'>const</font> shared_ptr_thread_safe<font color='#5555FF'><</font>font<font color='#5555FF'>></font> <b><a name='main_font'></a>main_font</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns the current main font being used by this widget |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>bool</u></font> <b><a name='is_hidden'></a>is_hidden</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns true if this object is NOT currently displayed on parent_window() |
|
and false otherwise. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='show'></a>show</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #is_hidden() == false |
|
- if (events_are_enabled() == true) then |
|
- parent_window() is updated to reflect the new state of #*this |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='hide'></a>hide</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #is_hidden() == true |
|
- if (events_are_enabled() == true) then |
|
- parent_window() is updated to reflect the new state of #*this |
|
!*/</font> |
|
|
|
drawable_window<font color='#5555FF'>&</font> <b><a name='parent_window'></a>parent_window</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns a reference to the drawable_window that this drawable is |
|
being drawn on and receiving events from. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>const</font> drawable_window<font color='#5555FF'>&</font> <b><a name='parent_window'></a>parent_window</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns a const reference to the drawable_window that this drawable |
|
is being drawn on and receiving events from. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>int</u></font> <b><a name='next_free_user_event_number'></a>next_free_user_event_number</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font><font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>0</font>; <b>}</b> |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns the smallest number, i, that is the next user event number you |
|
can use in calls to parent.trigger_user_event((void*)this,i). |
|
- This function exists because of the following scenario. Suppose |
|
you make a class called derived1 that inherits from drawable and |
|
in derived1 you use a user event to do something. Then suppose |
|
you inherit from derived1 to make derived2. Now in derived2 you |
|
may want to use a user event to do something as well. How are you |
|
to know which user event numbers are in use already? This function |
|
solves that problem. You would define derived1::next_free_user_event_number() |
|
so that it returned a number bigger than any user event numbers used by |
|
derived1 or its ancestors. Then derived2 could just call |
|
derived1::next_free_user_event_number() to find out what numbers it could use. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>protected</font>: |
|
<a name='drawable_protected_variables'/><font color='#009900'>/*!A drawable_protected_variables |
|
|
|
These protected members are provided because they are needed to |
|
implement drawable widgets. |
|
!*/</font> |
|
|
|
<font color='#009900'>// This is the rectangle that is returned by get_rect() |
|
</font> rectangle rect; |
|
|
|
<font color='#009900'>// This is the mutex used to serialize access to this class. |
|
</font> <font color='#0000FF'>const</font> rmutex<font color='#5555FF'>&</font> m; |
|
|
|
<font color='#009900'>// This is the parent window of this drawable |
|
</font> drawable_window<font color='#5555FF'>&</font> parent; |
|
|
|
<font color='#009900'>// This is the bool returned by is_hidden() |
|
</font> <font color='#0000FF'><u>bool</u></font> hidden; |
|
|
|
<font color='#009900'>// This is the bool returned by is_enabled() |
|
</font> <font color='#0000FF'><u>bool</u></font> enabled; |
|
|
|
<font color='#009900'>// This is the font pointer returned by main_font() |
|
</font> shared_ptr_thread_safe<font color='#5555FF'><</font>font<font color='#5555FF'>></font> mfont; |
|
|
|
<font color='#009900'>// This is the x coordinate that we last saw the mouse at or -1 if the mouse |
|
</font> <font color='#009900'>// is outside the parent window. |
|
</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&</font> lastx; |
|
|
|
<font color='#009900'>// This is the y coordinate that we last saw the mouse at or -1 if the mouse |
|
</font> <font color='#009900'>// is outside the parent window. |
|
</font> <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font><font color='#5555FF'>&</font> lasty; |
|
|
|
|
|
<font color='#0000FF'><u>void</u></font> <b><a name='enable_events'></a>enable_events</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #events_are_enabled() == true |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>void</u></font> <b><a name='disable_events'></a>disable_events</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- #events_are_enabled() == false |
|
!*/</font> |
|
|
|
<font color='#0000FF'><u>bool</u></font> <b><a name='events_are_enabled'></a>events_are_enabled</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>; |
|
<font color='#009900'>/*! |
|
ensures |
|
- returns true if this object is receiving events and draw() |
|
requests from its parent window. |
|
- returns false otherwise |
|
!*/</font> |
|
|
|
<font color='#009900'>// ---------------- EVENT HANDLERS ------------------ |
|
</font> |
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_user_event'></a>on_user_event</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>int</u></font> i |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- is called whenever the parent window receives an on_user_event(p,i) event |
|
where p == this. (i.e. this is just a redirect of on_user_event for |
|
cases where the first argument of on_user_event is equal to the |
|
this pointer). |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_window_resized'></a>on_window_resized</b><font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_window_resized() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_window_moved'></a>on_window_moved</b><font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_window_moved() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_mouse_down'></a>on_mouse_down</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> btn, |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> state, |
|
<font color='#0000FF'><u>long</u></font> x, |
|
<font color='#0000FF'><u>long</u></font> y, |
|
<font color='#0000FF'><u>bool</u></font> is_double_click |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_mouse_down() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_mouse_up'></a>on_mouse_up</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> btn, |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> state, |
|
<font color='#0000FF'><u>long</u></font> x, |
|
<font color='#0000FF'><u>long</u></font> y |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_mouse_up() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_mouse_move'></a>on_mouse_move</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> state, |
|
<font color='#0000FF'><u>long</u></font> x, |
|
<font color='#0000FF'><u>long</u></font> y |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- x == lastx |
|
- y == lasty |
|
- this is just the base_window::on_mouse_move() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_mouse_leave'></a>on_mouse_leave</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_mouse_leave() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_mouse_enter'></a>on_mouse_enter</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_mouse_enter() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_wheel_up'></a>on_wheel_up</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> state |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_wheel_up() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_wheel_down'></a>on_wheel_down</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> state |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_wheel_down() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_focus_gained'></a>on_focus_gained</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_focus_gained() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_focus_lost'></a>on_focus_lost</b> <font face='Lucida Console'>(</font> |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_focus_lost() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_keydown'></a>on_keydown</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> key, |
|
<font color='#0000FF'><u>bool</u></font> is_printable, |
|
<font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> state |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_keydown() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='on_string_put'></a>on_string_put</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'>const</font> std::wstring <font color='#5555FF'>&</font>str |
|
<font face='Lucida Console'>)</font><b>{</b><b>}</b> |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- this is just the base_window::on_put_string() event forwarded to |
|
this object. See the gui_core specs for the details about this event. |
|
ensures |
|
- does not change the state of mutex m. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='draw'></a>draw</b> <font face='Lucida Console'>(</font> |
|
<font color='#0000FF'>const</font> canvas<font color='#5555FF'>&</font> c |
|
<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font><font color='#5555FF'>=</font><font color='#979000'>0</font>; |
|
<font color='#009900'>/*! |
|
requires |
|
- events_are_enabled() == true |
|
- mutex m is locked |
|
- is_hidden() == false |
|
- is called by parent_window() when it needs to repaint itself. |
|
- c == the canvas object for the area of parent_window() that needs |
|
to be repainted. |
|
ensures |
|
- does not change the state of mutex m. |
|
- draws the area of *this that intersects with the canvas onto |
|
the canvas object c. |
|
!*/</font> |
|
|
|
<font color='#0000FF'>private</font>: |
|
|
|
<font color='#009900'>// restricted functions |
|
</font> <b><a name='drawable'></a>drawable</b><font face='Lucida Console'>(</font>drawable<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// copy constructor |
|
</font> drawable<font color='#5555FF'>&</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>drawable<font color='#5555FF'>&</font><font face='Lucida Console'>)</font>; <font color='#009900'>// assignment operator |
|
</font> <b>}</b>; |
|
|
|
<font color='#009900'>// ---------------------------------------------------------------------------------------- |
|
</font> |
|
<b>}</b> |
|
|
|
<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_DRAWABLe_ABSTRACT_ |
|
</font> |
|
|
|
</pre></body></html> |