File: Ctrl.h

package info (click to toggle)
ezquake 2.2%2Bgit20150324-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 6,996 kB
  • ctags: 16,582
  • sloc: ansic: 143,243; makefile: 339; tcl: 107; sh: 28
file content (93 lines) | stat: -rw-r--r-- 3,027 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
Copyright (C) 2011 azazello and ezQuake team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
//    $Id: Ctrl.h,v 1.14 2007-07-10 21:20:11 cokeman1982 Exp $

#ifndef __CTRL_H__
#define __CTRL_H__

#include "keys.h"

// this can be used to determine text block proportions
#define LETTERWIDTH 8
#define LETTERHEIGHT 8

//
// common GUI drawing methods
//
void UI_DrawCharacter (int cx, int line, int num);
void UI_Print (int cx, int cy, const char *str, int red);
int UI_DrawSlider (int x, int y, float range);
int UI_SliderWidth(void);
void UI_Print3 (int cx, int cy, const char *str, clrinfo_t *clr, int clr_cnt, int red);
void UI_Print_Center (int cx, int cy, int w, const char *str, int red);
void UI_Print_Center3 (int cx, int cy, int w, char *str, clrinfo_t *clr, int clr_cnt, int red);
void UI_DrawTextBox (int x, int y, int width, int lines);
void UI_MakeLine(char *buf, int w);
void UI_MakeLine2(char *buf, int w);
void UI_DrawColoredAlphaBox(int x, int y, int w, int h, color_t color);
void UI_DrawGrayBox(int x, int y, int w, int h);
void UI_DrawBox(int x, int y, int w, int h);

// prints the text into a box given by the area definitions (x,y, width, height)
// returned value determines, if the text did fit in the box
qbool UI_PrintTextBlock(int x, int y, int w, int h, const char* text, qbool red);

//
// <scrollbar>
// if this part gets too big, it might be moved to own header (Ctrl_*.h)
//

void ScrollBars_Init();

typedef void (*ScrollPos_setter) (double);

typedef struct ScrollBar_s {
    // current scrolling position in percentage 0-100%
    double curpos;                      

    // a function to which the scrollbar should report new scroll position
    ScrollPos_setter    scroll_fnc;     

    // should the scrollbar grab the mouse?
    // used to be able to scroll even if the mouse is a bit off
    qbool mouselocked;

    // scrollbar width and height
    int width, height;
} ScrollBar, *PScrollBar;

// scrollbar constructor
// 1st parameter: a function it should call, can be NULL
PScrollBar ScrollBar_Create(ScrollPos_setter);

// scrollbar destructor
void ScrollBar_Delete(PScrollBar);

// mouse event handler
// returns true if scrollbar changed it's position
qbool ScrollBar_MouseEvent(PScrollBar, const mouse_state_t*);

// scrollbar draw - starting point (x,y) and scrollbar's height (width is given internally)
void ScrollBar_Draw(PScrollBar, int x, int y, int h);

//
// </scrollbar>
//


#endif // __CTRL_H__