Colobot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
list.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2014, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsiteс.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 // list.h
21 
22 #pragma once
23 
24 
25 #include "ui/control.h"
26 #include "ui/button.h"
27 #include "ui/scroll.h"
28 
29 #include "common/event.h"
30 #include "common/misc.h"
31 
32 #include "graphics/engine/text.h"
33 
34 
35 namespace Ui {
36 
37 const int LISTMAXDISPLAY = 20; // maximum number of visible lines
38 const int LISTMAXTOTAL = 100; // maximum total number of lines
39 
40 
41 
42 class CList : public CControl
43 {
44  public:
45  CList();
46  ~CList();
47 
48  bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventMsg, float expand);
49 
50  void SetPos(Math::Point pos);
51  void SetDim(Math::Point dim);
52 
53  bool SetState(int state, bool bState);
54  bool SetState(int state);
55  bool ClearState(int state);
56 
57  bool EventProcess(const Event &event);
58  void Draw();
59 
60  void Flush();
61 
62  void SetTotal(int i);
63  int GetTotal();
64 
65  void SetSelect(int i);
66  int GetSelect();
67 
68  void SetSelectCap(bool bEnable);
69  bool GetSelectCap();
70 
71  void SetBlink(bool bEnable);
72  bool GetBlink();
73 
74  void SetItemName(int i, const char* name);
75  char* GetItemName(int i);
76 
77  void SetCheck(int i, bool bMode);
78  bool GetCheck(int i);
79 
80  void SetEnable(int i, bool bEnable);
81  bool GetEnable(int i);
82 
83  void SetTabs(int i, float pos, Gfx::TextAlign justif=Gfx::TEXT_ALIGN_LEFT);
84  float GetTabs(int i);
85 
86  void ShowSelect(bool bFixed);
87 
88  EventType GetEventMsgButton(int i);
89  EventType GetEventMsgScroll();
90 
91  protected:
92  bool MoveAdjust();
93  void UpdateButton();
94  void UpdateScroll();
95  void MoveScroll();
96  void DrawCase(char *text, Math::Point pos, float width, Gfx::TextAlign justif);
97 
98  private:
99  // Overridden to avoid warning about hiding the virtual function
100  virtual bool Create(Math::Point pos, Math::Point dim, int icon, EventType eventType) OVERRIDE;
101 
102  protected:
103  CButton* m_button[LISTMAXDISPLAY];
104  CScroll* m_scroll;
105 
106  EventType m_eventButton[LISTMAXDISPLAY];
107  EventType m_eventScroll;
108 
109  float m_expand;
110  int m_totalLine; // total number of lines
111  int m_displayLine; // number of visible lines
112  int m_selectLine; // selected line
113  int m_firstLine; // first visible line
114  bool m_bBlink;
115  bool m_bSelectCap;
116  float m_blinkTime;
117  float m_tabs[10];
118  Gfx::TextAlign m_justifs[10];
119 
120  char m_text[LISTMAXTOTAL][100];
121  char m_check[LISTMAXTOTAL];
122  char m_enable[LISTMAXTOTAL];
123 };
124 
125 
126 } // namespace Ui
127 
Definition: controller.h:32
Text rendering - CText class.
Definition: list.h:42
Definition: button.h:30
2D point
Definition: point.h:49
Event types, structs and event queue.
TextAlign
Type of text alignment.
Definition: text.h:51
Definition: scroll.h:37
EventType
Type of event message.
Definition: event.h:38
Event sent by system, interface or game.
Definition: event.h:678
Definition: control.h:66