Mail Archives: djgpp/2001/03/18/20:46:40
This is a multi-part message in MIME format.
--------------050706040407010806050402
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
here is the source code for the offending module (as symify sees it)
the Class GLinearBitmap works fine, as I have debugged it to death.
--
***********************************************************
* Sahab Yazdani * "Wizard's Third Rule: Passion rules *
* Thornhill S.S * Reason" - Kolo's Journal *
***********************************************************
* http://pheonixsoft.virtualave.net/ *
***********************************************************
--------------050706040407010806050402
Content-Type: text/plain;
name="perslide.cc"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="perslide.cc"
// Homebase Version 1.0
// Graphical Percentage Bar Widget
// By: Sahab Yazdani
#include <stdlib.h>
#include <stdio.h>
#include "e:/djgpp/contrib/grfx2/h/linbitmp.h"
#include "perslide.h"
static int PercentageOf( int per, int max ) {
double temp;
int num;
temp = ((double)(per))/100;
temp = temp * ((double)(max)); // Get Percentage of...
num = ((int)(temp));
return num;
}
static int Percentage( int num, int max ) {
double temp;
temp = ((double)(num))/(double)((max));
temp = temp * 100;
return ((int)(temp));
}
PercentageSlider::PercentageSlider() {
draw=NULL;
backdrop=NULL;
range = GPoint( 0, 0 );
curPercent=0;
region = GRect( 0, 0, 0, 0 );
colourA = GRGB( 0, 0, 0 );
colourB = GRGB( 0, 0, 0 );
}
PercentageSlider::PercentageSlider( GRect region, GLinearBitmap *target, GRGB colourA, GRGB colourB, GPoint range ) {
PercentageSlider::region = region;
backdrop = new GLinearBitmap( region.length, region.width, target->GetBitDepth() );
backdrop->Clip( GPoint( region.x, region.y ), target );
draw = new GLinearBitmap( region.length, region.width, target->GetBitDepth() );
fprintf( stderr, "draw[oninit]: 0x%x\n", draw );
curPercent=0;
PercentageSlider::colourA = colourA;
PercentageSlider::colourB = colourB;
PercentageSlider::range = range;
}
PercentageSlider::~PercentageSlider() {
fprintf( stderr, "draw[ondestruct]: 0x%x\n", draw );
fprintf( stderr, "draw->virtualPtr: 0x%x\n", draw->GetVirtualPointer() );
if ( draw!=NULL ) delete draw;
if ( backdrop!=NULL ) delete backdrop;
}
GRGB PercentageSlider::CalcStep( int curPer, int totalStep ) {
long RDelta;
long GDelta;
long BDelta;
RDelta = colourB.red - colourA.red;
RDelta = (RDelta * curPer) / totalStep;
GDelta = colourB.green - colourA.green;
GDelta = (GDelta * curPer) / totalStep;
BDelta = colourB.blue - colourA.blue;
BDelta = (BDelta * curPer) / totalStep;
return GRGB( ( colourA.red + (unsigned char) RDelta ) ,
( colourA.green + (unsigned char) GDelta ),
( colourA.blue + (unsigned char) BDelta ) );
}
void PercentageSlider::UpdateBasedonMouse( GPoint location ) {
int relative;
relative = location.x - region.x; // Relative to box
SetPercentage( Percentage( relative, region.length ) );
}
void PercentageSlider::ChangeBackdrop( GLinearBitmap *target ) {
backdrop->Clip( GPoint( region.x, region.y ), target );
}
void PercentageSlider::Draw( GLinearBitmap *target ) {
backdrop->Draw( GPoint( 0, 0 ), draw );
for( int c=0;c<PercentageOf( curPercent, region.length );c++ )
draw->Line( GPoint( c, 0 ), GPoint( c, region.width-1 ), CalcStep( c, region.length ) );
draw->Draw( GPoint( region.x, region.y ), target );
}
--------------050706040407010806050402--
- Raw text -