UTView.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _UT_VIEW_H_
00026 #define _UT_VIEW_H_
00027
00030
00031
00032
00033
00034
00035 #include "UTgui.h"
00036 #include "UTLists.h"
00037 #include "UTDrawable.h"
00038
00039
00040
00041
00042
00043
00046 const float c_label_colon_control_h_spacing = -1;
00047
00051 const float c_ok_cancel_etc_h_spacing = -2;
00052
00055 const float c_controls_h_spacing = -3;
00056
00060 const float c_controls_wide_h_spacing = -4;
00061
00065 const float c_dialog_body_to_ok_cancel_etc_v_spacing = -5;
00066
00069 const float c_controls_v_spacing = -6;
00070
00074 const float c_controls_wide_v_spacing = -7;
00075
00076
00077
00078
00079
00080 class ViewPlatformInfo_t;
00081 class Window_t;
00082 class Region_t;
00083
00084
00085
00086 class UTGUI_EXPORT View_t
00087
00111 : public LinkedListNode_t<View_t>,
00112 public Drawable_t
00113 {
00114
00115 public:
00116
00117 View_t();
00121
00122 virtual ~View_t();
00124
00125 inline Window_t* ParentWindow() const;
00127
00128 inline View_t* ParentView() const;
00132
00133 virtual void SetMinMaxSize( float min_width,
00134 float max_width,
00135 float min_height,
00136 float max_height );
00142
00143 inline float MinWidth() const;
00146
00147 inline float MaxWidth() const;
00150
00151 inline float MinHeight() const;
00154
00155 inline float MaxHeight() const;
00158
00159 inline const Rect_t& LBounds() const;
00182
00183 inline const Rect_t& PFrame() const;
00186
00187 void SetPFrame(const Rect_t& pframe);
00194
00195 void Invalidate();
00198
00199 void Invalidate(const Rect_t& rect);
00202
00203 inline int CountChildren() const;
00205
00206 inline View_t* HeadChild() const;
00209
00210 inline View_t* TailChild() const;
00213
00214 static float RealPlatformSpacing(float spacing_constant);
00225
00226
00227 protected:
00228
00229 virtual void AddChild(takes View_t* child);
00232
00233 virtual gives View_t* RemoveChild(View_t* child);
00236
00237 virtual void LBoundsChanged( const Rect_t& old_lbounds,
00238 const Rect_t& new_lbounds );
00248
00249 virtual void ChildMinMaxSizeChanged(View_t* child);
00259
00260 virtual void Paint(const Region_t& clip_to);
00290
00291 virtual void SetBackgroundColor(const Color_t& color);
00300
00301 Color_t BackgroundColor() const;
00308
00309 void SetClearBackgroundBeforePaint(bool clear_before_paint);
00317
00318 virtual void MouseChanged( const Point_t& point,
00319 bool mouse_inside_view,
00320 bool left_mouse_button_down,
00321 bool left_mouse_button_double_clicked,
00322 bool right_mouse_button_down_if_present );
00347
00348
00349
00350 virtual void TrackMouseUntilButtonsReleased(bool enable = true);
00367
00368
00369 public:
00370
00371 virtual void SetBrush( const Color_t& color,
00372 float brush_width = 1,
00373 line_cap_type_t cap_type =
00374 eLCT_butt_extended_half_width );
00377
00378 virtual void SetFillColor(const Color_t& color);
00382
00383 virtual void DrawLine( const Point_t& from,
00384 const Point_t& to,
00385 bool anti_alias = true );
00393
00394 virtual void DrawRect( const Rect_t& rect,
00395 bool anti_alias = true,
00396 bool fill = false );
00407
00408 virtual void DrawText( const String_t& string,
00409 const Point_t& where,
00410 bool anti_alias = true );
00419
00420 void SetFont(const Font_t& font);
00424
00425
00426 private:
00427
00428 View_t(bool create_os_peer);
00429
00430
00431
00432 void SetWindow(Window_t* window);
00433
00434
00435 virtual void WindowWillBeDeleted();
00436
00437
00438 virtual void WindowHasBeenDeleted();
00439
00440
00441 void SetMinMaxSizeInternal( float min_width,
00442 float max_width,
00443 float min_height,
00444 float max_height );
00445
00446
00447
00448
00449
00450
00451
00452
00453 private:
00454
00455 ViewPlatformInfo_t* m_platform_info;
00456
00457
00458 Window_t* m_window;
00459 View_t* m_parent;
00460 Rect_t m_pframe;
00461 Rect_t m_lbounds;
00462 OwnedLinkedList_t<View_t> m_children;
00463 Color_t m_background_color;
00464 bool m_clear_background_before_paint;
00465 bool m_track_mouse_allowed;
00466 bool m_track_mouse_enabled;
00467
00468 float m_min_width;
00469 float m_min_height;
00470 float m_max_width;
00471 float m_max_height;
00472
00473 friend class AppPlatformInfo_t;
00474 friend class ViewPlatformInfo_t;
00475 friend class MouseCaptureManager_t;
00476 friend class Window_t;
00477 friend class WindowPlatformInfo_t;
00478 friend class Button_t;
00479 friend class ButtonPlatformInfo_t;
00480 };
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492 inline Window_t*
00493 View_t::ParentWindow() const
00494 {
00495 return m_window;
00496 }
00497
00498
00499 inline View_t*
00500 View_t::ParentView() const
00501 {
00502 return m_parent;
00503 }
00504
00505
00506 inline float
00507 View_t::MinWidth() const
00508 {
00509 return m_min_width;
00510 }
00511
00512
00513 inline float
00514 View_t::MinHeight() const
00515 {
00516 return m_min_height;
00517 }
00518
00519
00520 inline float
00521 View_t::MaxWidth() const
00522 {
00523 return m_max_width;
00524 }
00525
00526
00527 inline float
00528 View_t::MaxHeight() const
00529 {
00530 return m_max_height;
00531 }
00532
00533
00534 inline const Rect_t&
00535 View_t::LBounds() const
00536 {
00537 return m_lbounds;
00538 }
00539
00540
00541 inline const Rect_t&
00542 View_t::PFrame() const
00543 {
00544 return m_pframe;
00545 }
00546
00547
00548 inline int
00549 View_t::CountChildren() const
00550 {
00551 return m_children.CountItems();
00552 }
00553
00554
00555 inline View_t*
00556 View_t::HeadChild() const
00557 {
00558 return m_children.Head();
00559 }
00560
00561
00562 inline View_t*
00563 View_t::TailChild() const
00564 {
00565 return m_children.Tail();
00566 }
00567
00568
00569 #endif // _UT_VIEW_H_