Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb_image_widget.h
1 // ================================================================================
2 // == This file is a part of Turbo Badger. (C) 2011-2014, Emil SegerÃ¥s ==
3 // == See tb_core.h for more information. ==
4 // ================================================================================
5 
6 #ifndef TB_IMAGE_WIDGET_H
7 #define TB_IMAGE_WIDGET_H
8 
9 #include "tb_widgets.h"
10 
11 #ifdef TB_IMAGE
12 
13 #include "image/tb_image_manager.h"
14 
15 namespace tb {
16 
21 class TBImageWidget : public TBWidget
22 {
23 public:
24  // For safe typecasting
25  TBOBJECT_SUBCLASS(TBImageWidget, TBWidget);
26 
27  TBImageWidget() {}
28 
29  void SetImage(const TBImage &image) { m_image = image; }
30  void SetImage(const char *filename) { m_image = g_image_manager->GetImage(filename); }
31 
32  void SetAdaptTextColor(bool adapt) { m_adapt_text_color = adapt; }
33  virtual PreferredSize OnCalculatePreferredContentSize(const SizeConstraints &constraints);
34 
35  virtual void OnInflate(const INFLATE_INFO &info);
36  virtual void OnPaint(const PaintProps &paint_props);
37 private:
38  TBImage m_image;
39  bool m_adapt_text_color;
40 };
41 
42 } // namespace tb
43 
44 #endif // TB_IMAGE
45 #endif // TB_IMAGE_WIDGET_H