imageview.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Harry Storbacka
27 ** Kenneth Gangstoe
28 ** Magnus Norddahl
29 ** Mark Page
30 */
31 
32 
33 #pragma once
34 
35 #include "../api_gui.h"
36 #include "../gui_component.h"
37 
38 namespace clan
39 {
42 
43 class Sprite;
44 class PixelBuffer;
45 class ImageView_Impl;
46 
48 class CL_API_GUI ImageView : public GUIComponent
49 {
52 public:
56  ImageView(GUIComponent *parent);
57 
58  virtual ~ImageView();
59 
63 public:
65 
69  static ImageView *get_named_item(GUIComponent *reference_component, const std::string &id);
70 
74  Sprite get_sprite() const;
75 
79  Image get_image() const;
80 
84 public:
88  void set_sprite(const Sprite &image);
89 
93  void set_image(const Image &image);
94 
98  void set_image(const PixelBuffer &image);
99 
101  void set_scale_to_fit(bool enable);
102 
107  void set_scale(float x, float y);
108 
112  float get_preferred_content_width();
113 
117  float get_preferred_content_height(float width);
118 
122 private:
123  std::shared_ptr<ImageView_Impl> impl;
125 };
126 
127 }
128 
Pixel data container.
Definition: pixel_buffer.h:69
Sprite class.
Definition: sprite.h:57
GUI base component class.
Definition: gui_component.h:81
GUIComponent * get_named_item(const std::string &id)
Find child component with the specified component ID name.
Image class.
Definition: image.h:60
Frame component.
Definition: imageview.h:48