rounded_rect.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Harry Storbacka
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../api_display.h"
00035 #include "../../Core/System/sharedptr.h"
00036 #include "../../Core/Math/origin.h"
00037 #include "../Render/graphic_context.h"
00038 
00039 class CL_Color;
00040 class CL_Gradient;
00041 class CL_Pointf;
00042 class CL_RoundedRect_Impl;
00043 
00047 class CL_RoundedRect
00048 {
00051 
00052 public:
00053 
00058         CL_RoundedRect(CL_Sizef size, float rounding_in_pixels=5.0f);
00059         virtual ~CL_RoundedRect();
00060 
00064 
00065 public:
00067         CL_Sizef get_size() const;
00068 
00070         float get_width() const;
00071 
00073         float get_height() const;
00074 
00076 
00077         float get_rounding() const;
00078 
00080         CL_Pointf get_control_point_tl() const;
00081 
00083         CL_Pointf get_control_point_tr() const;
00084 
00086         CL_Pointf get_control_point_bl() const;
00087 
00089         CL_Pointf get_control_point_br() const;
00090 
00092         CL_Sizef get_rounding_top_left() const;
00093 
00095         CL_Sizef get_rounding_top_right() const;
00096 
00098         CL_Sizef get_rounding_bottom_left() const;
00099 
00101         CL_Sizef get_rounding_bottom_right() const;
00102 
00106 
00107 public:
00109         void draw(
00110                 CL_GraphicContext &gc,
00111                 const CL_Pointf &position,
00112                 const CL_Colorf &color,
00113                 CL_Origin origin=origin_top_left);
00114 
00116         void fill(
00117                 CL_GraphicContext &gc,
00118                 const CL_Pointf &position,
00119                 const CL_Colorf &color,
00120                 CL_Origin origin=origin_top_left);
00121 
00122         void fill(
00123                 CL_GraphicContext &gc,
00124                 const CL_Pointf &position,
00125                 const CL_Gradient &gradient,
00126                 CL_Origin origin=origin_top_left);
00127 
00129         void set_size(const CL_Sizef &size);
00130 
00132         void set_control_point_tl(const CL_Pointf &pos);
00133 
00135         void set_control_point_tr(const CL_Pointf &pos);
00136 
00138         void set_control_point_bl(const CL_Pointf &pos);
00139 
00141         void set_control_point_br(const CL_Pointf &pos);
00142 
00144 
00145         void set_rounding(float offset_pixels);
00146 
00148         void set_rounding_top_left(const CL_Sizef &offset);
00149 
00151         void set_rounding_top_right(const CL_Sizef &offset);
00152 
00154         void set_rounding_bottom_left(const CL_Sizef &offset);
00155 
00157         void set_rounding_bottom_right(const CL_Sizef &offset);
00158 
00162 
00163 private:
00164         CL_SharedPtr<CL_RoundedRect_Impl> impl;
00166 };
00167