Jamba C++ API  4.3.0
ImageView.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 pongasoft
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  *
16  * @author Yan Pujante
17  */
18 #pragma once
19 
20 #include "CustomView.h"
21 
23 
38 class ImageView : public CustomView
39 {
40 public:
41  explicit ImageView(const CRect &iSize) : CustomView(iSize) { CView::setMouseEnabled(false); }
42 
45  BitmapPtr getImage() const { return fImage; }
46 
48  void setImage(BitmapPtr iImage) { fImage = iImage; }
49 
50  // draw => does the actual drawing job
51  void draw(CDrawContext *iContext) override;
52 
53 protected:
54  BitmapSPtr fImage{nullptr};
55 
56 public:
57  class Creator : public CustomViewCreator<ImageView, CustomView>
58  {
59  public:
60  explicit Creator(char const *iViewName = nullptr, char const *iDisplayName = nullptr) :
61  CustomViewCreator(iViewName, iDisplayName)
62  {
64  }
65  };
66 
67 };
68 
69 }
BitmapPtr getImage() const
The image to use.
Definition: ImageView.h:45
Inherit from this class to provide the factory for a custom view.
Definition: CustomViewCreator.h:1312
BitmapSPtr fImage
Definition: ImageView.h:54
This view simply renders an image (in addition to the background color).
Definition: ImageView.h:38
Class you should inherit from if you want to write a custom view.
Definition: CustomView.h:60
Creator(char const *iViewName=nullptr, char const *iDisplayName=nullptr)
Definition: ImageView.h:60
void draw(CDrawContext *iContext) override
Definition: ImageView.cpp:26
SharedPointer< CBitmap > BitmapSPtr
Definition: Types.h:50
Definition: CustomController.h:24
ImageView(const CRect &iSize)
Definition: ImageView.h:41
CBitmap * BitmapPtr
Definition: Types.h:49
void registerBitmapAttribute(std::string const &iName, typename BitmapAttribute::Getter iGetter, typename BitmapAttribute::Setter iSetter)
Registers a bitmap attribute with the given name and getter/setter.
Definition: CustomViewCreator.h:971
void setImage(BitmapPtr iImage)
attribute image
Definition: ImageView.h:48