Skip to main content
Yunus ARI
Senior
December 11, 2019
Question

can do create another cpp file like screenview?

  • December 11, 2019
  • 5 replies
  • 1037 views

​hi everyone.

I have a screen what has a many elements inside. Therfore, screen has very long kode that difficult to control. I want to group some of this code in another cpp files. This new cpp file should be like original screenView.cpp. I want to write code in this file for configurate widgets that in the screenbase. I should be access everything inside screenbase.hpp. Especially, I want to override action functions in screenbase.hpp with this file.

I create a new class that based on screenview class. I thought it would work but it didn't.

I'm pretty new at c++. Maybe this is too easy or impossible. I don't know. Forgive if i'm wrong. Thank you for answer already. :)

This topic has been closed for replies.

5 replies

Martin KJELDSEN
Principal III
December 11, 2019

The way screens are structured in C++ code in TouchGFX is that you have your Base class generated by the designer, and then a class in the gui/ folder that inherits from this generated class. This allows you to use the designer to generate _some_ code and let's you do the test.

Does that answer your question?

/Martin

Yunus ARI
Yunus ARIAuthor
Senior
December 11, 2019

Hi @Martin KJELDSEN​ 

I couldn't explain myself well. I already using actual class under gui/ folder. I want a new cpp file under gui folder for use like view.cpp. I will try to explain myself with code.

I create a screen named screen. This screen has a button with action and a text.

Here is base file under generated/ for this screen;

/*********** Base.hpp file ***********/
 
class screenViewBase : public touchgfx::View<screenPresenter>
{
public:
 screenViewBase();
 virtual ~screenViewBase() {}
 virtual void setupScreen();
 
 /*
 * Virtual Action Handlers
 */
 virtual void buttonPres()
 {
 // Override and implement this function in screen
 }
 
protected:
 
 touchgfx::ButtonWithLabel Button;
 touchgfx::TextArea textArea;
}

Here is view file under gui/ for this screen;

/*********** view.hpp file ***********/
 
class screenView : public screenViewBase 
{
public:
 screenView();
 virtual ~screenView() {}
 virtual void setupScreen();
 
 /*
 * Virtual Action Handlers
 */
 virtual void buttonPres()
 {
 
 }
 
protected:
 
}

Here is a file what I want to create under gui/ for this screen;

/*********** new.hpp file ***********/
 
class testNew: public screenView
{
public:
 testNew();
 virtual ~testNew() {}
 
 /*
 * Virtual Action Handlers
 */
 void buttonPres()
 {
 textArea.setVisible(true);
 textArea.invalidate();
 }
 
protected:
 
}

This is what I want to do. I hope this explains well the situation.

Yunus ARI
Yunus ARIAuthor
Senior
December 12, 2019

hi @Martin KJELDSEN​ 

Is there any clue you can give about that? I am trying several things but there is any solution yet.

scottSD
Senior III
December 12, 2019

I may not be understanding you correctly, but I have added files in the screen1_screen folder (or whatever you name your screen in the designer) and it compiled.

I have also added files in the gui/common folder and it has compiled and worked well.

Are you placing the hpp files in the "include" section and the cpp files in the src section?

Yunus ARI
Yunus ARIAuthor
Senior
December 12, 2019

It's not what I want to do. I want to split view file for improve code readability.