~ubuntu-branches/ubuntu/gutsy/audacity/gutsy-backports

« back to all changes in this revision

Viewing changes to src/widgets/Ruler.cpp

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-18 21:58:19 UTC
  • mfrom: (13.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080218215819-tmbcf1rx238r8gdv
Tags: 1.3.4-1.1ubuntu1~gutsy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
#include "../toolbars/ControlToolBar.h"
69
69
#include "../Theme.h"
70
70
#include "../AllThemeResources.h"
 
71
#include "../Experimental.h"
71
72
 
72
73
#define max(a,b)  ( (a<b)?b:a )
73
74
 
99
100
   mTop = -1;
100
101
   mRight = -1;
101
102
   mBottom = -1;
 
103
   mbTicksOnly = true;
 
104
   mbTicksAtExtremes = false;
 
105
   mTickColour = wxColour(153,153,153);
 
106
   mPen.SetColour(mTickColour);
102
107
 
103
108
   // Note: the font size is now adjusted automatically whenever
104
109
   // Invalidate is called on a horizontal Ruler, unless the user
647
652
         mMaxHeight = max(mMaxHeight, strH + 4);
648
653
      }
649
654
      else {
650
 
         strTop = mBottom - strH - 6;
 
655
         strTop = mBottom - strH -6;
651
656
         // Still leaves room for an umlaut or whatever above normal character
652
 
         strTop = mTop- mLead;
 
657
         strTop = mTop- mLead+4;// More space was needed...
653
658
         mMaxHeight = max(mMaxHeight, strH + 6);
654
659
      }
655
660
   }
920
925
 
921
926
void Ruler::Draw(wxDC& dc)
922
927
{
923
 
   Draw( dc, NULL, 0, 0 );
 
928
   Draw( dc, NULL, 0, 0);
924
929
}
925
930
 
926
931
void Ruler::Draw(wxDC& dc, Envelope *speedEnv, long minSpeed, long maxSpeed)
933
938
   if (!mValid)
934
939
      Update( speedEnv, minSpeed, maxSpeed );
935
940
 
 
941
#ifdef EXPERIMENTAL_THEMING
 
942
   mDC->SetPen(mPen);
 
943
   mDC->SetTextForeground(mTickColour);
 
944
#else
936
945
   mDC->SetPen(*wxBLACK_PEN);
937
946
   mDC->SetTextForeground(*wxBLACK);
 
947
#endif
938
948
 
939
 
   if (mOrientation == wxHORIZONTAL) {
940
 
      if (mFlip)
941
 
         mDC->DrawLine(mLeft, mTop, mRight+1, mTop);
942
 
      else
943
 
         mDC->DrawLine(mLeft, mBottom, mRight+1, mBottom);
944
 
   }
945
 
   else {
946
 
      if (mFlip)
947
 
         mDC->DrawLine(mLeft, mTop, mLeft, mBottom+1);
948
 
      else
949
 
         mDC->DrawLine(mRight, mTop, mRight, mBottom+1);
 
949
   // Draws a long line the length of the ruler.
 
950
   if( !mbTicksOnly )
 
951
   {
 
952
      if (mOrientation == wxHORIZONTAL) {
 
953
         if (mFlip)
 
954
            mDC->DrawLine(mLeft, mTop, mRight+1, mTop);
 
955
         else
 
956
            mDC->DrawLine(mLeft, mBottom, mRight+1, mBottom);
 
957
      }
 
958
      else {
 
959
         if (mFlip)
 
960
            mDC->DrawLine(mLeft, mTop, mLeft, mBottom+1);
 
961
         else
 
962
            mDC->DrawLine(mRight, mTop, mRight, mBottom+1);
 
963
      }
950
964
   }
951
965
 
952
966
   int i;
953
967
 
954
968
   mDC->SetFont(*mMajorFont);
955
969
 
 
970
   // We may want to not show the ticks at the extremes,
 
971
   // though still showing the labels.
 
972
   // This gives a better look when the ruler is on a bevelled
 
973
   // button, since otherwise the tick is drawn on the bevel.
 
974
   int iMaxPos = (mOrientation==wxHORIZONTAL)? mRight : mBottom-5;
 
975
 
956
976
   for(i=0; i<mNumMajor; i++) {
957
977
      int pos = mMajorLabels[i].pos;
958
978
 
959
 
      if (mOrientation == wxHORIZONTAL) {
960
 
         if (mFlip)
961
 
            mDC->DrawLine(mLeft + pos, mTop,
962
 
                          mLeft + pos, mTop + 4);
963
 
         else
964
 
            mDC->DrawLine(mLeft + pos, mBottom - 4,
965
 
                          mLeft + pos, mBottom);
966
 
      }
967
 
      else {
968
 
         if (mFlip)
969
 
            mDC->DrawLine(mLeft, mTop + pos,
970
 
                          mLeft + 4, mTop + pos);
971
 
         else
972
 
            mDC->DrawLine(mRight - 4, mTop + pos,
973
 
                          mRight, mTop + pos);
 
979
      if( mbTicksAtExtremes || ((pos!=0)&&(pos!=iMaxPos)))
 
980
      {
 
981
         if (mOrientation == wxHORIZONTAL) {
 
982
            if (mFlip)
 
983
               mDC->DrawLine(mLeft + pos, mTop,
 
984
                             mLeft + pos, mTop + 4);
 
985
            else
 
986
               mDC->DrawLine(mLeft + pos, mBottom - 4,
 
987
                             mLeft + pos, mBottom);
 
988
         }
 
989
         else {
 
990
            if (mFlip)
 
991
               mDC->DrawLine(mLeft, mTop + pos,
 
992
                             mLeft + 4, mTop + pos);
 
993
            else
 
994
               mDC->DrawLine(mRight - 4, mTop + pos,
 
995
                             mRight, mTop + pos);
 
996
         }
974
997
      }
975
998
 
976
999
      if (mMajorLabels[i].text != wxT(""))
984
1007
   for(i=0; i<mNumMinor; i++) {
985
1008
      int pos = mMinorLabels[i].pos;
986
1009
 
987
 
      if (mOrientation == wxHORIZONTAL) {
988
 
         if (mFlip)
989
 
            mDC->DrawLine(mLeft + pos, mTop,
990
 
                          mLeft + pos, mTop + 2);
991
 
         else
992
 
            mDC->DrawLine(mLeft + pos, mBottom - 2,
993
 
                          mLeft + pos, mBottom);
994
 
      }
995
 
      else {
996
 
         if (mFlip)
997
 
            mDC->DrawLine(mLeft, mTop + pos,
998
 
                          mLeft + 2, mTop + pos);
999
 
         else
1000
 
            mDC->DrawLine(mRight - 2, mTop + pos,
1001
 
                          mRight, mTop + pos);
 
1010
      if( mbTicksAtExtremes || ((pos!=0)&&(pos!=iMaxPos)))
 
1011
      {
 
1012
         if (mOrientation == wxHORIZONTAL) 
 
1013
         {
 
1014
            if (mFlip)
 
1015
               mDC->DrawLine(mLeft + pos, mTop,
 
1016
                             mLeft + pos, mTop + 2);
 
1017
            else
 
1018
               mDC->DrawLine(mLeft + pos, mBottom - 2,
 
1019
                             mLeft + pos, mBottom);
 
1020
         }
 
1021
         else 
 
1022
         {
 
1023
            if (mFlip)
 
1024
               mDC->DrawLine(mLeft, mTop + pos,
 
1025
                             mLeft + 2, mTop + pos);
 
1026
            else
 
1027
               mDC->DrawLine(mRight - 2, mTop + pos,
 
1028
                             mRight, mTop + pos);
 
1029
         }
1002
1030
      }
1003
1031
 
1004
1032
      if (mMinorLabels[i].text != wxT(""))
1216
1244
      SetCursor(wxCursor(wxCURSOR_HAND));
1217
1245
      
1218
1246
   double mouseTime = Pos2Time(evt.GetX());
 
1247
   if (mouseTime < 0.0) {
 
1248
      mouseTime = 0.0;
 
1249
   }
1219
1250
   
1220
1251
   if (evt.LeftDown())
1221
1252
   {
1336
1367
{
1337
1368
   double start, end;
1338
1369
   GetPlayRegion(&start, &end);
1339
 
   
 
1370
 
1340
1371
   if (start >= 0)
1341
1372
   {
1342
1373
      int x1 = Time2Pos(start) + 1;
1391
1422
void AdornedRulerPanel::DoDrawBorder(wxDC * dc)
1392
1423
{
1393
1424
   // Draw AdornedRulerPanel border
1394
 
   AColor::Medium( dc, false );
 
1425
   AColor::MediumTrackInfo( dc, false );
1395
1426
   dc->DrawRectangle( mInner );
1396
1427
 
1397
1428
   wxRect r = mOuter;
1398
1429
   r.width -= 1;                 // -1 for bevel
1399
1430
   r.height -= 2;                // -2 for bevel and for bottom line
1400
 
   AColor::Bevel( *dc, true, r );
 
1431
   AColor::BevelTrackInfo( *dc, true, r );
1401
1432
 
1402
1433
   dc->SetPen( *wxBLACK_PEN );
1403
1434
   dc->DrawLine( mOuter.x,
1410
1441
{
1411
1442
   double min = mViewInfo->h - mLeftOffset / mViewInfo->zoom;
1412
1443
   double max = min + mInner.width / mViewInfo->zoom;
1413
 
 
 
1444
   
 
1445
   ruler.SetTickColour( theTheme.Colour( clrTrackPanelText ) );
1414
1446
   ruler.SetRange( min, max );
1415
1447
   ruler.Draw( *dc );
1416
1448
}