Advertisement
3_2004-2005 Complete Applications #148252

cEdit Version 5.1.4

cEdit is an OpenSource Code Editor. Originally it was written in Visual Basic, but has been ported to Borland Delphi 6 Personal Edition. This is one of the most complete editors on PSC I believe, and has a huge number of features available. It uses synedit to achieve the syntax highlighting, but this is only one portion of what cEdit can do. Unfortunatly the file size of the download is pretty large, running almost 15MB. Because of this I am unable to upload directly to psc so I've included a direct link to the source below off the sourceforge website. I emailed the psc owners asking them if possible to post the source for me. http://prdownloads.sourceforge.net/cedit/cEditSource.zip?download Please note the components for the app are all located in the components directory. Some of them are by me, others I can not claim credit for. Browse threw, most of them came with readme's so you can see who deserves credit where.

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Quellcode
original-source
Download source and components at:
http://prdownloads.sourceforge.net/cedit/cEditSource.zip?download
<?
// SETTINGS
$fontbase = $DOCUMENT_ROOT."/howto/php/dynafont/";
$rotateDegrees = 0;
$text = trim(stripslashes($_GET["text"]));
// SET FONT PROPERTIES
$font = $_GET["font"];
if (!$font) { $font = "arial.ttf"; }
$fontfile = $fontbase.$font;
$size = $_GET["size"];
if (!$size) { $size = 5; }
$textalign = $_GET["textalign"];
if (!$textalign) { $textalign = "left"; }
$color = $_GET["color"];
if (!$color) { $color = "000000"; }
//$foreground = GetRGBvalues("0x".$color, false);
$bgcolor = $_GET["bgcolor"];
if (!$bgcolor) { $bgcolor = "FFFFFF"; }
//$background = GetRGBvalues("0x".$bgcolor, false);
if($_GET["date"]) {
 $text = date($_GET["date"]);
}
$ImageSizeInfoArr = GetImageSizeForTextBlock($rotateDegrees, $text, $fontfile, $size);
// CREATE IMAGE
$im = imagecreate ($ImageSizeInfoArr["WIDTH"]+5, $ImageSizeInfoArr["HEIGHT"]);
$background = ImageColorAllocate ($im, hexdec(substr($bgcolor, 0, 2)), hexdec(substr($bgcolor, 2, 2)), hexdec(substr($bgcolor, 4, 2)));
$foreground = ImageColorAllocate ($im, hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2)));
ImageTTFText ($im, $size, 0, $ImageSizeInfoArr["X_POS"], $ImageSizeInfoArr["Y_POS"], $foreground, $fontfile, $text);
// SEND IMAGE TO BROWSER
Header ("Content-type: image/PNG");
ImagePNG ($im, "", 100);
ImageDestroy ($im);
?>
<?
// IMAGE SUPPORT FUNCTIONS
function GetImageSizeForTextBlock($rotateDegrees, $text, $fontLocation, $fontSize){
 ##-- This will add a small margin area around the text block.  --##
 ##-- The margin grows with the font size.   --##
 $margin = intval(0.25 * $fontSize);
 ##-- Convert the angle so it is always a number between 0 and 359 --##
 if($rotateDegrees > 359 || $rotateDegrees < -359){
  $rotateDegrees = intval($rotateDegrees % 360);
 }
 if($rotateDegrees < 0){
  $rotateDegrees = 360 + $rotateDegrees;
 }
 #-- Clean out all of the "new line" characters. --#
 #-- The following function expects the special code of "-br-" for line breaks. --#
 $text = preg_replace("/(\n|\r)/", "", $text);
 ##-- Get the total size of the text block so that we know how big to create the Image --##
 $TextBoxSize = ImageTTFBBox ($fontSize, $rotateDegrees, $fontLocation, preg_replace("/-br-/", "\n\r", $text));
 ##-- Put the variables into reader-friendly variables --##
 $TxtBx_Lwr_L_x = $TextBoxSize[0];
 $TxtBx_Lwr_L_y = $TextBoxSize[1];
 $TxtBx_Lwr_R_x = $TextBoxSize[2];
 $TxtBx_Lwr_R_y = $TextBoxSize[3];
 $TxtBx_Upr_R_x = $TextBoxSize[4];
 $TxtBx_Upr_R_y = $TextBoxSize[5];
 $TxtBx_Upr_L_x = $TextBoxSize[6];
 $TxtBx_Upr_L_y = $TextBoxSize[7];
 ##-- The Text Box coordinates are relative to the font, regardless of the angle   --##
 ##-- We need to figure out the height and width of the text box accounting for the rotation  --##
 if($rotateDegrees <= 90 || $rotateDegrees >= 270 ){
  $TextBox_width = max($TxtBx_Lwr_R_x, $TxtBx_Upr_R_x) - min($TxtBx_Lwr_L_x, $TxtBx_Upr_L_x);
  $TextBox_height = max($TxtBx_Lwr_L_y, $TxtBx_Lwr_R_y) - min($TxtBx_Upr_R_y, $TxtBx_Upr_L_y);
  ##-- This figures out where the coordinates of the first letter in the text block starts --##
  ##-- It is roughly the lower left-hand corner letter      --##
  $Start_Text_Coord_x = -(min($TxtBx_Upr_L_x, $TxtBx_Lwr_L_x));
  $Start_Text_Coord_y = -(min($TxtBx_Upr_R_y, $TxtBx_Upr_L_y));
 }
 else{
  $TextBox_width = max($TxtBx_Lwr_L_x, $TxtBx_Upr_L_x) - min($TxtBx_Lwr_R_x, $TxtBx_Upr_R_x);
  $TextBox_height = max($TxtBx_Upr_R_y, $TxtBx_Upr_L_y) - min($TxtBx_Lwr_L_y, $TxtBx_Lwr_R_y);
  $Start_Text_Coord_x = -(min($TxtBx_Lwr_R_x,$TxtBx_Upr_R_x));
  $Start_Text_Coord_y = -(min($TxtBx_Lwr_L_y, $TxtBx_Lwr_R_y));
 }
 ##-- We need to add our margin to the coordinates of the first letter --##
 $Start_Text_Coord_x += $margin;
 $Start_Text_Coord_y += $margin - 2; //Don't forget to account for the '0th' pixel at Y-coord 0
 ##-- We are going to make the image just big enough to hold our text block... accounting for the rotation and font size. --##
 ##-- We times the Margin by 2 so that there is a margin on all 4 sides  --##
 $TotalImageWidth = $TextBox_width + $margin *2;
 $TotalImageHeight = $TextBox_height + $margin *2;
 ##-- Send back a hash with our calculations --#
 return array("WIDTH"=>$TotalImageWidth, "HEIGHT"=>$TotalImageHeight, "X_POS"=>$Start_Text_Coord_x, "Y_POS"=>$Start_Text_Coord_y);
}
?>
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine