File: notepad.h

package info (click to toggle)
btanks 0.9.8083-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 43,616 kB
  • sloc: cpp: 46,425; ansic: 12,005; xml: 4,262; python: 313; sh: 13; makefile: 13
file content (52 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download | duplicates (5)
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
#ifndef BTANKS_NOTEPAD_H__
#define BTANKS_NOTEPAD_H__

#include "sdlx/rect.h"
#include <string>
#include <vector>
#include "control.h"

namespace sdlx {
	class Surface;
	class Font;
}

//this notepad is actually a fake. 
//it's not a container, just a clickable tab bar :) sorry :)

class Notepad : public Control {
public: 
	Notepad(const int w, const std::string &font);
	void add(const std::string &area, const std::string &label);
	void render(sdlx::Surface &surface, const int x, const int y) const;
	void get_size(int &w, int &h) const;
	bool onMouse(const int button, const bool pressed, const int x, const int y);
	bool onKey(const SDL_keysym sym);
	void set(const int idx);
	int get() const { return (int)current_page; }
	
	void left();
	void right();

private:
	void recalculate_sizes();
	
	int tab_x1, tab_x2, tab_w, width;
	sdlx::Rect tab_left, tab_right, tab_bg;
	
	const sdlx::Surface * tabbg;
	const sdlx::Font * font;
	
	struct Page {
		std::string label;
		sdlx::Rect tab_rect;
		//aligning ? )
	};

	size_t current_page;
	
	std::vector<Page> pages;
};

#endif