#90235 - 2002-12-04 09:33 AM
KiXforms - PostPrep 0.9 (Preview)
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Hi all,
Here is my actual project (by now it just opens any Textfile in the first TextBox)
code:
;PostPrep 1.0
; KIXTART 4.12 (WKiX32) ; KIXFORMS build 37 ; AUTHOR Jochen Polster
break on
$ReqFormsBuild = 36 $Version = "1.0"
Global $SourceText[0]
$frm = createobject("Kixtart.Form")
if val($frm.Build) < $ReqFormsBuild $ = messagebox('This Script requires Kixforms build ' + $ReqFormsBuild,'Version check',4112) Quit() endif
$frm.Size = 640,480 $frm.Caption = "UBB Postprep " + $Version $frm.Icon = "SHELL32.dll;2" $frm.Center
$txtSource = $frm.TextBox $txtSource.Left = 5 $txtSource.Top = 5 $txtSource.Right = $frm.ClientWidth - 100 $txtSource.Bottom = $frm.ClientHeight / 2 - 3 $txtSource.ScrollBars = 3 $txtSource.FontName = "Courier New" $txtSource.FontSize = 8 $txtSource.MultiLine = 1
$rtfTarget = $frm.RichTextBox $rtfTarget.Left = 5 $rtfTarget.Top = 5 + $txtSource.Bottom $rtfTarget.Right = $frm.ClientWidth - 100 $rtfTarget.Bottom = $frm.ClientHeight - 5
$btnOpen = $frm.Button $btnOpen.Caption = "Open..." $btnOpen.Left = $rtfTarget.Right + 10 $btnOpen.Top = 5 $btnOpen.Width = 80 $btnOpen.Height = 25 $btnOpen.OnClick = "btnOpen_Click()"
$frm.Show while $frm.Visible $ = execute($frm.DoEvents) loop
function btnOpen_Click() dim $FileName, $nl $FileName = $frm.FileOpenDialog("Open", "", "", "", 0) if $FileName $ = open(1,$Filename,2) if not @error $frm.BeginUpdate redim $SourceText[0] $SourceText[0] = readline(1) $txtSource.Text = "" + $SourceText[0] while @error = 0 redim preserve $SourceText[ubound($SourceText)+1] $SourceText[ubound($SourceText)] = $nl $txtSource.Text = $txtSource.Text + @crlf + $SourceText[ubound($SourceText)] $nl = readline(1) loop $ = close(1) $frm.EndUpdate endif endif endfunction
To be implemented : -> Convert to html 'code' with preferred colors for Keywords -> Custom color choosable for different groups of words
Issues by now :
-> it adds an aditional crlf after the first line
J. [ 06. December 2002, 11:41: Message edited by: jpols ]
_________________________
|
Top
|
|
|
|
#90237 - 2002-12-04 02:18 PM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
Top
|
|
|
|
#90239 - 2002-12-04 04:46 PM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
j, if you go for keywords, i would like to have them too
then, html conversion is no big deal but headache can be found in special chars like: $convert=";","&","+","€","£","‚","ƒ","„","…","ˆ","‰","™","®","©","Ø"," ","°","±","²","³","´","µ","·","¸","¹","º","¼","½","¾","¿","ß","÷"
well, it depends though, checker must convert, but it actually cracks boards internal processing... if you check codeparser (posted somethink like month ago), there is all you need to convert.
mm... ofcourse you will then have the additional headache about your special code. [ 04. December 2002, 16:57: Message edited by: Lonkero ]
_________________________
!download KiXnet
|
Top
|
|
|
|
#90243 - 2002-12-05 09:20 AM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Nice little Town that is .. Stuttgart I mean
Ummm ... actually, to come back to topic I am in Color Hell !!!
Means that I want to incorporate a PictureBox filled with small Rectangles in different (increasing RGB) colors ....
All what I can get is a really interesting but useless graphics effect
Help ... please :
code:
break on
$frmDialog1 = createobject("Kixtart.Form") $frmDialog1.Size = 300,250 $frmDialog1.Caption = "Select Colors" $picChoice = $frmDialog1.PictureBox("",5,60,285,160) $picChoice.DrawWidth = 2 ;pixels $picChoice.FillStyle = 1 ; solid
$cR = &00 $cG = &00 $cB = &00 $c = cint($cR) + cint($cG) + cint($cB)
for $i = 0 to $picChoice.ClientWidth step 2 for $j = 0 to $picChoice.ClientHeight step 2 $picChoice.ForeColor = $c $picChoice.FillColor = $c $picChoice.Rectangle($i,$j,2,2) $cR = $cR + &01 $cG = $cG + &0001 $cB = $cB + &000001 $c = cint($cR) + cint($cG) + cint($cB) next next
$frmDialog1.Show while $frmDialog1.Visible $ = execute($frmDialog1.DoEvents) loop
btw. : afterwards it should be no problem to pick the Color with 'Point' [ 05. December 2002, 09:21: Message edited by: jpols ]
_________________________
|
Top
|
|
|
|
#90245 - 2002-12-05 10:28 AM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
the logic just is screwed up. couldn't get further than this with your script base:
code:
$frmDialog1 = createobject("Kixtart.Form") $frmDialog1.Size = 300,250 $frmDialog1.Caption = "Select Colors" $picChoice = $frmDialog1.PictureBox("",5,60,285,160) $picChoice.DrawWidth = 2 ;pixels $picChoice.FillStyle = 1 ; solid
$color = 0
for $i = 0 to $picChoice.ClientWidth step 2 for $j = 0 to $picChoice.ClientHeight step 2 $picChoice.forecolor=$color $picChoice.FillColor = $picChoice.ForeColor $picChoice.Rectangle($i,$j,2,2) $color=1506+$color next next
$frmDialog1.Show while $frmDialog1.Visible $ = execute($frmDialog1.DoEvents) loop
should it be re-written?
anyway, didn't test that your getting-better code yet so dunno.
and, btw, you don't need any break ons as there is only wkix code.
_________________________
!download KiXnet
|
Top
|
|
|
|
#90247 - 2002-12-05 11:40 AM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Lonkero
KiX Master Guru
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
heh, you must check out this ghaos theory:
code:
$frmDialog1 = createobject("Kixtart.Form") $frmDialog1.Size = 300,250 $frmDialog1.Caption = "Select Colors" $picChoice = $frmDialog1.PictureBox(,5,60,285,160) $picChoice.DrawWidth = 5 ;pixels $picChoice.FillStyle = 1 ; solid
for $r=0 to 255 step 20 for $g=0 to 255 step 20 for $b=0 to 255 step 20 $color=$color+""+$r+","+$g+","+$b+" " next next next $color=split($color) "Colors done" ?
get $
$counter=0 for $i = 0 to $picChoice.ClientWidth step 5 for $j = 0 to $picChoice.ClientHeight step 5 $picChoice.forecolor=split($color[$counter],",") $picChoice.Rectangle($i,$j,5,5) $counter=$counter+1 next next
$frmDialog1.Show while $frmDialog1.Visible $ = execute($frmDialog1.DoEvents) loop
_________________________
!download KiXnet
|
Top
|
|
|
|
#90248 - 2002-12-05 11:59 AM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Very messy !!!
Roflmao ...
Full story so far (without Wordfile.ini so you might want to comment the lines at the beginning from if exist($Wordfile) to its endif !)
code:
;PostPrep 1.0
; KIXTART 4.12 (WKiX32) ; KIXFORMS build 37 ; AUTHOR Jochen Polster
break on
$ReqFormsBuild = 36 $Version = "1.0" $Wordfile = @scriptdir + '\Wordfile.ini' $Kix = substr(@kix,1,4)
Global $SourceText[0],$Colors[6] $Sections = "Comments","Strings","Numbers","Commands","Functions","Macros","Operators"
;if exist($Wordfile) ; for $i = 0 to 6 ; $Colors[$i] = readprofilestring($Wordfile,$Sections[$i],"Color") ; next ; $Commands = split(readprofilestring($Wordfile,"Commands", "words"),',') ; $Functions = split(readprofilestring($Wordfile,"Functions","words"),',') ; $Macros = split(readprofilestring($Wordfile,"Macros", "words"),',') ; $Operators = split(readprofilestring($Wordfile,"Operators","words"),',') ; if not ubound($commands) ; or not ubound($functions) ; or not ubound($macros) ; or not ubound($Operators) ; or not ubound($Colors) ; $ = messagebox('This Script requires a wordfile ','Unexpected Error',4112) ; quit() ; endif ;else ; $ = messagebox('This Script requires a wordfile ','Unexpected Error',4112) ; quit() ;endif
$frm = createobject("Kixtart.Form")
if val($frm.Build) < $ReqFormsBuild $ = messagebox('This Script requires Kixforms build ' + $ReqFormsBuild,'Version check',4112) quit() endif
$frm.Size = 640,500 $frm.Caption = "UBB Postprep " + $Version $frm.Icon = "SHELL32.dll;2" $frm.Center
$lblPowered = $frm.Label("Powered by", $frm.ClientWidth-90,$frm.ClientHeight-100,90,20) $lblPowered.FontName = "Comic sans MS" $lblPowered.FontBold = 1 $lblPowered.FontSize = 10 $lblPowered.ForeColor = Kixtart
$lblBuild = $frm.Label("KiXtart " + $kix + @crlf + "and KiXforms" + @crlf + " build " + $frm.Build, $frm.ClientWidth-90,$frm.ClientHeight-80,90,60) $lblBuild.FontName = "Comic sans MS" $lblBuild.FontBold = 1 $lblBuild.FontSize = 7 $lblBuild.ForeColor = Kixtart
$txtSource = $frm.TextBox $txtSource.Left = 5 $txtSource.Top = 5 $txtSource.Right = $frm.ClientWidth - 100 $txtSource.Bottom = $frm.ClientHeight / 2 - 3 $txtSource.ScrollBars = 3 $txtSource.FontName = "Courier New" $txtSource.FontSize = 8 $txtSource.MultiLine = 1
$txtTarget = $frm.TextBox $txtTarget.Left = 5 $txtTarget.Top = 5 + $txtSource.Bottom $txtTarget.Right = $frm.ClientWidth - 100 $txtTarget.Bottom = $frm.ClientHeight - 20 $txtTarget.ScrollBars = 3 $txtTarget.FontName = "Courier New" $txtTarget.FontSize = 8 $txtTarget.MultiLine = 1
$lblStatus1 = $frm.Label("",5,$frm.ClientHeight-17,$frm.ClientWidth/3*2,15) $lblStatus1.BorderStyle = 5
$lblStatus2 = $frm.Label("",$lblStatus1.Right+3,$frm.ClientHeight-17,$frm.ClientWidth/3-10,15) $lblStatus2.BorderStyle = 5
$prg = $lblStatus2.ProgressBar $prg.Size = $frm.ClientWidth/3-10,13 $prg.Style = 1 $prg.BorderStyle = 0 $prg.Value = 0
$btnOpen = $frm.Button $btnOpen.Caption = "Open..." $btnOpen.Left = $txtTarget.Right + 10 $btnOpen.Top = 5 $btnOpen.Width = 80 $btnOpen.Height = 25 $btnOpen.BorderStyle = 5 $btnOpen.OnClick = "btnOpen_Click()"
$btnColor = $frm.Button $btnColor.Caption = "Set Colors..." $btnColor.Left = $txtTarget.Right + 10 $btnColor.Top = $btnOpen.Bottom + 2 $btnColor.Width = 80 $btnColor.Height = 25 $btnColor.BorderStyle = 5 $btnColor.OnClick = "btnColor_Click()"
$btnConvert = $frm.Button $btnConvert.Caption = "Convert" $btnConvert.Left = $txtTarget.Right + 10 $btnConvert.Top = $btnColor.Bottom + 2 $btnConvert.Width = 80 $btnConvert.Height = 25 $btnConvert.BorderStyle = 5 $btnConvert.OnClick = "btnConvert_Click()"
$frm.Show while $frm.Visible $ = execute($frm.DoEvents) loop
function btnOpen_Click() dim $FileName, $nl $FileName = $frm.FileOpenDialog("Open File ...", "", "", "KiX Files|*.kix;*.udf;*.k2k|All Files|*.*", 1) if $FileName $ = open(1,$Filename,2) if not @error dim $count $txtSource.Text = "" redim $SourceText[0] $count = 1 $frm.MousePointer = 11 $txtSource.BeginUpdate $SourceText[0] = readline(1) $txtSource.Text = "" + $SourceText[0] while @error = 0 redim preserve $SourceText[ubound($SourceText)+1] $SourceText[ubound($SourceText)] = $nl $txtSource.Text = $txtSource.Text + @crlf + $SourceText[ubound($SourceText)] $nl = readline(1) loop $ = close(1) $txtSource.EndUpdate $frm.MousePointer = 0 endif endif endfunction
function btnColor_Click() dim $frmDialog1, $cR, $cG, $cB, $c, $steps
$frmDialog1 = createobject("Kixtart.Form") $frmDialog1.Size = 300,254 $frmDialog1.Caption = "Set Colors"
$cboStrings = $frmDialog1.ComboBox $cboStrings.List = "Comments","Strings","Numbers","Commands","Functions","Macros","Operators" $cboStrings.Location = 5,5 $cboStrings.ListIndex = 0
$chkBold = $frmDialog1.CheckBox("Bold",5,30,50,15)
$picChoice = $frmDialog1.PictureBox("",8,60,279,160) $picChoice.DrawWidth = 2 ;pixels $picChoice.FillStyle = 1 ; solid $picChoice.BorderStyle = 0
$cR = &00 $cG = &00 $cB = &00 $c = $cR + $cG + $cB $Steps = 84
for $i = 4 to $picChoice.ClientHeight step 23 for $j = 4 to $picChoice.ClientWidth step 23 $picChoice.ForeColor = $c $picChoice.FillColor = $c $picChoice.Rectangle($j,$i,19,19) select case $i + $j < $steps / 3 $cR = $cR + ( 255 / 84 ) case $i + $j > $steps / 3 $cG = $cG + ( 255 / 84 ) case $i + $j > $steps / 3 * 2 $cB = $cB + ( 255 / 84 ) endselect $c = $cR + $cG + $cB next next
$frmDialog1.Show while $frmDialog1.Visible $ = execute($frmDialog1.DoEvents) loop endfunction
function btnConvert_Click() $txtTarget.BeginUpdate
$txtTarget.EndUpdate endfunction
[ 05. December 2002, 13:20: Message edited by: jpols ]
_________________________
|
Top
|
|
|
|
#90250 - 2002-12-05 03:03 PM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Are you, perhaps, trying to do this...
code:
break on cls $ComDlg = CreateObject("MSComDlg.CommonDialog") $ComDlg.ShowColor ? "Color selected " + $ComDlg.Color get $
Reference: Color Dialog Box
|
Top
|
|
|
|
#90252 - 2002-12-05 03:35 PM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
I agree. The Font Dialog could come in handy too, I'm sure.
|
Top
|
|
|
|
#90253 - 2002-12-05 03:46 PM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Thanx Chris for making me stumble over this !
In the mean time I get more closer results :
(But still the RGB business is try & error for me )
code:
break on dim $frmDialog1, $cR, $cG, $cB, $c, $steps, $h
$frmDialog1 = createobject("Kixtart.Form") $frmDialog1.Size = 300,244 $frmDialog1.Caption = "Set Colors"
$cboStrings = $frmDialog1.ComboBox $cboStrings.List = "Comments","Strings","Numbers","Commands","Functions","Macros","Operators" $cboStrings.Location = 5,5 $cboStrings.ListIndex = 0
$chkBold = $frmDialog1.CheckBox("Bold",120,9,50,15)
$btnClose = $frmDialog1.Button("Close",$frmDialog1.ClientWidth-89,5,80,25) $btnClose.OnClick = "$$frmDialog1.Hide" $btnClose.Cancel = 1
$picChoice = $frmDialog1.PictureBox("",8,50,279,160) $picChoice.DrawWidth = 2 ;pixels $picChoice.FillStyle = 1 ; solid $picChoice.BorderStyle = 0
$cR = 0 $cG = 0 $cB = 0 $Steps = 84
for $i = 4 to $picChoice.ClientHeight step 23 for $j = 4 to $picChoice.ClientWidth step 23 $c = "" + dectohex($cR) + dectohex($cG) + dectohex($cB) if len(dectohex($cR)) = 1 $c = "0" + $c endif if len(dectohex($cG)) = 1 $c = substr($c,1,2)+"0"+substr($c,3,len($c)) endif if len(dectohex($cB)) = 1 $c = substr($c,1,4)+"0"+substr($c,5,len($c)) endif $c ? $ = execute("$$picChoice.ForeColor = &$c") $ = execute("$$picChoice.FillColor = &$c") $picChoice.Rectangle($j,$i,19,19) select case $h < $Steps / 3 $cR = $cR + ( 255 / 28 ) case ($h > $Steps / 3) and ($h < $steps / 3 * 2) $cG = $cG + ( 255 / 28 ) case $h > $Steps / 3 * 2 $cB = $cB + ( 255 / 28 ) endselect $h = $h + 1 next next
;$frm.Enabled = 0 $frmDialog1.Show
while $frmDialog1.Visible $ = execute($frmDialog1.DoEvents) loop
_________________________
|
Top
|
|
|
|
#90254 - 2002-12-05 03:59 PM
Re: KiXforms - PostPrep 0.9 (Preview)
|
Chris S.
MM club member
Registered: 2002-03-18
Posts: 2368
Loc: Earth
|
Perhaps this will help you along a little more. Add these lines to your code...
code:
$picChoice.OnClick = "fnClickColor()" . . . Function fnClickColor() $picChoice.MouseX " " $picChoice.MouseY ? EndFunction
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 382 anonymous users online.
|
|
|