Advertisement
Psychobitch

Form

Nov 4th, 2015
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.23 KB | None | 0 0
  1. #define _NO_SPECIAL_ENTRY
  2.  
  3.  
  4. #include "src\YamiApplication.h"
  5. //#include "src\UI\UIButton.h"
  6. #include "src\Window\YWindow.h"
  7. #include "src\Window\Renderer.h"
  8. #include "src\Window\YTexture.h"
  9. #include "src\UI\UITextbox.h"
  10. #include "src\UI\UICheckbox.h"
  11. #include "src\UI\UITab.h"
  12. #include "src\UI\UITabControl.h"
  13. #include "src\FileManagement\Config\Config.h"
  14.  
  15.  
  16. using namespace Yami;
  17. using namespace Application;
  18. using namespace Files;
  19. using namespace UI;
  20.  
  21.  
  22.  
  23.  
  24. class MyForm : public YForm
  25. {
  26. private:
  27.     YInt hkey = VK_HOME;
  28.  
  29.     UITextbox* tb1 = YObject::safe_alloc<UITextbox>();
  30.     UICheckbox* cb1 = YObject::safe_alloc<UICheckbox>(), *cb2 = YObject::safe_alloc<UICheckbox>();
  31.     YVector2 mouse;
  32.  
  33.     UITabControl* tabControl = YObject::safe_alloc<UITabControl>();
  34.     UITab* tab1 = YObject::safe_alloc<UITab>(), *tab2 = YObject::safe_alloc<UITab>();
  35.  
  36.  
  37. public:
  38.  
  39.     YVoid InitalizeComponent()
  40.     {
  41.         _myWindow = YObject::safe_alloc<YWindow>();
  42.         _myRenderer = YObject::safe_alloc<YRenderer>();
  43.         _myWindow->Create(800, 600, 300, 300, "Class", "Title");
  44.         _myRenderer->Create(_myWindow->gethWnd());
  45.         _myRenderer->PrepareFont("Caviar", "Caviar Dreams", 25, 200);
  46.  
  47.  
  48.        
  49.        
  50.  
  51.  
  52.  
  53.         // Draw state
  54.         cb1->setDrawState(YDraw_renderer);
  55.         cb2->setDrawState(YDraw_renderer);
  56.         tb1->setDrawState(YDraw_renderer);
  57.         UIColor color;
  58.  
  59.         //Foreground
  60.         color.foreground = D3DCOLOR_ARGB(255, 25, 25, 25);
  61.         color.line = D3DCOLOR_ARGB(255, 40, 40, 40);
  62.         color.text = D3DCOLOR_ARGB(255, 255, 255, 255);
  63.         color.ex = D3DCOLOR_ARGB(255, 64, 64, 64);
  64.         cb1->setDefaultColor(color);
  65.         cb2->setDefaultColor(color);
  66.         tb1->setDefaultColor(color);
  67.  
  68.         color.ex = D3DCOLOR_ARGB(245, 0, 157, 222);
  69.         tabControl->setDefaultColor(color);
  70.  
  71.         color.line = D3DCOLOR_ARGB(255, 75, 75, 75);
  72.         tabControl->setHoveredColor(color);
  73.  
  74.  
  75.         //Hover
  76.         cb1->setHoveredColor(color);
  77.         cb2->setHoveredColor(color);
  78.         tb1->setHoveredColor(color);
  79.         cb1->setClickedColor(color);
  80.         cb2->setClickedColor(color);
  81.        
  82.        
  83.  
  84.        
  85.         // checkbox1
  86.         cb1->setPadding({ 25, 150 });
  87.         cb1->setSize({ 25, 25 });
  88.         cb1->setName("Checkbox1");
  89.         cb1->setText("Checkbox");
  90.         cb1->setFont("Caviar");
  91.         cb1->setEditable(true);
  92.  
  93.         // checkbox2
  94.         cb2->setPadding({ 25, 150 });
  95.         cb2->setSize({ 25, 25 });
  96.         cb2->setName("Checkbox2");
  97.         cb2->setText("Checkbox");
  98.         cb2->setFont("Caviar");
  99.         cb2->setEditable(true);
  100.  
  101.         // Textbox
  102.         tb1->setPadding({ 25, 225 });
  103.         tb1->setSize({ 0, 0 });
  104.         tb1->setAutosize(true);
  105.         tb1->setMultilined(true);
  106.         tb1->setFont("Caviar");
  107.         tb1->setText("Default Text");
  108.         tb1->setName("Textbox1");
  109.  
  110.  
  111.  
  112.         // Tabs
  113.         tab1->addChild(cb1);
  114.         tab1->addChild(tb1);
  115.         tab1->setFont("Caviar");
  116.         tab1->setText("Tab1");
  117.         tab2->addChild(cb2);
  118.         tab2->setFont("Caviar");
  119.         tab2->setText("Tab2");
  120.  
  121.  
  122.         tabControl->setFont("Caviar");
  123.         tabControl->setTabType(YTab_horiz);
  124.         tabControl->setPadding({ 15, 15 });
  125.         tabControl->setSize({ 75, 35 });
  126.         tabControl->AddTab(tab1);
  127.         tabControl->AddTab(tab2);
  128.  
  129.  
  130.  
  131.         _timer_tick = 5.0f;
  132.     }
  133.  
  134.     YVoid Tick()
  135.     {
  136.        
  137.     }
  138.  
  139.     YVoid DestroyComponent()
  140.     {
  141.         YObject::safe_delete(_myWindow);
  142.         YObject::safe_delete(_myRenderer);
  143.         YObject::safe_delete(cb1);
  144.         YObject::safe_delete(cb2);
  145.         YObject::safe_delete(tb1);
  146.         YObject::safe_delete(tabControl);
  147.         YObject::safe_delete(tab1);
  148.         YObject::safe_delete(tab2);
  149.     }
  150.  
  151.     YVoid OnResetDevice()
  152.     {
  153.         _myRenderer->getFontData("Caviar")->OnResetDevice();
  154.     }
  155.  
  156.     YVoid OnLostDevice()
  157.     {
  158.         _myRenderer->getFontData("Caviar")->OnLostDevice();
  159.     }
  160.  
  161.     YVoid OnMouseMove(YInt x, YInt y)
  162.     {
  163.         tabControl->OnMouseMove(x, y);
  164.     }
  165.  
  166.     YVoid OnLeftMouseDown(YInt x, YInt y)
  167.     {
  168.         tabControl->OnLeftMouseDown(x, y);
  169.     }
  170.  
  171.     YVoid OnLeftMouseUp(YInt x, YInt y)
  172.     {
  173.         tabControl->OnLeftMouseUp(x, y);
  174.     }
  175.  
  176.     YVoid OnKeyDown(YInt i)
  177.     {
  178.         tabControl->OnKeyDown(i);
  179.     }
  180.  
  181.     YVoid OnKeyUp(YInt i)
  182.     {
  183.         tabControl->OnKeyUp(i);
  184.     }
  185.  
  186.  
  187.     YVoid Render()
  188.     {
  189.         if (!IShouldRender())
  190.             return;
  191.  
  192.         _myRenderer->Rect(0, 0, _myWindow->getWidth(), _myWindow->getHeigth(), D3DCOLOR_ARGB(255, 24, 24, 24));
  193.        
  194.         tabControl->Draw(_myRenderer);
  195.     }
  196.    
  197. };
  198.  
  199.  
  200.  
  201. int main(int argC, char* argV[])
  202. {  
  203.     YApplication* app = Start(argC, argV);
  204.  
  205.  
  206.     app->ApplicationRunForm(new MyForm());
  207.     return app->Exit();
  208. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement