/[hegemonie]/hegemonie/Resources/Theme/UiArrowTheme.m
ViewVC logotype

Diff of /hegemonie/Resources/Theme/UiArrowTheme.m

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by zaral, Thu Aug 28 19:10:17 2003 UTC revision 1.2 by dam, Mon Sep 8 14:03:47 2003 UTC
# Line 23  Line 23 
23    
24  #include <GL/gl.h>  #include <GL/gl.h>
25    
26    #include <Foundation/NSException.h>
27    
28  #include "Interface/UiArrow.h"  #include "Interface/UiArrow.h"
29    
30  #define BORDERSIZE 5  #define ARROW_SIZE 15.0f
 #define ARROW_SIZE 15  
31    
32  @interface UiArrow (Theme)  @interface UiArrow (Theme)
33    
# Line 39  Line 40 
40    
41  - (void) _displayRect: (NSRect)rect  - (void) _displayRect: (NSRect)rect
42  {  {
43    /* Tell the container to display his widgets */    NSPoint points[3];
   /* Sets the color to white */  
   glColor3f (1.0f, 1.0f, 1.0f);  
     
   /* enables stripple lines */  
   glEnable (GL_LINE_STIPPLE);  
     
   /* sets the line to be stippled to dash */  
   glLineStipple (1, 0xAAAA);  
     
   /* draw the border */  
44    NSRect rectangle = [self frame];    NSRect rectangle = [self frame];
45      GLfloat triangleBaseShift = NSHeight (rectangle) / 3.0f;
46      GLfloat triangleArrowShift = NSHeight (rectangle) / 6.0f;
47    
48    switch ([self orientation])    switch ([self orientation])
49      {      {
50      case UI_UP_ORIENTATION:      case UI_UP_ORIENTATION:
51          glBegin (GL_LINE_LOOP);        points[0] = NSMakePoint (0.0f, triangleBaseShift);
52          glVertex2f (0.0f, 0.0f);        points[1] = NSMakePoint (NSMidX (rectangle),
53          glVertex2f (NSMidX (rectangle), NSHeight (rectangle));                                 NSHeight (rectangle) - triangleArrowShift);
54          glVertex2f (NSWidth (rectangle), NSHeight (rectangle));        points[2] = NSMakePoint (NSWidth (rectangle), triangleBaseShift);
         glEnd ();  
55        break;        break;
56      case UI_LEFT_ORIENTATION:      case UI_LEFT_ORIENTATION:
57          glBegin (GL_LINE_LOOP);        points[0] = NSMakePoint (triangleArrowShift, NSMidY (rectangle));
58          glVertex2f (0.0f, NSMidY (rectangle));        points[1] = NSMakePoint (NSWidth (rectangle) - triangleBaseShift, 0.0f);
59          glVertex2f (NSWidth (rectangle), 0.0f);        points[2] = NSMakePoint (NSWidth (rectangle) - triangleBaseShift,
60          glVertex2f (NSWidth (rectangle), NSHeight (rectangle));                                 NSHeight (rectangle));
         glEnd ();  
61        break;        break;
62      case UI_DOWN_ORIENTATION:      case UI_DOWN_ORIENTATION:
63          glBegin (GL_LINE_LOOP);        points[0] = NSMakePoint (NSMidX (rectangle), triangleArrowShift);
64          glVertex2f (NSMidX (rectangle), 0.0f);        points[1] = NSMakePoint (0.0f, NSHeight (rectangle) - triangleBaseShift);
65          glVertex2f (NSWidth (rectangle), NSMidY (rectangle));        points[2] = NSMakePoint (NSWidth (rectangle),
66          glVertex2f (0.0f, NSHeight (rectangle));                                 NSHeight (rectangle) - triangleBaseShift);
         glEnd ();  
67        break;        break;
68      case UI_RIGHT_ORIENTATION:      case UI_RIGHT_ORIENTATION:
69          glBegin (GL_LINE_LOOP);        points[0] = NSMakePoint (triangleBaseShift, 0.0f);
70          glVertex2f (0.0f, 0.0f);        points[1] = NSMakePoint (triangleBaseShift, NSHeight (rectangle));
71          glVertex2f (0.0f, NSHeight (rectangle));        points[2] = NSMakePoint (NSWidth (rectangle) - triangleArrowShift,
72          glVertex2f (NSWidth (rectangle), NSMidY (rectangle));                                 NSMidY (rectangle));
73          glEnd ();        break;
74          
75        default:
76          NSAssert (YES, @"Unknown orientation");
77        break;        break;
78      }      }
79    
80    glDisable (GL_LINE_STIPPLE);    glBegin (GL_TRIANGLES);
81      glVertex2f ((GLfloat)points[0].x, (GLfloat)points[0].y);
82      glVertex2f ((GLfloat)points[1].x, (GLfloat)points[1].y);
83      glVertex2f ((GLfloat)points[2].x, (GLfloat)points[2].y);
84      glEnd ();
85  }  }
86    
87  - (void) sizeToFit  - (void) sizeToFit
88  {  {
89    [self setSize: NSMakeSize (15, 15)];    [self setSize: NSMakeSize (ARROW_SIZE, ARROW_SIZE)];
90  }  }
91    
92  @end  @end

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26