~tux-style/eflxx/eflxx_examples

« back to all changes in this revision

Viewing changes to src/elementaryxx/full/test_genlist.cpp

  • Committer: seoz
  • Date: 2011-04-13 13:25:55 UTC
  • Revision ID: svn-v4:7cbeb6ba-43b4-40fd-8cce-4c39aea84d33:trunk/BINDINGS/cxx/eflxx_examples:58633
BINDINGS/cxx elementaryxx: Removed trailing whitespaces.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
  GenListColumnConstructor1 () :
14
14
    mItemNum (0)
15
15
  {}
16
 
  
 
16
 
17
17
  void setItemNum (int num) {mItemNum = num;}
18
18
  int getItemNum () const {return mItemNum;}
19
 
  
 
19
 
20
20
private:
21
21
  int mItemNum;
22
22
};
30
30
  ~GenListDataModel1 () {}
31
31
 
32
32
  std::string getLabel (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part) const
33
 
  { 
 
33
  {
34
34
    GenListColumnConstructor1 *construct1 = static_cast <GenListColumnConstructor1*> (construction);
35
35
    cout << "GenListDataModel::getLabel" << endl;
36
36
 
37
37
    return "Item " + toString <int> (construct1->getItemNum ());
38
38
  }
39
 
    
 
39
 
40
40
  Elmxx::Object *getIcon (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part)
41
41
  {
42
42
    Icon *ic = Icon::factory (obj);
43
43
    ic->setFile (searchPixmapFile ("elementaryxx/logo_small.png"));
44
44
    ic->setAspectHintSize (EVAS_ASPECT_CONTROL_VERTICAL, Eflxx::Size (1, 1));
45
 
    
 
45
 
46
46
    //part: elm.swallow.icon
47
47
    //part: elm.swallow.end
48
48
 
60
60
public:
61
61
  void setItemNum (int num) {mItemNum = num;}
62
62
  int getItemNum () const {return mItemNum;}
63
 
  
 
63
 
64
64
private:
65
65
  int mItemNum;
66
66
};
78
78
 * Hint: 'selectList1' isn't cleaned up at exit. Normal applications should do this.
79
79
 *       This could be done at the GenList or Window destructor. For this example it's ok...
80
80
 */
81
 
std::vector <GenListColumnSelector1*> selectList1; 
 
81
std::vector <GenListColumnSelector1*> selectList1;
82
82
 
83
83
void glSelected (GenListColumnSelector &selection, const Evasxx::Object &obj, void *event_info)
84
84
{
85
85
  GenListColumnSelector1 *selection1 = static_cast <GenListColumnSelector1*> (&selection);
86
 
  
 
86
 
87
87
  cout << "glSelected: " << selection1->getItemNum () << endl;
88
88
}
89
89
 
91
91
{
92
92
  int where = 0;
93
93
  Eflxx::Point pos (ev.data->cur.canvas.x, ev.data->cur.canvas.y);
94
 
  
 
94
 
95
95
  GenListItem *gli = gl->getItemAtXY (pos, where);
96
96
 
97
97
  if (gli)
135
135
  Window *win = Window::factory ("genlist", ELM_WIN_BASIC);
136
136
  win->setTitle ("GenList");
137
137
  win->setAutoDel (true);
138
 
  
 
138
 
139
139
  Background *bg = Background::factory (*win);
140
140
  win->addObjectResize (*bg);
141
141
  bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
142
142
  bg->show ();
143
 
  
 
143
 
144
144
  Box *bx = Box::factory (*win);
145
145
  bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
146
146
  win->addObjectResize (*bx);
147
147
  bx->show ();
148
 
  
 
148
 
149
149
  GenList *gl = GenList::factory (*win);
150
150
  gl->getEventSignal ("selected")->connect (sigc::ptr_fun (&_gl_selected));
151
151
  gl->getEventSignal ("clicked")->connect (sigc::ptr_fun (&_gl_clicked));
159
159
  gl->show ();
160
160
 
161
161
  Eflxx::CountedPtr <Evasxx::Canvas> canvas (win->getEvas ());
162
 
  
 
162
 
163
163
  Evasxx::Rectangle *over = new Evasxx::Rectangle (*canvas);
164
164
  over->setColor (Eflxx::Color (0, 0, 0, 0));
165
165
  over->signalHandleMouseMove.connect (sigc::bind (sigc::ptr_fun (&_move), gl));
177
177
  bt_1500->setLabel ("Go to 1500");
178
178
  bx->packEnd (*bt_1500);
179
179
  bt_1500->show ();
180
 
  
 
180
 
181
181
  gl->setDataModel (model);
182
 
  
 
182
 
183
183
  gl->signalSelect.connect (sigc::ptr_fun (&glSelected));
184
 
  
 
184
 
185
185
  for (int i = 0; i < 2000; i++)
186
186
  {
187
187
    GenListColumnConstructor1 *construct1 = new GenListColumnConstructor1 ();
189
189
 
190
190
    GenListColumnSelector1 *select1 = new GenListColumnSelector1 ();
191
191
    select1->setItemNum (i * 10);
192
 
    
 
192
 
193
193
    GenListItem *gli = gl->append (construct1, NULL, ELM_GENLIST_ITEM_NONE, select1);
194
194
 
195
195
    constructList1.push_back (construct1);
204
204
      bt_1500->getEventSignal ("clicked")->connect (sigc::bind (sigc::ptr_fun (&_bt1500_cb), gli));
205
205
    }
206
206
  }
207
 
    
 
207
 
208
208
  win->resize (Size (480, 800));
209
209
  win->show ();
210
210
}
225
225
  construct1->setItemNum (i);
226
226
  GenListColumnSelector1 *select1 = new GenListColumnSelector1 ();
227
227
  select1->setItemNum (i*10);
228
 
  
 
228
 
229
229
  GenListItem *gli = gl->append (construct1, NULL, ELM_GENLIST_ITEM_NONE, select1);
230
230
 
231
231
  i++;
235
235
{
236
236
  static int i = 0;
237
237
  GenListItem *gliSel = gl->getItemSelected ();
238
 
  
 
238
 
239
239
  if (!gliSel)
240
240
  {
241
241
          cout << "no item selected" << endl;
247
247
  construct1->setItemNum (i);
248
248
  GenListColumnSelector1 *select1 = new GenListColumnSelector1 ();
249
249
  select1->setItemNum (i*10);
250
 
  
 
250
 
251
251
  GenListItem *gli = gl->insertBefore (construct1, gliSel, ELM_GENLIST_ITEM_NONE, select1);
252
252
 
253
253
  i++;
257
257
{
258
258
  static int i = 0;
259
259
  GenListItem *gliSel = gl->getItemSelected ();
260
 
  
 
260
 
261
261
  if (!gliSel)
262
262
  {
263
263
          cout << "no item selected" << endl;
269
269
  construct1->setItemNum (i);
270
270
  GenListColumnSelector1 *select1 = new GenListColumnSelector1 ();
271
271
  select1->setItemNum (i*10);
272
 
  
 
272
 
273
273
  GenListItem *gli = gl->insertAfter (construct1, gliSel, ELM_GENLIST_ITEM_NONE, select1);
274
274
 
275
275
  i++;
310
310
    it->update ();
311
311
    cout << i << endl;
312
312
    i++;
313
 
    
 
313
 
314
314
    //it = elm_genlist_item_next_get(it);
315
315
  }*/
316
316
}
323
323
 
324
324
  if (!gli)
325
325
    return;
326
 
  
 
326
 
327
327
  gli->show ();
328
328
  gli->setSelected (true);
329
329
}
334
334
 
335
335
  if (!gli)
336
336
    return;
337
 
  
 
337
 
338
338
  gli->show ();
339
339
  gli->setSelected (true);
340
340
}
357
357
 
358
358
  Button *bt = NULL;
359
359
  Box *bx2 = NULL;
360
 
    
 
360
 
361
361
  Window *win = Window::factory ("genlist-2", ELM_WIN_BASIC);
362
362
  win->setTitle ("GenList 2");
363
363
  win->setAutoDel (true);
364
 
  
 
364
 
365
365
  Background *bg = Background::factory (*win);
366
366
  win->addObjectResize (*bg);
367
367
  bg->setFile (searchPixmapFile ("elementaryxx/plant_01.jpg"));
368
368
  bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
369
369
  bg->show ();
370
 
  
 
370
 
371
371
  Box *bx = Box::factory (*win);
372
372
  bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
373
373
  win->addObjectResize (*bx);
465
465
  bt->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);/*************/
466
466
  bt->setWeightHintSize (EVAS_HINT_EXPAND, 0.0);
467
467
  bx2->packEnd (*bt);
468
 
  bt->show (); 
 
468
  bt->show ();
469
469
 
470
470
  bx->packEnd (*bx2);
471
471
  bx2->show ();
483
483
  bt->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);
484
484
  bt->setWeightHintSize (EVAS_HINT_EXPAND, 0.0);
485
485
  bx2->packEnd (*bt);
486
 
  bt->show (); 
 
486
  bt->show ();
487
487
 
488
488
  bt = Button::factory (*win);
489
489
  bt->setLabel ("+");
491
491
  bt->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);
492
492
  bt->setWeightHintSize (EVAS_HINT_EXPAND, 0.0);
493
493
  bx2->packEnd (*bt);
494
 
  bt->show (); 
 
494
  bt->show ();
495
495
 
496
496
  bt = Button::factory (*win);
497
497
  bt->setLabel ("-");
499
499
  bt->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);
500
500
  bt->setWeightHintSize (EVAS_HINT_EXPAND, 0.0);
501
501
  bx2->packEnd (*bt);
502
 
  bt->show (); 
503
 
  
 
502
  bt->show ();
 
503
 
504
504
  bx->packEnd (*bx2);
505
505
  bx2->show ();
506
506
 
509
509
  bx3->setHomogenous (true);
510
510
  bx3->setWeightHintSize (EVAS_HINT_EXPAND, 0.0);
511
511
  bx3->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);
512
 
  
 
512
 
513
513
  bt = Button::factory (*win);
514
514
  bt->setLabel ("+ before");
515
515
  bt->getEventSignal ("clicked")->connect (sigc::bind (sigc::ptr_fun (&my_gl_insert_before), gl));
516
516
  bt->setAlignHintSize (EVAS_HINT_FILL, EVAS_HINT_FILL);
517
517
  bt->setWeightHintSize (EVAS_HINT_EXPAND, 0.0);
518
518
  bx3->packEnd (*bt);
519
 
  bt->show (); 
 
519
  bt->show ();
520
520
 
521
521
  bt = Button::factory (*win);
522
522
  bt->setLabel ("+ after");
533
533
  bt->setWeightHintSize (EVAS_HINT_EXPAND, 0.0);
534
534
  bx3->packEnd (*bt);
535
535
  bt->show ();
536
 
  
 
536
 
537
537
  bx->packEnd (*bx3);
538
538
  bx3->show ();
539
539
 
555
555
  GenListColumnConstructor3 () :
556
556
    mTestItem (NULL)
557
557
  {}
558
 
  
 
558
 
559
559
  void setTestItem (TestItem *testItem) {mTestItem = testItem;}
560
560
  TestItem *getTestItem () const {return mTestItem;}
561
 
  
 
561
 
562
562
private:
563
563
  TestItem *mTestItem;
564
564
};
569
569
  GenListColumnSelector3 () :
570
570
    mTestItem (NULL)
571
571
  {}
572
 
    
 
572
 
573
573
  void setTestItem (TestItem *testItem) {mTestItem = testItem;}
574
574
  TestItem *getTestItem () const {return mTestItem;}
575
 
  
 
575
 
576
576
private:
577
577
  TestItem *mTestItem;
578
578
};
586
586
  ~GenListDataModel3 () {}
587
587
 
588
588
  std::string getLabel (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part) const
589
 
  { 
 
589
  {
590
590
    GenListColumnConstructor3 *construct1 = static_cast <GenListColumnConstructor3*> (construction);
591
591
    cout << "GenListDataModel::getLabel" << endl;
592
592
 
593
593
    return "Item mode " + toString <int> (construct1->getTestItem ()->mode);
594
594
  }
595
 
    
 
595
 
596
596
  Elmxx::Object *getIcon (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part)
597
597
  {
598
598
    GenListColumnConstructor3 *construct1 = static_cast <GenListColumnConstructor3*> (construction);
599
599
    int mode = construct1->getTestItem ()->mode;
600
 
    
 
600
 
601
601
    Icon *ic = Icon::factory (obj);
602
602
 
603
603
    string iconName;
612
612
        iconName = searchPixmapFile ("elementaryxx/panel_01.jpg");
613
613
      else if ((mode & 0x3) == 3)
614
614
        iconName = searchPixmapFile ("elementaryxx/rock_01.jpg");
615
 
      
 
615
 
616
616
      ic->setFile (iconName);
617
617
    }
618
618
    else if (part == "elm.swallow.end")
625
625
        iconName = searchPixmapFile ("elementaryxx/sky_03.jpg");
626
626
      else if ((mode & 0x3) == 3)
627
627
        iconName = searchPixmapFile ("elementaryxx/sky_04.jpg");
628
 
           
 
628
 
629
629
      ic->setFile (iconName);
630
630
     }
631
 
    
 
631
 
632
632
    ic->setAspectHintSize (EVAS_ASPECT_CONTROL_VERTICAL, Eflxx::Size (1, 1));
633
633
 
634
634
    return ic;
643
643
void glSelected3 (GenListColumnSelector &selection, const Evasxx::Object &obj, void *event_info)
644
644
{
645
645
  GenListColumnSelector3 *selection1 = static_cast <GenListColumnSelector3*> (&selection);
646
 
  
 
646
 
647
647
  cout << "glSelected3 mode " << selection1->getTestItem ()->mode << endl;
648
648
}
649
649
 
658
658
  Window *win = Window::factory ("genlist-3", ELM_WIN_BASIC);
659
659
  win->setTitle ("GenList 2");
660
660
  win->setAutoDel (true);
661
 
  
 
661
 
662
662
  Background *bg = Background::factory (*win);
663
663
  win->addObjectResize (*bg);
664
664
  bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
665
665
  bg->show ();
666
 
  
 
666
 
667
667
  Box *bx = Box::factory (*win);
668
668
  bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
669
669
  win->addObjectResize (*bx);
676
676
  gl->show ();
677
677
 
678
678
  gl->setDataModel (model3);
679
 
  
 
679
 
680
680
  gl->signalSelect.connect (sigc::ptr_fun (&glSelected3));
681
681
 
682
682
  GenListColumnConstructor3 *construct1 = new GenListColumnConstructor3 ();
742
742
static void my_gl_item_check_changed (Evasxx::Object &obj, void *event_info, TestItem *tit)
743
743
{
744
744
  Check *check = static_cast <Check*> (&obj);
745
 
  
 
745
 
746
746
  tit->onoff = check->getState ();
747
747
  printf("item %p onoff = %i\n", tit, tit->onoff);
748
748
}
756
756
  ~GenListDataModel4 () {}
757
757
 
758
758
  std::string getLabel (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part) const
759
 
  { 
 
759
  {
760
760
    GenListColumnConstructor3 *construct1 = static_cast <GenListColumnConstructor3*> (construction);
761
761
    cout << "GenListDataModel::getLabel" << endl;
762
762
 
763
763
    return "Item mode " + toString <int> (construct1->getTestItem ()->mode);
764
764
  }
765
 
    
 
765
 
766
766
  Elmxx::Object *getIcon (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part)
767
767
  {
768
768
    GenListColumnConstructor3 *construct1 = static_cast <GenListColumnConstructor3*> (construction);
769
769
    TestItem *tit = construct1->getTestItem ();
770
 
    
 
770
 
771
771
    if (part == "elm.swallow.icon")
772
772
    {
773
773
      Label *lb = Label::factory (obj);
774
774
 
775
 
      lb->setLineWrap (true);      
 
775
      lb->setLineWrap (true);
776
776
      lb->setWrapWidth (201);
777
777
      lb->setLabel ("ashj ascjscjh n asjkl hcjlh ls hzshnn zjh sh zxjcjsnd h dfw sdv edev efe fwefvv vsd cvs ws wf  fvwf wd fwe f  we wef we wfe rfwewef wfv wswf wefg sdfws w wsdcfwcf wsc vdv  sdsd sdcd cv wsc sdcv wsc d sdcdcsd sdcdsc wdvd sdcsd wscxcv wssvd sd");
778
778
      lb->show ();
782
782
    else if (part == "elm.swallow.end")
783
783
    {
784
784
      Check *ck = Check::factory (obj);
785
 
      
 
785
 
786
786
      ck->setEventsPropagate (false);
787
787
        ck->setState (tit->onoff);
788
788
      ck->getEventSignal ("changed")->connect (sigc::bind (sigc::ptr_fun (&my_gl_item_check_changed), tit));
810
810
  Window *win = Window::factory ("genlist-4", ELM_WIN_BASIC);
811
811
  win->setTitle ("GenList 4");
812
812
  win->setAutoDel (true);
813
 
  
 
813
 
814
814
  Background *bg = Background::factory (*win);
815
815
  win->addObjectResize (*bg);
816
816
  bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
817
817
  bg->show ();
818
 
  
 
818
 
819
819
  Box *bx = Box::factory (*win);
820
820
  bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
821
821
  win->addObjectResize (*bx);
827
827
  gl->show ();
828
828
 
829
829
  gl->signalSelect.connect (sigc::ptr_fun (&glSelected3));
830
 
  
 
830
 
831
831
  gl->setDataModel (model4);
832
832
 
833
833
  GenListColumnConstructor3 *construct1 = new GenListColumnConstructor3 ();
890
890
static void my_gl_item_check_changed2 (Evasxx::Object &obj, void *event_info, TestItem *tit)
891
891
{
892
892
  Check *check = static_cast <Check*> (&obj);
893
 
  
 
893
 
894
894
  tit->onoff = check->getState ();
895
895
  printf("item %p onoff = %i\n", tit, tit->onoff);
896
896
}
939
939
  ~GenListDataModel5 () {}
940
940
 
941
941
  std::string getLabel (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part) const
942
 
  { 
 
942
  {
943
943
    GenListColumnConstructor3 *construct1 = static_cast <GenListColumnConstructor3*> (construction);
944
944
    const TestItem *tit = construct1->getTestItem ();
945
945
    string buf;
946
 
    
 
946
 
947
947
    if (part == "elm.text")
948
948
    {
949
949
      buf = "Item mode " + toString <int> (tit->mode);
955
955
 
956
956
    return buf;
957
957
  }
958
 
    
 
958
 
959
959
  Elmxx::Object *getIcon (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part)
960
960
  {
961
961
    GenListColumnConstructor3 *construct1 = static_cast <GenListColumnConstructor3*> (construction);
962
962
    TestItem *tit = construct1->getTestItem ();
963
 
    
 
963
 
964
964
    if (part == "elm.swallow.icon")
965
965
    {
966
966
      Box *bx = Box::factory (obj);
978
978
    else if (part == "elm.swallow.end")
979
979
    {
980
980
      Check *ck = Check::factory (obj);
981
 
      
 
981
 
982
982
      ck->setEventsPropagate (false);
983
983
        ck->setState (tit->onoff);
984
984
      ck->getEventSignal ("changed")->connect (sigc::bind (sigc::ptr_fun (&my_gl_item_check_changed2), tit));
985
985
      ck->show ();
986
986
        return ck;
987
987
    }
988
 
    
 
988
 
989
989
    return NULL;
990
990
  }
991
991
 
1006
1006
  Window *win = Window::factory ("genlist-5", ELM_WIN_BASIC);
1007
1007
  win->setTitle ("GenList 5");
1008
1008
  win->setAutoDel (true);
1009
 
  
 
1009
 
1010
1010
  Background *bg = Background::factory (*win);
1011
1011
  win->addObjectResize (*bg);
1012
1012
  bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1013
1013
  bg->show ();
1014
 
  
 
1014
 
1015
1015
  Box *bx = Box::factory (*win);
1016
1016
  bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1017
1017
  win->addObjectResize (*bx);
1143
1143
  ~GenListDataModel6 () {}
1144
1144
 
1145
1145
  std::string getLabel (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part) const
1146
 
  { 
 
1146
  {
1147
1147
    GenListColumnConstructor1 *construct1 = static_cast <GenListColumnConstructor1*> (construction);
1148
 
            
 
1148
 
1149
1149
    return "Item mode " + toString <int> (construct1->getItemNum ());
1150
1150
  }
1151
 
    
 
1151
 
1152
1152
  Elmxx::Object *getIcon (GenListColumnConstructor *construction, Evasxx::Object &obj, const std::string &part)
1153
1153
  {
1154
1154
    GenListColumnConstructor1 *construct1 = static_cast <GenListColumnConstructor1*> (construction);
1155
 
    
 
1155
 
1156
1156
    if (part == "elm.swallow.icon")
1157
1157
    {
1158
1158
      Icon *ic = Icon::factory (obj);
1166
1166
    else if (part == "elm.swallow.end")
1167
1167
    {
1168
1168
      Check *ck = Check::factory (obj);
1169
 
      
 
1169
 
1170
1170
      ck->setEventsPropagate (false);
1171
1171
      ck->show ();
1172
1172
        return ck;
1173
1173
    }
1174
 
    
 
1174
 
1175
1175
    return NULL;
1176
1176
  }
1177
1177
 
1191
1191
  Window *win = Window::factory ("genlist-tree", ELM_WIN_BASIC);
1192
1192
  win->setTitle ("GenList Tree");
1193
1193
  win->setAutoDel (true);
1194
 
  
 
1194
 
1195
1195
  Background *bg = Background::factory (*win);
1196
1196
  win->addObjectResize (*bg);
1197
1197
  bg->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1198
1198
  bg->show ();
1199
 
  
 
1199
 
1200
1200
  Box *bx = Box::factory (*win);
1201
1201
  bx->setWeightHintSize (EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1202
1202
  win->addObjectResize (*bx);
1227
1227
  bt->getEventSignal ("contract,request")->connect (sigc::bind (sigc::ptr_fun (&gl4_con_req), gl));
1228
1228
  bt->getEventSignal ("expanded")->connect (sigc::bind (sigc::ptr_fun (&gl4_exp), gl));
1229
1229
  bt->getEventSignal ("contracted")->connect (sigc::bind (sigc::ptr_fun (&gl4_con), gl));
1230
 
  
 
1230
 
1231
1231
  bx->packEnd (*gl);
1232
1232
  bx->show ();
1233
1233
 
1263
1263
 
1264
1264
  bx->packEnd (*bx2);
1265
1265
  bx2->show ();
1266
 
  
 
1266
 
1267
1267
  win->resize (size320x320);
1268
1268
  win->show ();
1269
1269
}