diff --git a/include/LCUI/LCUI_Font.h b/include/LCUI/LCUI_Font.h index 3e218904..2a5ad9f6 100755 --- a/include/LCUI/LCUI_Font.h +++ b/include/LCUI/LCUI_Font.h @@ -69,12 +69,12 @@ int Show_Font_Bitmap(LCUI_Bitmap *in_fonts); /* 功能:在å±�幕打å�°ä»¥0å’Œ1表示字体ä½�图 */ int Mix_Fonts_Bitmap( - LCUI_Graph *back_graph, /* 背景图形 */ - int start_x, - int start_y, + LCUI_Graph *back_graph, /* 背景图形 */ + int start_x, + int start_y, LCUI_Bitmap *in_fonts, /* 传入的字体ä½�图数æ�® */ - LCUI_RGB color, /* 字体的é…�色 */ - int flag + LCUI_RGB color, /* 字体的é…�色 */ + int flag ); /* 功能:将字体ä½�图数æ�®ä¸ŽèƒŒæ™¯å›¾å½¢æ··å�ˆ */ diff --git a/include/LCUI/LCUI_Label.h b/include/LCUI/LCUI_Label.h index 5c4f026d..b69d94cc 100755 --- a/include/LCUI/LCUI_Label.h +++ b/include/LCUI/LCUI_Label.h @@ -40,7 +40,7 @@ * ****************************************************************************/ #ifndef __LCUI_LABEL_H__ #define __LCUI_LABEL_H__ -typedef struct _LCUI_Label LCUI_Label; +typedef struct _LCUI_Label LCUI_Label; /**************************** lable部件 ********************************/ struct _LCUI_Label { @@ -87,4 +87,9 @@ void Set_Label_Font_Default_Color(LCUI_Widget *widget, LCUI_RGB color); LCUI_END_HEADER + +#ifdef __cplusplus +#include LC_LABEL_HPP +#endif + #endif diff --git a/include/LCUI/LCUI_Label.hpp b/include/LCUI/LCUI_Label.hpp new file mode 100644 index 00000000..8279b6d1 --- /dev/null +++ b/include/LCUI/LCUI_Label.hpp @@ -0,0 +1,79 @@ +/* *************************************************************************** + * LCUI_Label.hpp -- C++ class and function for Label widget + * + * Copyright (C) 2012 by + * Liu Chao + * + * This file is part of the LCUI project, and may only be used, modified, and + * distributed under the terms of the GPLv2. + * + * (GPLv2 is abbreviation of GNU General Public License Version 2) + * + * By continuing to use, modify, or distribute this file you indicate that you + * have read the license and understand and accept it fully. + * + * The LCUI project 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 GPL v2 for more details. + * + * You should have received a copy of the GPLv2 along with this file. It is + * usually in the LICENSE.TXT file, If not, see . + * ****************************************************************************/ + +/* **************************************************************************** + * LCUI_Label.h -- Îı¾±êÇ©(label)²¿¼þµÄC++ÀàºÍº¯Êý + * + * °æÈ¨ËùÓÐ (C) 2012 ¹éÊôÓÚ + * Áõ³¬ + * + * Õâ¸öÎļþÊÇLCUIÏîÄ¿µÄÒ»²¿·Ö£¬²¢ÇÒÖ»¿ÉÒÔ¸ù¾ÝGPLv2Ðí¿ÉЭÒéÀ´Ê¹Óᢸü¸ÄºÍ·¢²¼¡£ + * + * (GPLv2 ÊÇ GNUͨÓù«¹²Ðí¿ÉÖ¤µÚ¶þ°æ µÄÓ¢ÎÄËõд) + * + * ¼ÌÐøÊ¹Óá¢Ð޸Ļò·¢²¼±¾Îļþ£¬±íÃ÷ÄúÒѾ­ÔĶÁ²¢ÍêÈ«Àí½âºÍ½ÓÊÜÕâ¸öÐí¿ÉЭÒé¡£ + * + * LCUI ÏîÄ¿ÊÇ»ùÓÚʹÓÃÄ¿µÄ¶ø¼ÓÒÔÉ¢²¼µÄ£¬µ«²»¸ºÈκε£±£ÔðÈΣ¬ÉõÖÁûÓÐÊÊÏúÐÔ»òÌØ + * ¶¨ÓÃ;µÄÒþº¬µ£±££¬ÏêÇéÇë²ÎÕÕGPLv2Ðí¿ÉЭÒé¡£ + * + * ÄúÓ¦ÒÑÊÕµ½¸½ËæÓÚ±¾ÎļþµÄGPLv2Ðí¿ÉЭÒéµÄ¸±±¾£¬Ëüͨ³£ÔÚLICENSE.TXTÎļþÖУ¬Èç¹û + * ûÓУ¬Çë²é¿´£º. + * ****************************************************************************/ + +#ifndef __LCUI_LABEL_HPP__ +#define __LCUI_LABEL_HPP__ + +LCUIWidget::_Label::_Label(LCUIWidget *object) +{ + parent = object; +} + +int LCUIWidget::_Label::setText(const char *fmt, ...) +{ + if( parent->isError() ) { + return WIDGET_IS_NULL; + } + + char text[LABEL_TEXT_MAX_SIZE]; + memset(text, 0, sizeof(text)); + + LCUI_Label *p_label; + p_label = (LCUI_Label*)Get_Widget_Private_Data(parent->getWidget()); + + va_list ap; + va_start(ap, fmt); + vsnprintf(text, LABEL_TEXT_MAX_SIZE, fmt, ap); + va_end(ap); + + Strcpy( &p_label->text, text );/* ¿½±´×Ö·û´® */ + Draw_Widget( parent->getWidget() );/* ¸üв¿¼þ */ + return 0; +} + +int LCUIWidget::_Label::setFont(int font_pixel_size, char *fontfile) +{ + if( parent->isError() ) { + return WIDGET_IS_NULL; + } + return Set_Label_Font(parent->getWidget(), font_pixel_size, fontfile); +} +#endif diff --git a/include/LCUI/LCUI_Widget.hpp b/include/LCUI/LCUI_Widget.hpp index d305f604..ad73f54b 100644 --- a/include/LCUI/LCUI_Widget.hpp +++ b/include/LCUI/LCUI_Widget.hpp @@ -46,200 +46,173 @@ #define WIDGET_IS_NULL -5 -#include LC_WINDOW_H -#include LC_LABEL_H #include LC_GRAPHICS_H class LCUIWidget { - private: - int error; - LCUI_Widget **widget; - public: - LCUIWidget(const char* widget_type):Label(this),Window(this) - { - error = 0; - widget = new (LCUI_Widget *); - *widget = Create_Widget(widget_type); - if(*widget == NULL){ - error = 1; - } - } - ~LCUIWidget() - { - delete widget; - } - int isError() - { - return error; - } - LCUI_Widget *getWidget() - { - return *widget; - } - int resize(LCUI_Size new_size) - { - if( error ) return WIDGET_IS_NULL; - Resize_Widget( getWidget() , new_size); - return 0; - } - int move(LCUI_Pos new_pos) - { - if(error) return WIDGET_IS_NULL; - Move_Widget( getWidget() , new_pos); - return 0; - } - int show() - { - if(error) return WIDGET_IS_NULL; - Show_Widget( getWidget() ); - return 0; - } - int hide() - { - if(error) return WIDGET_IS_NULL; - Hide_Widget( getWidget() ); - return 0; - } - int refresh() - { - if(error) return WIDGET_IS_NULL; - Refresh_Widget( getWidget() ); - return 0; - } - int draw() - { - if(error) return WIDGET_IS_NULL; - Draw_Widget( getWidget() ); - return 0; - } - int enable() - { - if(error) return WIDGET_IS_NULL; - Enable_Widget( getWidget() ); - return 0; - } - int disable() - { - if(error) return WIDGET_IS_NULL; - Disable_Widget( getWidget() ); - return 0; - } - int setAlpha(unsigned char alpha) - { - if(error) return WIDGET_IS_NULL; - Set_Widget_Alpha( getWidget() , alpha); - return 0; - } - int setAlign(LCUI_Align align, LCUI_Pos offset_pos) - { - if(error) return WIDGET_IS_NULL; - Set_Widget_Align( getWidget() , align, offset_pos); - return 0; - } - int setBorder(LCUI_RGB color, LCUI_Border border) - { - if(error) return WIDGET_IS_NULL; - Set_Widget_Border( getWidget() , color, border); - return 0; - } - int setBackgroundImage(LCUI_Graph *img, int flag) - { - if(error) return WIDGET_IS_NULL; - return Set_Widget_Background_Image( getWidget() , img, flag); - } - - /* label widget */ - class _Label - { - public: - _Label(LCUIWidget *object) - { - parent = object; - } - int setText(const char *fmt, ...) - { - if( parent->isError() ) { - return WIDGET_IS_NULL; - } - - char text[LABEL_TEXT_MAX_SIZE]; - memset(text, 0, sizeof(text)); - - LCUI_Label *p_label; - p_label = (LCUI_Label*)Get_Widget_Private_Data(parent->getWidget()); - - va_list ap; - va_start(ap, fmt); - vsnprintf(text, LABEL_TEXT_MAX_SIZE, fmt, ap); - va_end(ap); - - Strcpy( &p_label->text, text );/* ¿½±´×Ö·û´® */ - Draw_Widget( parent->getWidget() );/* ¸üв¿¼þ */ - return 0; - } - int setFont(int font_pixel_size, char *fontfile) - { - if( parent->isError() ) { - return WIDGET_IS_NULL; - } - return Set_Label_Font(parent->getWidget(), font_pixel_size, fontfile); - } - private: - LCUIWidget *parent; - }; - _Label Label; - /* label widget end */ - - /* window widget */ + LCUIWidget(const char* widget_type); + ~LCUIWidget(); + int isError(); + LCUI_Widget *getWidget(); + int resize(LCUI_Size new_size); + int move(LCUI_Pos new_pos); + int show(); + int hide(); + int refresh(); + int draw(); + int enable(); + int disable(); + int setAlpha(unsigned char alpha); + int setAlign(LCUI_Align align, LCUI_Pos offset_pos); + int setBorder(LCUI_RGB color, LCUI_Border border); + int setBackgroundImage(LCUI_Graph *img, int flag); + /* window widget class */ class _Window - { + { public: - _Window( LCUIWidget *object ) - { - parent = object; - } - int setTitle( const char *text ) - { - if( parent->isError() ) { - return WIDGET_IS_NULL; - } - Set_Window_Title_Text(parent->getWidget(), text); - return 0; - } - int setIcon( LCUIGraph &icon ) - { - if( parent->isError() ) { - return WIDGET_IS_NULL; - } - Set_Window_Title_Icon(parent->getWidget(), &icon.graph); - return 0; - } - int setIcon( LCUI_Graph *icon ) - { - if( parent->isError() ) { - return WIDGET_IS_NULL; - } - Set_Window_Title_Icon(parent->getWidget(), icon); - return 0; - } - int addToClientArea(LCUIWidget &object) - { - if( parent->isError() ) { - return WIDGET_IS_NULL; - } - Window_Client_Area_Add(parent->getWidget(), object.getWidget()); - return 0; - } + _Window( LCUIWidget *object ); + int setTitle( const char *text ); + int setIcon( LCUIGraph &icon ); + int setIcon( LCUI_Graph *icon ); + int addToClientArea( LCUIWidget &object ); private: LCUIWidget *parent; }; - _Window Window; - /* window widget end */ + /* window widget class --end-- */ + + /* label widget class */ + class _Label + { + public: + _Label(LCUIWidget *object); + int setText(const char *fmt, ...); + int setFont(int font_pixel_size, char *fontfile); + + private: + LCUIWidget *parent; + }; + /* label widget class --end-- */ + _Label Label; + _Window Window; + + private: + int error; + LCUI_Widget **widget; + }; + +#include LC_WINDOW_H +#include LC_LABEL_H + + +LCUIWidget::LCUIWidget(const char* widget_type):Label(this),Window(this) +{ + error = 0; + widget = new (LCUI_Widget *); + *widget = Create_Widget(widget_type); + if(*widget == NULL){ + error = 1; + } +} + +LCUIWidget::~LCUIWidget() +{ + delete this->widget; +} + +int LCUIWidget::isError() +{ + return error; +} + +LCUI_Widget *LCUIWidget::getWidget() +{ + return *widget; +} + +int LCUIWidget::resize(LCUI_Size new_size) +{ + if( isError() ) return WIDGET_IS_NULL; + Resize_Widget( getWidget() , new_size ); + return 0; +} + +int LCUIWidget::move(LCUI_Pos new_pos) +{ + if( isError() ) return WIDGET_IS_NULL; + Move_Widget( getWidget() , new_pos ); + return 0; +} + +int LCUIWidget::show() +{ + if( isError() ) return WIDGET_IS_NULL; + Show_Widget( getWidget() ); + return 0; +} + +int LCUIWidget::hide() +{ + if( isError() ) return WIDGET_IS_NULL; + Hide_Widget( getWidget() ); + return 0; +} + +int LCUIWidget::refresh() +{ + if( isError() ) return WIDGET_IS_NULL; + Refresh_Widget( getWidget() ); + return 0; +} + +int LCUIWidget::draw() +{ + if( isError() ) return WIDGET_IS_NULL; + Draw_Widget( getWidget() ); + return 0; +} + +int LCUIWidget::enable() +{ + if( isError() ) return WIDGET_IS_NULL; + Enable_Widget( getWidget() ); + return 0; +} + +int LCUIWidget::disable() +{ + if( isError() ) return WIDGET_IS_NULL; + Disable_Widget( getWidget() ); + return 0; +} + +int LCUIWidget::setAlpha(unsigned char alpha) +{ + if( isError() ) return WIDGET_IS_NULL; + Set_Widget_Alpha( getWidget() , alpha); + return 0; +} +int LCUIWidget::setAlign(LCUI_Align align, LCUI_Pos offset_pos) +{ + if( isError() ) return WIDGET_IS_NULL; + Set_Widget_Align( getWidget() , align, offset_pos); + return 0; +} +int LCUIWidget::setBorder(LCUI_RGB color, LCUI_Border border) +{ + if( isError() ) return WIDGET_IS_NULL; + Set_Widget_Border( getWidget() , color, border); + return 0; +} +int LCUIWidget::setBackgroundImage(LCUI_Graph *img, int flag) +{ + if( isError() ) return WIDGET_IS_NULL; + return Set_Widget_Background_Image( getWidget() , img, flag); +} + #endif #endif diff --git a/include/LCUI/LCUI_Window.h b/include/LCUI/LCUI_Window.h index c7d563bd..9ffe9198 100755 --- a/include/LCUI/LCUI_Window.h +++ b/include/LCUI/LCUI_Window.h @@ -101,4 +101,8 @@ void Window_TitleBar_Add(LCUI_Widget *window, LCUI_Widget *widget); LCUI_END_HEADER +#ifdef __cplusplus +#include LC_WINDOW_HPP +#endif + #endif /* __LCUI_WINDOW_H__ */ diff --git a/include/LCUI/LCUI_Window.hpp b/include/LCUI/LCUI_Window.hpp new file mode 100644 index 00000000..f1740f6c --- /dev/null +++ b/include/LCUI/LCUI_Window.hpp @@ -0,0 +1,89 @@ +/* *************************************************************************** + * LCUI_Window.h -- C++ class and function for window widget + * + * Copyright (C) 2012 by + * Liu Chao + * + * This file is part of the LCUI project, and may only be used, modified, and + * distributed under the terms of the GPLv2. + * + * (GPLv2 is abbreviation of GNU General Public License Version 2) + * + * By continuing to use, modify, or distribute this file you indicate that you + * have read the license and understand and accept it fully. + * + * The LCUI project 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 GPL v2 for more details. + * + * You should have received a copy of the GPLv2 along with this file. It is + * usually in the LICENSE.TXT file, If not, see . + * ****************************************************************************/ + +/* **************************************************************************** + * LCUI_Window.h -- ´°¿Ú²¿¼þµÄC++ÀàºÍº¯Êý + * + * °æÈ¨ËùÓÐ (C) 2012 ¹éÊôÓÚ + * Áõ³¬ + * + * Õâ¸öÎļþÊÇLCUIÏîÄ¿µÄÒ»²¿·Ö£¬²¢ÇÒÖ»¿ÉÒÔ¸ù¾ÝGPLv2Ðí¿ÉЭÒéÀ´Ê¹Óᢸü¸ÄºÍ·¢²¼¡£ + * + * (GPLv2 ÊÇ GNUͨÓù«¹²Ðí¿ÉÖ¤µÚ¶þ°æ µÄÓ¢ÎÄËõд) + * + * ¼ÌÐøÊ¹Óá¢Ð޸Ļò·¢²¼±¾Îļþ£¬±íÃ÷ÄúÒѾ­ÔĶÁ²¢ÍêÈ«Àí½âºÍ½ÓÊÜÕâ¸öÐí¿ÉЭÒé¡£ + * + * LCUI ÏîÄ¿ÊÇ»ùÓÚʹÓÃÄ¿µÄ¶ø¼ÓÒÔÉ¢²¼µÄ£¬µ«²»¸ºÈκε£±£ÔðÈΣ¬ÉõÖÁûÓÐÊÊÏúÐÔ»òÌØ + * ¶¨ÓÃ;µÄÒþº¬µ£±££¬ÏêÇéÇë²ÎÕÕGPLv2Ðí¿ÉЭÒé¡£ + * + * ÄúÓ¦ÒÑÊÕµ½¸½ËæÓÚ±¾ÎļþµÄGPLv2Ðí¿ÉЭÒéµÄ¸±±¾£¬Ëüͨ³£ÔÚLICENSE.TXTÎļþÖУ¬Èç¹û + * ûÓУ¬Çë²é¿´£º. + * ****************************************************************************/ +#ifndef __LCUI_WINDOW_HPP_ +#define __LCUI_WINDOW_HPP_ + +LCUIWidget::_Window::_Window( LCUIWidget *object ) +{ + parent = object; +} + +int LCUIWidget::_Window::setTitle( const char *text ) +{ + if( parent->isError() ) { + return WIDGET_IS_NULL; + } + Set_Window_Title_Text(parent->getWidget(), text); + return 0; +} + +int LCUIWidget::_Window::setIcon( LCUIGraph &icon ) +{ + if( parent->isError() ) { + return WIDGET_IS_NULL; + } + Set_Window_Title_Icon(parent->getWidget(), &icon.graph); + return 0; +} + +int LCUIWidget::_Window::setIcon( LCUI_Graph *icon ) +{ + if( parent->isError() ) { + return WIDGET_IS_NULL; + } + Set_Window_Title_Icon(parent->getWidget(), icon); + return 0; +} + +int LCUIWidget::_Window::addToClientArea( LCUIWidget &object ) +{ + if( parent->isError() ) { + return WIDGET_IS_NULL; + } + Window_Client_Area_Add(parent->getWidget(), object.getWidget()); + return 0; +} +#endif + + + + + diff --git a/include/LCUI/Makefile.am b/include/LCUI/Makefile.am index 8b76068a..d7184018 100755 --- a/include/LCUI/Makefile.am +++ b/include/LCUI/Makefile.am @@ -16,8 +16,8 @@ LCUI_PictureBox.h \ LCUI_ProgressBar.h \ LCUI_Cursor.h \ LCUI_Error.h \ -LCUI_Label.h \ -LCUI_Window.h \ +LCUI_Label.h LCUI_Label.hpp\ +LCUI_Window.h LCUI_Window.hpp\ LCUI_Memory.h \ LCUI_Menu.h \ LCUI_CheckBox.h \ diff --git a/include/LCUI/Makefile.in b/include/LCUI/Makefile.in index e463ffab..6a98d396 100644 --- a/include/LCUI/Makefile.in +++ b/include/LCUI/Makefile.in @@ -220,8 +220,8 @@ LCUI_PictureBox.h \ LCUI_ProgressBar.h \ LCUI_Cursor.h \ LCUI_Error.h \ -LCUI_Label.h \ -LCUI_Window.h \ +LCUI_Label.h LCUI_Label.hpp\ +LCUI_Window.h LCUI_Window.hpp\ LCUI_Memory.h \ LCUI_Menu.h \ LCUI_CheckBox.h \ diff --git a/include/LCUI_Build.h b/include/LCUI_Build.h index b90bc347..fc3e7a1d 100644 --- a/include/LCUI_Build.h +++ b/include/LCUI_Build.h @@ -74,7 +74,9 @@ /* 一些部件的头文件路径 */ #define LC_WINDOW_H +#define LC_WINDOW_HPP #define LC_LABEL_H +#define LC_LABEL_HPP #define LC_BUTTON_H #define LC_PICBOX_H #define LC_PROGBAR_H