Some fellows coders ask me (and request) about add support to the delphi 5 and delphi 6 IDEs. these versions was not originally supported by the Delphi IDE Theme Editor because these IDEs gives you a 16 fixed colors palette. So this causes limitations to manage the themes.
Check this image for the IDE editor options in Delphi 5 which shows the 16 colors available
the option to assign any color to the Highlight elements was added in the Delphi 7 version
The first thing I thought to manage the 16 palette colors was use specific themes with contains combinations of colors using these 16 colors. But quickly discarded this solution because would be necessary handle specific themes for specific versions of the delphi IDEs. So finally I decide convert the colors themes to the 16 color palette using some algorithm to find the closest color to the palette. the algorithm chosen was the Euclidean distance where closest color is determined by the distance between the two corresponding points in three-dimensional space. for example to find the distance of two colors (r1,g1,b1) and (r2,g2,b2) the formula look like this
Now the dephi implementation of the algorithm to find the “straight-line distance” or “nearest color” using the Euclidean distance:
const DelphiOldColorsCount =16; //this is the 16 colors palette used by delphi 5 and delphi 6 IDEs (BGR format) DelphiOldColorsList: array[0..DelphiOldColorsCount-1] of TColor = ( $000000,$000080,$008000,$008080, $800000,$800080,$808000,$C0C0C0, $808080,$0000FF,$00FF00,$00FFFF, $FF0000,$FF00FF,$FFFF00,$FFFFFF ) function GetIndexClosestColor(AColor:TColor) : Integer; var SqrDist,SmallSqrDist : Double; i,R1,G1,B1,R2,G2,B2 : Integer; begin Result:=0; //set the max distance possible SmallSqrDist := Sqrt(SQR(255)*3); //get the RGB components of the original color R1 := GetRValue(AColor); G1 := GetGValue(AColor); B1 := GetBValue(AColor); for i := 0 to DelphiOldColorsCount-1 do begin //get the RGB components of the palette color R2 := GetRValue(DelphiOldColorsList[i]); G2 := GetGValue(DelphiOldColorsList[i]); B2 := GetBValue(DelphiOldColorsList[i]); //calculate the euclidean distance SqrDist := Sqrt(SQR(R1 - R2) + SQR(G1 - G2) + SQR(B1 - B2)); if SqrDist < SmallSqrDist then begin Result := i; SmallSqrDist := SqrDist; end end end;
Applying the above function the results are
Aqua Theme Original (Delphi 7 and Above)
Aqua Theme Modified (Delphi 5 and Delphi 6)
NightFall Theme Original (Delphi 7 and Above)
NightFall Theme Modified (Delphi 5 and Delphi 6)
I think which the final result is acceptable (remember the palette is 16 colors only) . Now you can download the updated version of the Delphi IDE Theme Editor from here.