12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /*
- * Part of LaGUI demonstration programs
- * Copyright (C) 2022-2023 Wu Yiming
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program 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
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include "la_5.h"
- extern LA MAIN;
- typedef struct My{
- int _pad;
- laSafeString* Name;
- int Age;
- int Gender;
- real Height;
- } My;
- My Stats;
- void* myget_Stats(void* unused, void* unused1){
- return &Stats;
- }
- void MyProperties(laUiList *uil, laPropPack *This, laPropPack *DetachedProps, laColumn *UNUSED, int context){
- laColumn* c=laFirstColumn(uil);
- laShowLabel(uil,c,"Hello world!",0,0);
- laShowItem(uil,c,0,"me.name");
- laShowItem(uil,c,0,"me.age");
- laShowItem(uil,c,0,"me.height");
- laShowItem(uil,c,0,"me.gender");
- }
- int main(int argc, char *argv[]){
- laGetReady();
- Stats.Age=25;
- Stats.Gender=0;
- Stats.Height=1.76;
- strSafeSet(&Stats.Name,"ChengduLittleA");
- laPropContainer* root=laDefineRoot();
- laAddSubGroup(root,"me","Me","Me root", "my", 0,0,0,0,myget_Stats,0,0,0,0,0,0,0);
- laPropContainer* my=laAddPropertyContainer("my", "My", "Struct My",0,0,0,0,0,LA_PROP_OTHER_ALLOC);
- laAddStringProperty(my, "name", "Name", "My name",0,0,0,0,1,offsetof(My,Name),0,0,0,0,0);
- laAddIntProperty(my, "age", "Age", "My age",0,0,"years old",100,0,1,25,0,offsetof(My,Age),0,0,0,0,0,0,0,0,0,0,0);
- laAddFloatProperty(my, "height", "Height", "My height",0,0,"cm",2,0.3,0.01,1.76,0,offsetof(My,Height),0,0,0,0,0,0,0,0,0,0,0);
- laProp* ep=laAddEnumProperty(my, "gender","Gender","My gender",0,0,0,0,0,offsetof(My,Gender),0,0,0,0,0,0,0,0,0,0);
- laAddEnumItemAs(ep,"MALE","Male","Gender being male",0,L'♂');
- laAddEnumItemAs(ep,"FEMALE","female","Gender being female",1,L'♀');
- laRegisterUiTemplate("my_properties","Properties", MyProperties,0,0,"Demonstration", 0,0,0);
- // Uncomment this to load preferences.
- // laEnsureUserPreferences();
- if(!MAIN.Windows.pFirst){
- laWindow* w = laDesignWindow(-1,-1,600,600);
- laLayout* l = laDesignLayout(w,"My Layout");
- laCreatePanel(l->FirstBlock,"my_properties");
- laStartWindow(w);
- }
- laMainLoop();
- }
|