~ubuntu-branches/ubuntu/raring/lmms/raring-proposed

« back to all changes in this revision

Viewing changes to plugins/zynaddsubfx/fltk/src/Fl_Group.cxx

  • Committer: Charlie Smotherman
  • Date: 2012-12-05 22:08:38 UTC
  • mfrom: (33.1.7 lmms_0.4.13)
  • Revision ID: cjsmo@cableone.net-20121205220838-09pjfzew9m5023hr
* New  Upstream release.
  - Minor tweaking to ZynAddSubFX, CALF, SWH plugins  and Stefan Fendt's RC
    filters.
  - Added UI fixes: Magnentic effect of knobs and Piano-roll fixes
  - Updated German localization and copyright year
* debian/lmms-common.install:
  - added /usr/share/applications so the lmms.desktop file will correctly
    install (LP: #863366)
  - This should also fix the Software Center not displaying lmms in sound
    and video (LP: #824231)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: Fl_Group.cxx 7469 2010-04-07 23:17:33Z matt $"
 
2
// "$Id: Fl_Group.cxx 8184 2011-01-04 18:28:01Z matt $"
3
3
//
4
4
// Group widget for the Fast Light Tool Kit (FLTK).
5
5
//
6
 
// Copyright 1998-2009 by Bill Spitzak and others.
 
6
// Copyright 1998-2010 by Bill Spitzak and others.
7
7
//
8
8
// This library is free software; you can redistribute it and/or
9
9
// modify it under the terms of the GNU Library General Public
89
89
Fl_Group *Fl_Group::current() {return current_;}
90
90
 
91
91
/**
92
 
  See static Fl_Group *Fl_Group::current() 
 
92
  Sets the current group.
 
93
  \see Fl_Group::current() 
93
94
*/
94
95
void Fl_Group::current(Fl_Group *g) {current_ = g;}
95
96
 
133
134
    break;
134
135
  case FL_Tab:
135
136
    if (!Fl::event_state(FL_SHIFT)) return FL_Right;
136
 
  case 0xfe20: // XK_ISO_Left_Tab
137
137
    return FL_Left;
138
138
  case FL_Right:
139
139
    return FL_Right;
387
387
  savedfocus_ = 0;
388
388
  resizable_ = this;
389
389
  init_sizes();
 
390
 
 
391
  // we must change the Fl::pushed() widget, if it is one of
 
392
  // the group's children. Otherwise fl_fix_focus() would send
 
393
  // lots of events to children that are about to be deleted
 
394
  // anyway.
 
395
 
 
396
  Fl_Widget *pushed = Fl::pushed();     // save pushed() widget
 
397
  if (contains(pushed)) pushed = this;  // set it to be the group, if it's a child
 
398
  Fl::pushed(this);                     // for fl_fix_focus etc.
 
399
 
390
400
  // okay, now it is safe to destroy the children:
391
 
  while (children_) {
392
 
    Fl_Widget* o = child(0);    // *first* child widget
393
 
    if (o->parent() == this) {  // should always be true
394
 
      remove(o);                // remove child widget first
395
 
      delete o;                 // then delete it
396
 
    } else {                    // this should never happen !
397
 
#ifdef DEBUG_CLEAR
398
 
      printf ("Fl_Group::clear() widget:%p, parent: %p != this (%p)\n",
399
 
              o, o->parent(), this); fflush(stdout);
400
 
#endif // DEBUG_CLEAR
401
 
      remove(o);                // remove it
402
 
    }
403
 
  }
 
401
 
 
402
#define REVERSE_CHILDREN
 
403
#ifdef  REVERSE_CHILDREN
 
404
  // Reverse the order of the children. Doing this and deleting
 
405
  // always the last child is much faster than the other way around.
 
406
  if (children_ > 1) {
 
407
    Fl_Widget *temp;
 
408
    Fl_Widget **a = (Fl_Widget**)array();
 
409
    for (int i=0,j=children_-1; i<children_/2; i++,j--) {
 
410
      temp = a[i];
 
411
      a[i] = a[j];
 
412
      a[j] = temp;
 
413
    }
 
414
  }
 
415
#endif // REVERSE_CHILDREN
 
416
 
 
417
  while (children_) {                   // delete all children
 
418
    int idx = children_-1;              // last child's index
 
419
    Fl_Widget* w = child(idx);          // last child widget
 
420
    if (w->parent()==this) {            // should always be true
 
421
      if (children_>2) {                // optimized removal
 
422
        w->parent_ = 0;                 // reset child's parent
 
423
        children_--;                    // update counter
 
424
      } else {                          // slow removal
 
425
        remove(idx);
 
426
      }
 
427
      delete w;                         // delete the child
 
428
    } else {                            // should never happen
 
429
      remove(idx);                      // remove it anyway
 
430
    }
 
431
  }
 
432
 
 
433
  if (pushed != this) Fl::pushed(pushed); // reset pushed() widget
 
434
 
404
435
}
405
436
 
406
437
/**
435
466
      if (index > n) index--;
436
467
      if (index == n) return;
437
468
    }
438
 
    g->remove(o);
 
469
    g->remove(n);
439
470
  }
440
471
  o.parent_ = this;
441
472
  if (children_ == 0) { // use array pointer to point at single child
463
494
void Fl_Group::add(Fl_Widget &o) {insert(o, children_);}
464
495
 
465
496
/**
466
 
  Removes a widget from the group but does not delete it.
 
497
  Removes the widget at \p index from the group but does not delete it.
467
498
 
468
 
  This method does nothing if the widget is not a child of the group.
 
499
  This method does nothing if \p index is out of bounds.
469
500
 
470
501
  This method differs from the clear() method in that it only affects
471
502
  a single widget and does not delete it from memory.
 
503
  
 
504
  \since FLTK 1.3.0
472
505
*/
473
 
void Fl_Group::remove(Fl_Widget &o) {
474
 
  if (!children_) return;
475
 
  int i = find(o);
476
 
  if (i >= children_) return;
 
506
void Fl_Group::remove(int index) {
 
507
  if (index < 0 || index >= children_) return;
 
508
  Fl_Widget &o = *child(index);
477
509
  if (&o == savedfocus_) savedfocus_ = 0;
478
510
  if (o.parent_ == this) {      // this should always be true
479
511
    o.parent_ = 0;
480
512
  } 
481
 
#ifdef DEBUG_REMOVE  
482
 
  else {                        // this should never happen !
483
 
    printf ("Fl_Group::remove(): widget %p, parent_ (%p) != this (%p)\n",
484
 
      &o, o.parent_, this);
485
 
  }
486
 
#endif // DEBUG_REMOVE
487
513
 
488
514
  // remove the widget from the group
489
515
 
490
516
  children_--;
491
517
  if (children_ == 1) { // go from 2 to 1 child
492
 
    Fl_Widget *t = array_[!i];
 
518
    Fl_Widget *t = array_[!index];
493
519
    free((void*)array_);
494
520
    array_ = (Fl_Widget**)t;
495
521
  } else if (children_ > 1) { // delete from array
496
 
    for (; i < children_; i++) array_[i] = array_[i+1];
 
522
    for (; index < children_; index++) array_[index] = array_[index+1];
497
523
  }
498
524
  init_sizes();
499
525
}
500
526
 
 
527
/**
 
528
  Removes a widget from the group but does not delete it.
 
529
 
 
530
  This method does nothing if the widget is not a child of the group.
 
531
 
 
532
  This method differs from the clear() method in that it only affects
 
533
  a single widget and does not delete it from memory.
 
534
  
 
535
  \note If you have the child's index anyway, use remove(int index)
 
536
  instead, because this doesn't need a child lookup in the group's
 
537
  table of children. This can be much faster, if there are lots of
 
538
  children.
 
539
*/
 
540
void Fl_Group::remove(Fl_Widget &o) {
 
541
  if (!children_) return;
 
542
  int i = find(o);
 
543
  if (i < children_) remove(i);
 
544
}
 
545
 
501
546
////////////////////////////////////////////////////////////////
502
547
 
503
548
// Rather lame kludge here, I need to detect windows and ignore the
600
645
 
601
646
  Fl_Widget::resize(X,Y,W,H); // make new xywh values visible for children
602
647
 
603
 
  if (!resizable() || dw==0 && dh==0 ) {
 
648
  if (!resizable() || (dw==0 && dh==0) ) {
604
649
 
605
650
    if (type() < FL_WINDOW) {
606
651
      Fl_Widget*const* a = array();
740
785
  // skip any labels that are inside the widget:
741
786
  if (!(widget.align()&15) || (widget.align() & FL_ALIGN_INSIDE)) return;
742
787
  // invent a box that is outside the widget:
743
 
  int a = widget.align();
 
788
  Fl_Align a = widget.align();
744
789
  int X = widget.x();
745
790
  int Y = widget.y();
746
791
  int W = widget.w();
747
792
  int H = widget.h();
 
793
  int wx, wy;
 
794
  if (const_cast<Fl_Group*>(this)->as_window()) {
 
795
    wx = wy = 0;
 
796
  } else {
 
797
    wx = x(); wy = y();
 
798
  }
748
799
  if ( (a & 0x0f) == FL_ALIGN_LEFT_TOP ) {
749
800
    a = (a &~0x0f ) | FL_ALIGN_TOP_RIGHT;
750
 
    X = x();
 
801
    X = wx;
751
802
    W = widget.x()-X-3;
752
803
  } else if ( (a & 0x0f) == FL_ALIGN_LEFT_BOTTOM ) {
753
804
    a = (a &~0x0f ) | FL_ALIGN_BOTTOM_RIGHT; 
754
 
    X = x();
 
805
    X = wx;
755
806
    W = widget.x()-X-3;
756
807
  } else if ( (a & 0x0f) == FL_ALIGN_RIGHT_TOP ) {
757
808
    a = (a &~0x0f ) | FL_ALIGN_TOP_LEFT; 
758
809
    X = X+W+3;
759
 
    W = x()+this->w()-X;
 
810
    W = wx+this->w()-X;
760
811
  } else if ( (a & 0x0f) == FL_ALIGN_RIGHT_BOTTOM ) {
761
812
    a = (a &~0x0f ) | FL_ALIGN_BOTTOM_LEFT; 
762
813
    X = X+W+3;
763
 
    W = x()+this->w()-X;
 
814
    W = wx+this->w()-X;
764
815
  } else if (a & FL_ALIGN_TOP) {
765
816
    a ^= (FL_ALIGN_BOTTOM|FL_ALIGN_TOP);
766
 
    Y = y();
 
817
    Y = wy;
767
818
    H = widget.y()-Y;
768
819
  } else if (a & FL_ALIGN_BOTTOM) {
769
820
    a ^= (FL_ALIGN_BOTTOM|FL_ALIGN_TOP);
770
821
    Y = Y+H;
771
 
    H = y()+h()-Y;
 
822
    H = wy+h()-Y;
772
823
  } else if (a & FL_ALIGN_LEFT) {
773
824
    a ^= (FL_ALIGN_LEFT|FL_ALIGN_RIGHT);
774
 
    X = x();
 
825
    X = wx;
775
826
    W = widget.x()-X-3;
776
827
  } else if (a & FL_ALIGN_RIGHT) {
777
828
    a ^= (FL_ALIGN_LEFT|FL_ALIGN_RIGHT);
778
829
    X = X+W+3;
779
 
    W = x()+this->w()-X;
 
830
    W = wx+this->w()-X;
780
831
  }
781
832
  widget.draw_label(X,Y,W,H,(Fl_Align)a);
782
833
}
783
834
 
784
835
//
785
 
// End of "$Id: Fl_Group.cxx 7469 2010-04-07 23:17:33Z matt $".
 
836
// End of "$Id: Fl_Group.cxx 8184 2011-01-04 18:28:01Z matt $".
786
837
//