gltiki

view src/label.c @ 0:ea177566fe79

initial commit
author John Tsiombikas <nuclear@mutantstargoat.com>
date Sat, 07 Jul 2012 07:07:40 +0300
parents
children
line source
1 /*
2 A simple cross-platform OpenGL GUI toolkit
3 Copyright (C) 2012 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser 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.
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 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "gltiki_impl.h"
20 static void draw(gltk_widget *w);
22 gltk_widget *gltk_label(const char *text)
23 {
24 gltk_widget *w;
25 struct gltk_label *lab;
27 if(!(w = gltk_create_widget())) {
28 return 0;
29 }
30 w->type = LABEL;
31 w->width = gltk_text_width(text) + gltk_char_width(-1) * 2.0;
32 w->height = gltk_char_height(-1) * 1.5;
33 w->draw = draw;
35 lab = (struct gltk_label*)w;
36 if(!(lab->text = malloc(strlen(text) + 1))) {
37 free(w);
38 return 0;
39 }
40 strcpy(lab->text, text);
42 return w;
43 }
45 static void draw(gltk_widget *w)
46 {
48 }