Mercurial > hg > octave-max
comparison src/DLD-FUNCTIONS/fltk_backend.cc @ 11207:51e6ac3e5afc
Code fixes for uimenu
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Mon, 08 Nov 2010 21:22:22 +0100 |
parents | a2437f70fe6c |
children | e0db3f9e9267 |
comparison
equal
deleted
inserted
replaced
11206:83d268af65cb | 11207:51e6ac3e5afc |
---|---|
338 | 338 |
339 Matrix pos = Matrix (uimenu_childs.numel (), 1); | 339 Matrix pos = Matrix (uimenu_childs.numel (), 1); |
340 | 340 |
341 for (octave_idx_type ii = 0; ii < uimenu_childs.numel (); ii++) | 341 for (octave_idx_type ii = 0; ii < uimenu_childs.numel (); ii++) |
342 { | 342 { |
343 graphics_handle kid = uimenu_childs (ii); | 343 graphics_object kidgo = gh_manager::get_object (uimenu_childs (ii)); |
344 | 344 |
345 if (gh_manager::is_handle_visible (kid)) | 345 if (kidgo.valid_object() && kidgo.isa ("uimenu")) |
346 { | 346 { |
347 graphics_object kidgo = gh_manager::get_object (kid); | 347 uimenu_childs(k) = uimenu_childs(ii); |
348 if (kidgo.isa ("uimenu")) | 348 pos(k++) = |
349 { | 349 dynamic_cast<uimenu::properties&> (kidgo.get_properties ()).get_position (); |
350 uimenu_childs(k) = uimenu_childs(ii); | |
351 pos(k++) = | |
352 dynamic_cast<uimenu::properties&> (kidgo.get_properties ()).get_position (); | |
353 std::string lbl = | |
354 dynamic_cast<uimenu::properties&> (kidgo.get_properties ()).get_fltk_label (); | |
355 } | |
356 } | 350 } |
357 } | 351 } |
358 | 352 |
359 uimenu_childs.resize (k, 1); | 353 uimenu_childs.resize (k, 1); |
360 pos.resize (k, 1); | 354 pos.resize (k, 1); |
366 retval(ii) = uimenu_childs (sidx(ii)); | 360 retval(ii) = uimenu_childs (sidx(ii)); |
367 | 361 |
368 return retval; | 362 return retval; |
369 } | 363 } |
370 | 364 |
371 void update_submenu (uimenu::properties& uimenup) | |
372 { | |
373 Matrix uimenu_ch = find_uimenu_children (uimenup); | |
374 | |
375 if (uimenu_ch.numel () > 0) | |
376 { | |
377 std::string fltk_label = uimenup.get_fltk_label (); | |
378 int idx = find_index_by_name (fltk_label.c_str ()); | |
379 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*>(&menubar->menu () [idx]); | |
380 menubar->mode(idx, item->flags|FL_SUBMENU); | |
381 } | |
382 } | |
383 | |
384 void delete_entry(uimenu::properties& uimenup) | 365 void delete_entry(uimenu::properties& uimenup) |
385 { | 366 { |
386 std::string fltk_label = uimenup.get_fltk_label (); | 367 std::string fltk_label = uimenup.get_fltk_label (); |
387 int idx = find_index_by_name (fltk_label.c_str ()); | 368 int idx = find_index_by_name (fltk_label.c_str ()); |
388 | 369 |
489 | 470 |
490 void add_entry (uimenu::properties& uimenup) | 471 void add_entry (uimenu::properties& uimenup) |
491 { | 472 { |
492 | 473 |
493 std::string fltk_label = uimenup.get_fltk_label (); | 474 std::string fltk_label = uimenup.get_fltk_label (); |
494 | 475 |
495 if (!fltk_label.empty ()) | 476 if (!fltk_label.empty ()) |
496 { | 477 { |
497 bool item_added = false; | 478 bool item_added = false; |
498 do | 479 do |
499 { | 480 { |
547 update_callback (uimenup); | 528 update_callback (uimenup); |
548 update_accelerator (uimenup); | 529 update_accelerator (uimenup); |
549 update_enable (uimenup); | 530 update_enable (uimenup); |
550 update_visible (uimenup); | 531 update_visible (uimenup); |
551 update_seperator (uimenup); | 532 update_seperator (uimenup); |
552 | 533 |
553 for (octave_idx_type ii = 0; ii < len; ii++) | 534 for (octave_idx_type ii = 0; ii < len; ii++) |
554 { | 535 { |
555 graphics_handle kid = kids (len - (ii + 1)); | 536 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1))); |
556 graphics_object kgo = gh_manager::get_object (kid); | |
557 uimenu::properties& kprop = dynamic_cast<uimenu::properties&>(kgo.get_properties ()); | |
558 if (kgo.valid_object ()) | 537 if (kgo.valid_object ()) |
559 add_to_menu (kprop); | 538 { |
539 uimenu::properties& kprop = dynamic_cast<uimenu::properties&>(kgo.get_properties ()); | |
540 add_to_menu (kprop); | |
541 } | |
560 } | 542 } |
561 | |
562 | |
563 } | 543 } |
564 | 544 |
565 void add_to_menu (figure::properties& figp) | 545 void add_to_menu (figure::properties& figp) |
566 { | 546 { |
567 Matrix kids = find_uimenu_children (figp); | 547 Matrix kids = find_uimenu_children (figp); |
568 int len = kids.length (); | 548 int len = kids.length (); |
569 menubar->clear (); | 549 menubar->clear (); |
570 for (octave_idx_type ii = 0; ii < len; ii++) | 550 for (octave_idx_type ii = 0; ii < len; ii++) |
571 { | 551 { |
572 graphics_handle kid = kids (len - (ii + 1)); | 552 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1))); |
573 graphics_object kgo = gh_manager::get_object (kid); | 553 |
574 uimenu::properties& kprop = dynamic_cast<uimenu::properties&>(kgo.get_properties ()); | |
575 if (kgo.valid_object ()) | 554 if (kgo.valid_object ()) |
576 add_to_menu (kprop); | 555 { |
556 uimenu::properties& kprop = dynamic_cast<uimenu::properties&>(kgo.get_properties ()); | |
557 add_to_menu (kprop); | |
558 } | |
577 } | 559 } |
578 } | 560 } |
579 | 561 |
580 template <class T_prop> | 562 template <class T_prop> |
581 void remove_from_menu (T_prop& prop) | 563 void remove_from_menu (T_prop& prop) |
585 kids = find_uimenu_children (prop); | 567 kids = find_uimenu_children (prop); |
586 int len = kids.length (); | 568 int len = kids.length (); |
587 | 569 |
588 for (octave_idx_type ii = 0; ii < len; ii++) | 570 for (octave_idx_type ii = 0; ii < len; ii++) |
589 { | 571 { |
590 graphics_handle kid = kids (len - (ii + 1)); | 572 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1))); |
591 graphics_object kgo = gh_manager::get_object (kid); | 573 |
592 uimenu::properties kprop = dynamic_cast<uimenu::properties&>(kgo.get_properties ()); | |
593 if (kgo.valid_object ()) | 574 if (kgo.valid_object ()) |
594 remove_from_menu (kprop); | 575 { |
576 uimenu::properties kprop = dynamic_cast<uimenu::properties&>(kgo.get_properties ()); | |
577 remove_from_menu (kprop); | |
578 } | |
595 } | 579 } |
596 | 580 |
597 if (type.compare("uimenu") == 0) | 581 if (type.compare("uimenu") == 0) |
598 delete_entry(dynamic_cast<uimenu::properties&>(prop)); | 582 delete_entry(dynamic_cast<uimenu::properties&>(prop)); |
599 else if (type.compare("figure") == 0) | 583 else if (type.compare("figure") == 0) |