Fossil

Diff
Login

Differences From Artifact [94cf682d56]:

To Artifact [f2eab6eddb]:


374
375
376
377
378
379
380
381

382
383
384
385
386
387
388
374
375
376
377
378
379
380

381
382
383
384
385
386
387
388







-
+







struct PClass {
  const char *zName;                     /* Name of class */
  char isLine;                           /* True if a line class */
  char eJust;                            /* Use box-style text justification */
  void (*xInit)(Pik*,PElem*);              /* Initializer */
  void (*xNumProp)(Pik*,PElem*,PToken*);   /* Value change notification */
  void (*xCheck)(Pik*,PElem*);             /* Checks to after parsing */
  PPoint (*xChop)(PElem*,PPoint*);         /* Chopper */
  PPoint (*xChop)(Pik*,PElem*,PPoint*);    /* Chopper */
  PPoint (*xOffset)(Pik*,PElem*,int);      /* Offset from .c to edge point */
  void (*xFit)(Pik*,PElem*,PNum w,PNum h); /* Size to fit text */
  void (*xRender)(Pik*,PElem*);            /* Render */
};


/* Forward declarations */
3584
3585
3586
3587
3588
3589
3590
3591

3592
3593
3594
3595
3596
3597
3598
3584
3585
3586
3587
3588
3589
3590

3591
3592
3593
3594
3595
3596
3597
3598







-
+







    case CP_S:   pt.x = 0.0;      pt.y = -h2;    break;
    case CP_SW:  pt.x = rx-w2;    pt.y = rx-h2;  break;
    case CP_W:   pt.x = -w2;      pt.y = 0.0;    break;
    case CP_NW:  pt.x = rx-w2;    pt.y = h2-rx;  break;
  }
  return pt;
}
static PPoint boxChop(PElem *pElem, PPoint *pPt){
static PPoint boxChop(Pik *p, PElem *pElem, PPoint *pPt){
  PNum dx, dy;
  int cp = CP_C;
  PPoint chop = pElem->ptAt;
  if( pElem->w<=0.0 ) return chop;
  if( pElem->h<=0.0 ) return chop;
  dx = (pPt->x - pElem->ptAt.x)*pElem->h/pElem->w;
  dy = (pPt->y - pElem->ptAt.y);
3617
3618
3619
3620
3621
3622
3623
3624

3625
3626
3627
3628
3629
3630
3631
3617
3618
3619
3620
3621
3622
3623

3624
3625
3626
3627
3628
3629
3630
3631







-
+







      cp = CP_W;
    }else if( dy>2.414*dx ){
      cp = CP_SW;
    }else{
      cp = CP_S;
    }
  }
  chop = pElem->type->xOffset(0,pElem,cp);
  chop = pElem->type->xOffset(p,pElem,cp);
  chop.x += pElem->ptAt.x;
  chop.y += pElem->ptAt.y;
  return chop;
}
static void boxFit(Pik *p, PElem *pElem, PNum w, PNum h){
  if( w>0 ) pElem->w = w;
  if( h>0 ) pElem->h = h;
3703
3704
3705
3706
3707
3708
3709
3710

3711
3712
3713
3714
3715
3716
3717
3703
3704
3705
3706
3707
3708
3709

3710
3711
3712
3713
3714
3715
3716
3717







-
+







      break;
    case T_HEIGHT:
      pElem->w = pElem->h;
      pElem->rad = 0.5*pElem->w;
      break;
  }
}
static PPoint circleChop(PElem *pElem, PPoint *pPt){
static PPoint circleChop(Pik *p, PElem *pElem, PPoint *pPt){
  PPoint chop;
  PNum dx = pPt->x - pElem->ptAt.x;
  PNum dy = pPt->y - pElem->ptAt.y;
  PNum dist = hypot(dx,dy);
  if( dist<pElem->rad ) return pElem->ptAt;
  chop.x = pElem->ptAt.x + dx*pElem->rad/dist;
  chop.y = pElem->ptAt.y + dy*pElem->rad/dist;
3828
3829
3830
3831
3832
3833
3834
3835

3836
3837
3838
3839
3840
3841
3842
3828
3829
3830
3831
3832
3833
3834

3835
3836
3837
3838
3839
3840
3841
3842







-
+









/* Methods for the "ellipse" class */
static void ellipseInit(Pik *p, PElem *pElem){
  pElem->w = pik_value(p, "ellipsewid",10,0);
  pElem->h = pik_value(p, "ellipseht",9,0);
}
static PPoint ellipseChop(PElem *pElem, PPoint *pPt){
static PPoint ellipseChop(Pik *p, PElem *pElem, PPoint *pPt){
  PPoint chop;
  PNum s, dq, dist;
  PNum dx = pPt->x - pElem->ptAt.x;
  PNum dy = pPt->y - pElem->ptAt.y;
  if( pElem->w<=0.0 ) return pElem->ptAt;
  if( pElem->h<=0.0 ) return pElem->ptAt;
  s = pElem->h/pElem->w;
5571
5572
5573
5574
5575
5576
5577
5578

5579
5580
5581
5582
5583
5584
5585
5571
5572
5573
5574
5575
5576
5577

5578
5579
5580
5581
5582
5583
5584
5585







-
+







  for(j=1, cnt=0; j<n-1; j++){
    if( (z[j] & 0xc0)==0xc0 ) continue;
    cnt++;
    if( z[j]=='\\' && z[j+1]!='&' ){
      j++;
    }else if( z[j]=='&' ){
      int k;
      for(k=j+1; k<j+7 && z[k]!=';'; k++){}
      for(k=j+1; k<j+7 && z[k]!=0 && z[k]!=';'; k++){}
      if( z[k]==';' ) j = k;
    }
  }
  return cnt;
}

/* Adjust the width, height, and/or radius of the object so that
6109
6110
6111
6112
6113
6114
6115
6116

6117
6118
6119
6120
6121
6122
6123
6109
6110
6111
6112
6113
6114
6115

6116
6117
6118
6119
6120
6121
6122
6123







-
+







** If point pTo is the exact enter of a choppable object,
** then adjust pTo by the appropriate amount in the direction
** of pFrom.
*/
static void pik_autochop(Pik *p, PPoint *pFrom, PPoint *pTo){
  PElem *pElem = pik_find_chopper(p->list, pTo);
  if( pElem ){
    *pTo = pElem->type->xChop(pElem, pFrom);
    *pTo = pElem->type->xChop(p, pElem, pFrom);
  }
}

/* This routine runs after all attributes have been received
** on an element.
*/
static void pik_after_adding_attributes(Pik *p, PElem *pElem){
6589
6590
6591
6592
6593
6594
6595
6596





6597
6598
6599
6600
6601
6602
6603
6589
6590
6591
6592
6593
6594
6595

6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607







-
+
+
+
+
+







    case ';':
    case '\n': {
      pToken->eType = T_EOL;
      return 1;
    }
    case '"': {
      for(i=1; (c = z[i])!=0; i++){
        if( c=='\\' ){ i++; continue; }
        if( c=='\\' ){ 
          if( z[i+1]==0 ) break;
          i++;
          continue;
        }
        if( c=='"' ){
          pToken->eType = T_STRING;
          return i+1;
        }
      }
      pToken->eType = T_ERROR;
      return i;
6716
6717
6718
6719
6720
6721
6722
6723

6724
6725
6726
6727
6728
6729
6730
6720
6721
6722
6723
6724
6725
6726

6727
6728
6729
6730
6731
6732
6733
6734







-
+







          if( pFound && (pFound->eEdge>0 ||
                         pFound->eType==T_EDGEPT ||
                         pFound->eType==T_START ||
                         pFound->eType==T_END )
          ){
            /* Dot followed by something that is a 2-D place value */
            pToken->eType = T_DOT_E;
          }else if( pFound->eType==T_X || pFound->eType==T_Y ){
          }else if( pFound && (pFound->eType==T_X || pFound->eType==T_Y) ){
            /* Dot followed by "x" or "y" */
            pToken->eType = T_DOT_XY;
          }else{
            /* Any other "dot" */
            pToken->eType = T_DOT_L;
          }
          return 1;
6743
6744
6745
6746
6747
6748
6749
6750

6751
6752
6753
6754
6755
6756
6757
6747
6748
6749
6750
6751
6752
6753

6754
6755
6756
6757
6758
6759
6760
6761







-
+







      if( (c>='0' && c<='9') || c=='.' ){
        int nDigit;
        int isInt = 1;
        if( c!='.' ){
          nDigit = 1;
          for(i=1; (c = z[i])>='0' && c<='9'; i++){ nDigit++; }
          if( i==1 && (c=='x' || c=='X') ){
            for(i=3; (c = z[i])!=0 && isxdigit(c); i++){}
            for(i=2; (c = z[i])!=0 && isxdigit(c); i++){}
            pToken->eType = T_NUMBER;
            return i;
          }
        }else{
          isInt = 0;
          nDigit = 0;
        }
6775
6776
6777
6778
6779
6780
6781
6782

6783
6784
6785
6786
6787
6788
6789
6779
6780
6781
6782
6783
6784
6785

6786
6787
6788
6789
6790
6791
6792
6793







-
+







            i -= 2;
          }else{
            i++;
            isInt = 0;
            while( (c = z[i])>=0 && c<='9' ){ i++; }
          }
        }
        c2 = z[i+1];
        c2 = c ? z[i+1] : 0;
        if( isInt ){
          if( (c=='t' && c2=='h')
           || (c=='r' && c2=='d')
           || (c=='n' && c2=='d')
           || (c=='s' && c2=='t')
          ){
            pToken->eType = T_NTH;
7049
7050
7051
7052
7053
7054
7055
7056

7053
7054
7055
7056
7057
7058
7059

7060







-
+
    }
  }
  printf("</body></html>\n");
  return 0; 
}
#endif /* PIKCHR_SHELL */

#line 7081 "pikchr.c"
#line 7085 "pikchr.c"