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