1 /*$ 2 Copyright (C) 2016-2020 Azel. 3 4 This file is part of AzPainterB. 5 6 AzPainterB is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 AzPainterB is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 $*/ 19 20 #ifndef MLIB_BUTTON_H 21 #define MLIB_BUTTON_H 22 23 #include "mWidgetDef.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 #define M_BUTTON(p) ((mButton *)(p)) 30 31 typedef struct _mButton mButton; 32 33 typedef struct 34 { 35 char *text; 36 int textW; 37 uint32_t style,flags,press_key; 38 void (*onPressed)(mButton *); 39 }mButtonData; 40 41 struct _mButton 42 { 43 mWidget wg; 44 mButtonData btt; 45 }; 46 47 enum MBUTTON_STYLE 48 { 49 MBUTTON_S_REAL_W = 1<<0, 50 MBUTTON_S_REAL_H = 1<<1, 51 52 MBUTTON_S_REAL_WH = MBUTTON_S_REAL_W | MBUTTON_S_REAL_H 53 }; 54 55 enum MBUTTON_NOTIFY 56 { 57 MBUTTON_N_PRESS 58 }; 59 60 /*--------*/ 61 62 void mButtonDestroyHandle(mWidget *p); 63 void mButtonCalcHintHandle(mWidget *p); 64 void mButtonDrawHandle(mWidget *p,mPixbuf *pixbuf); 65 int mButtonEventHandle(mWidget *wg,mEvent *ev); 66 67 mButton *mButtonCreate(mWidget *parent,int id,uint32_t style,uint32_t fLayout,uint32_t marginB4,const char *text); 68 69 mButton *mButtonNew(int size,mWidget *parent,uint32_t style); 70 void mButtonSetText(mButton *p,const char *text); 71 void mButtonSetPress(mButton *p,mBool press); 72 mBool mButtonIsPressed(mButton *p); 73 74 void mButtonDrawBase(mButton *p,mPixbuf *pixbuf,mBool pressed); 75 76 #ifdef __cplusplus 77 } 78 #endif 79 80 #endif 81