gltiki
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/label.c Sat Jul 07 07:07:40 2012 +0300 1.3 @@ -0,0 +1,48 @@ 1.4 +/* 1.5 +A simple cross-platform OpenGL GUI toolkit 1.6 +Copyright (C) 2012 John Tsiombikas <nuclear@member.fsf.org> 1.7 + 1.8 +This program is free software: you can redistribute it and/or modify 1.9 +it under the terms of the GNU Lesser General Public License as published by 1.10 +the Free Software Foundation, either version 3 of the License, or 1.11 +(at your option) any later version. 1.12 + 1.13 +This program is distributed in the hope that it will be useful, 1.14 +but WITHOUT ANY WARRANTY; without even the implied warranty of 1.15 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1.16 +GNU Lesser General Public License for more details. 1.17 + 1.18 +You should have received a copy of the GNU Lesser General Public License 1.19 +along with this program. If not, see <http://www.gnu.org/licenses/>. 1.20 +*/ 1.21 +#include "gltiki_impl.h" 1.22 + 1.23 +static void draw(gltk_widget *w); 1.24 + 1.25 +gltk_widget *gltk_label(const char *text) 1.26 +{ 1.27 + gltk_widget *w; 1.28 + struct gltk_label *lab; 1.29 + 1.30 + if(!(w = gltk_create_widget())) { 1.31 + return 0; 1.32 + } 1.33 + w->type = LABEL; 1.34 + w->width = gltk_text_width(text) + gltk_char_width(-1) * 2.0; 1.35 + w->height = gltk_char_height(-1) * 1.5; 1.36 + w->draw = draw; 1.37 + 1.38 + lab = (struct gltk_label*)w; 1.39 + if(!(lab->text = malloc(strlen(text) + 1))) { 1.40 + free(w); 1.41 + return 0; 1.42 + } 1.43 + strcpy(lab->text, text); 1.44 + 1.45 + return w; 1.46 +} 1.47 + 1.48 +static void draw(gltk_widget *w) 1.49 +{ 1.50 + 1.51 +}