Browse Source

Geschtrichelte Rahmen besser konfigurierbar

Kolja Strohm 5 years ago
parent
commit
4d53954dae
3 changed files with 83 additions and 51 deletions
  1. 69 49
      Rahmen.cpp
  2. 13 1
      Rahmen.h
  3. 1 1
      ToolTip.cpp

+ 69 - 49
Rahmen.cpp

@@ -30,9 +30,13 @@ void Rahmen::setRamenBreite( int br ) // setzt die Breite des Rahmens
 
 // wenn dieser Flag gesetzt wird, wird der Rahmen gestrichelt gezeichnet
 //  br: 1 -> gestrichelt, 0 -> durchgehend
-void Rahmen::setBreaks( bool br )
+void Rahmen::setBreaks( bool br, int brOff, int brLength, int lineLength )
 {
     breaks = br;
+    breakOffset = brOff;
+    breakLength = brLength;
+    this->lineLength = lineLength;
+    rend = 1;
 }
 
 void Rahmen::setAlpha( bool a ) // Legt fest, ob der Alphawert der Farbe berücksichtigt werden soll
@@ -68,6 +72,24 @@ bool Rahmen::hasBreaks() const
     return breaks;
 }
 
+// startpunkt des ersten linienabschnittes
+int Rahmen::getBreakOffset() const
+{
+    return breakOffset;
+}
+
+// länge einer lücke
+int Rahmen::getBreakLength() const
+{
+    return breakLength;
+}
+
+// länge einer linie
+int Rahmen::getLineLength() const
+{
+    return lineLength;
+}
+
 
 // Inhalt der LRahmen Klasse aus Rahmen.h
 // Konstruktor 
@@ -82,10 +104,12 @@ LRahmen::~LRahmen()
 void LRahmen::render( Bild &Obj ) // Zeichnet den Rahmen in das RenderZeichnung
 {
     Zeichnung::render( Obj );
-    int x = pos.x;
-    int y = pos.y;
-    int b = x + gr.x - 1;
-    int h = y + gr.y - 1;
+    int x = 0;
+    int y = 0;
+    int b = gr.x - 1;
+    int h = gr.y - 1;
+    if( !Obj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
+        return;
     if( !breaks )
     {
         if( alpha )
@@ -115,35 +139,32 @@ void LRahmen::render( Bild &Obj ) // Zeichnet den Rahmen in das RenderZeichnung
         {
             for( int i = 0; i < br; ++i )
             {
-                for( int x = pos.x; x < pos.x + gr.x; x += 20 )
-                {
-                    Obj.drawLinieHAlpha( x + i + 1, y + i, min( 10, gr.x - i * 2 - 1 + pos.x - x ), farbe );
-                    Obj.drawLinieHAlpha( x + i + 1, h - i, min( 10, gr.x - i * 2 - 1 + pos.x - x ), farbe );
-                }
-                for( int y = pos.y; y < pos.y + gr.y; y += 20 )
-                {
-                    Obj.drawLinieVAlpha( b - i, y + i + 1, min( 10, gr.y - i * 2 - 2 + pos.y - y ), farbe );
-                    Obj.drawLinieVAlpha( x + i, y + i, min( 10, gr.y - i * 2 + pos.y - y ), farbe );
-                }
+                for( int x = breakOffset; x < gr.x; x += lineLength + breakLength )
+                    Obj.drawLinieHAlpha( x + i + 1, y + i, lineLength - ( x + i + 1 + lineLength > gr.x - i - 1 ? gr.x - i - 1 - ( x + i + 1 + lineLength ) : 0 ), farbe );
+                for( int x = gr.x - breakOffset - lineLength; x >= 0; x -= lineLength + breakLength )
+                    Obj.drawLinieHAlpha( max( x + i + 1, i + 1 ), h - i, lineLength - ( x + i + 1 < i + 1 ? i + 1 - ( x + i + 1 ) : 0 ), farbe );
+                for( int y = breakOffset; y < gr.y; y += lineLength + breakLength )
+                    Obj.drawLinieVAlpha( b - i, y + i + 1, lineLength - ( y + i + 1 + lineLength > gr.y - i - 1 ? gr.y - i - 1 - ( y + i + 1 + lineLength ) : 0 ), farbe );
+                for( int y = gr.y - breakOffset - lineLength; y >= 0; y -= lineLength + breakLength )
+                    Obj.drawLinieVAlpha( x + i, max( y + i, i ), lineLength - ( y + i < i ? i - ( y + i ) : 0 ), farbe );
             }
         }
         else
         {
             for( int i = 0; i < br; ++i )
             {
-                for( int x = pos.x; x < pos.x + gr.x; x += 20 )
-                {
-                    Obj.drawLinieH( x + i + 1, y + i, min( 10, gr.x - i * 2 - 1 + pos.x - x ), farbe );
-                    Obj.drawLinieH( x + i + 1, h - i, min( 10, gr.x - i * 2 - 1 + pos.x - x ), farbe );
-                }
-                for( int y = pos.y; y < pos.y + gr.y; y += 20 )
-                {
-                    Obj.drawLinieV( b - i, y + i + 1, min( 10, gr.y - i * 2 - 2 + pos.y - y ), farbe );
-                    Obj.drawLinieV( x + i, y + i, min( 10, gr.y - i * 2 + pos.y - y ), farbe );
-                }
+                for( int x = breakOffset; x < gr.x; x += lineLength + breakLength )
+                    Obj.drawLinieH( x + i + 1, y + i, lineLength - ( x + i + 1 + lineLength > gr.x - i - 1 ? gr.x - i - 1 - ( x + i + 1 + lineLength ) : 0 ), farbe );
+                for( int x = gr.x - breakOffset - lineLength; x >= 0; x -= lineLength + breakLength )
+                    Obj.drawLinieH( max( x + i + 1, i + 1 ), h - i, lineLength - ( x + i + 1 < i + 1 ? i + 1 - ( x + i + 1 ) : 0 ), farbe );
+                for( int y = breakOffset; y < gr.y; y += lineLength + breakLength )
+                    Obj.drawLinieV( b - i, y + i + 1, lineLength - ( y + i + 1 + lineLength > gr.y - i - 1 ? gr.y - i - 1 - ( y + i + 1 + lineLength ) : 0 ), farbe );
+                for( int y = gr.y - breakOffset - lineLength; y >= 0; y -= lineLength + breakLength )
+                    Obj.drawLinieV( x + i, max( y + i, i ), lineLength - ( y + i < i ? i - ( y + i ) : 0 ), farbe );
             }
         }
     }
+    Obj.releaseDrawOptions();
 }
 
 Zeichnung *LRahmen::dublizieren() const // Kopiert das Zeichnung
@@ -182,11 +203,13 @@ Rahmen3D::~Rahmen3D()
 void Rahmen3D::render( Bild &Obj ) // Zeichnet den Rahmen in das RenderZeichnung
 {
     Zeichnung::render( Obj );
-    int x = pos.x;
-    int y = pos.y;
-    int b = x + gr.x - 1;
-    int h = y + gr.y - 1;
+    int x = 0;
+    int y = 0;
+    int b = gr.x - 1;
+    int h = gr.y - 1;
     int fcomp = ( farbe & 0xFF000000 ) | ( ~farbe & 0x00FFFFFF );
+    if( !Obj.setDrawOptions( pos.x, pos.y, gr.x, gr.y ) )
+        return;
     if( !breaks )
     {
         if( alpha )
@@ -216,35 +239,32 @@ void Rahmen3D::render( Bild &Obj ) // Zeichnet den Rahmen in das RenderZeichnung
         {
             for( int i = 0; i < br; ++i )
             {
-                for( int x = pos.x; x < pos.x + gr.x; x += 20 )
-                {
-                    Obj.drawLinieHAlpha( x + i + 1, y + i, min( 10, gr.x - i * 2 - 1 + pos.x - x ), farbe );
-                    Obj.drawLinieHAlpha( x + i + 1, h - i, min( 10, gr.x - i * 2 - 1 + pos.x - x ), fcomp );
-                }
-                for( int y = pos.y; y < pos.y + gr.y; y += 20 )
-                {
-                    Obj.drawLinieVAlpha( b - i, y + i + 1, min( 10, gr.y - i * 2 - 2 + pos.y - y ), farbe );
-                    Obj.drawLinieVAlpha( x + i, y + i, min( 10, gr.y - i * 2 + pos.y - y ), fcomp );
-                }
+                for( int x = breakOffset; x < gr.x; x += lineLength + breakLength )
+                    Obj.drawLinieHAlpha( x + i + 1, y + i, lineLength - ( x + i + 1 + lineLength > gr.x - i - 1 ? gr.x - i - 1 - ( x + i + 1 + lineLength ) : 0 ), farbe );
+                for( int x = gr.x - breakOffset - lineLength; x >= 0; x -= lineLength + breakLength )
+                    Obj.drawLinieHAlpha( max( x + i + 1, i + 1 ), h - i, lineLength - ( x + i + 1 < i + 1 ? i + 1 - ( x + i + 1 ) : 0 ), fcomp );
+                for( int y = breakOffset; y < gr.y; y += lineLength + breakLength )
+                    Obj.drawLinieVAlpha( b - i, y + i + 1, lineLength - ( y + i + 1 + lineLength > gr.y - i - 1 ? gr.y - i - 1 - ( y + i + 1 + lineLength ) : 0 ), farbe );
+                for( int y = gr.y - breakOffset - lineLength; y >= 0; y -= lineLength + breakLength )
+                    Obj.drawLinieVAlpha( x + i, max( y + i, i ), lineLength - ( y + i < i ?i - ( y + i ) : 0 ), fcomp );
             }
         }
         else
         {
             for( int i = 0; i < br; ++i )
             {
-                for( int x = pos.x; x < pos.x + gr.x; x += 20 )
-                {
-                    Obj.drawLinieH( x + i + 1, y + i, min( 10, gr.x - i * 2 - 1 + pos.x - x ), farbe );
-                    Obj.drawLinieH( x + i + 1, h - i, min( 10, gr.x - i * 2 - 1 + pos.x - x ), fcomp );
-                }
-                for( int y = pos.y; y < pos.y + gr.y; y += 20 )
-                {
-                    Obj.drawLinieV( b - i, y + i + 1, min( 10, gr.y - i * 2 - 2 + pos.y - y ), farbe );
-                    Obj.drawLinieV( x + i, y + i, min( 10, gr.y - i * 2 + pos.y - y ), fcomp );
-                }
+                for( int x = breakOffset; x < gr.x; x += lineLength + breakLength )
+                    Obj.drawLinieH( x + i + 1, y + i, lineLength - ( x + i + 1 + lineLength > gr.x - i - 1 ? gr.x - i - 1 - ( x + i + 1 + lineLength ) : 0 ), farbe );
+                for( int x = gr.x - breakOffset - lineLength; x >= 0; x -= lineLength + breakLength )
+                    Obj.drawLinieH( max( x + i + 1, i + 1 ), h - i, lineLength - ( x + i + 1 < i + 1 ? i + 1 - ( x + i + 1 ) : 0 ), fcomp );
+                for( int y = breakOffset; y < gr.y; y += lineLength + breakLength )
+                    Obj.drawLinieV( b - i, y + i + 1, lineLength - ( y + i + 1 + lineLength > gr.y - i - 1 ? gr.y - i - 1 - ( y + i + 1 + lineLength ) : 0 ), farbe );
+                for( int y = gr.y - breakOffset - lineLength; y >= 0; y -= lineLength + breakLength )
+                    Obj.drawLinieV( x + i, max( y + i, i ), lineLength - ( y + i < i ? i - ( y + i ) : 0 ), fcomp );
             }
         }
     }
+    Obj.releaseDrawOptions();
 }
 
 Zeichnung *Rahmen3D::dublizieren() const // Kopiert das Zeichnung

+ 13 - 1
Rahmen.h

@@ -14,6 +14,9 @@ namespace Framework
         int farbe;
         bool alpha;
         bool breaks;
+        int breakOffset;
+        int breakLength;
+        int lineLength;
 
     public:
         // Konstruktor 
@@ -25,7 +28,10 @@ namespace Framework
         __declspec( dllexport ) void setRamenBreite( int br );
         // wenn dieser Flag gesetzt wird, wird der Rahmen gestrichelt gezeichnet
         //  br: 1 -> gestrichelt, 0 -> durchgehend
-        __declspec( dllexport ) void setBreaks( bool br );
+        //  brOff: startpunkt des ersten linienabschnittes
+        //  brLength: länge einer lücke
+        //  lineLength: länge einer linie
+        __declspec( dllexport ) void setBreaks( bool br, int brOff = 0, int brLength = 10, int lineLength = 10 );
         // Gibt die Breite des Rahmens in Pixeln zurück
         __declspec( dllexport ) int getRBreite() const;
         // Legt fest, ob beim zeichnen alpha blending verwendet werden soll
@@ -40,6 +46,12 @@ namespace Framework
         __declspec( dllexport ) bool hatAlpha() const;
         // Gibt 1 zurück, falls der Rahmen gestrichelt gezeichnet wird
         __declspec( dllexport ) bool hasBreaks() const;
+        // startpunkt des ersten linienabschnittes
+        __declspec( dllexport ) int getBreakOffset() const;
+        // länge einer lücke
+        __declspec( dllexport ) int getBreakLength() const;
+        // länge einer linie
+        __declspec( dllexport ) int getLineLength() const;
     };
 
     // Eine Zeichnung des 2D GUI Frameworks, die einen Linienrahmen um ein Rechteck zeichnet

+ 1 - 1
ToolTip.cpp

@@ -169,7 +169,7 @@ void ToolTip::doMausEreignis( MausEreignis &me )
         z->doMausEreignis( me );
     me.mx += pos.x;
     me.my += pos.y;
-    if( mausIn2 )
+    if( mausIn2 && sichtbar )
         me.verarbeitet = 1;
     if( alpha )
         rend = 1;