wtf GUI Frameworks... rant I guess

Everything else that doesn't fall into one of the other PB categories.
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: wtf GUI Frameworks... rant I guess

Post by TomS »

So.
First short example of RTML :mrgreen: : Rich Text Markup Language. (RTF - HTML)

Please let me know, if anybody is interested in further development.

I plan to add <b> <i> <u> <font=xyz> etc...
Right know the only command is <color=name> where a color with this name has to be added to the colortable using RTML_AddColor(name.s, color.i)
I chose <color=red> instead of just <red> because some lazy programmer would name his blue color just "b" and that would interfere with the planned bold-command <b>
Maybe I'll add a shortcut-tag for colors like {red} which would equal <color=red>, but would not interfere with any other commands, since these would use only < brackets >
Also in the future I plan to add any color without using a predefined color.
<color=$0000FF>, <color=#FF0000> would both equal red (first one is BGR like in PB and second one is RGB like in html) so PB users and other users who may write text scripts for an application don't need to adapt to the other in most cases unfamiliar color noting system.

Also planned is another command to add lines where one can use \n or other commands to create new lines without using another command or line.

Code: Select all

Structure structure_RTML_Colors
	name.s
	color.i
	colorID.i
EndStructure 

Define index_RTML_ColorID.i

NewList RTML_Colors.structure_RTML_Colors()

Procedure RTML_AddColor(name.s, color.i)
	
	Shared index_RTML_ColorID
	Shared RTML_Colors()
	
	ForEach RTML_Colors()
		If RTML_Colors()\name = name
			ProcedureReturn #False
		EndIf 
	Next
	
	AddElement(RTML_Colors())
	index_RTML_ColorID + 1
	RTML_Colors()\name = name
	RTML_Colors()\color = color
	RTML_Colors()\colorID = index_RTML_ColorID
	
	ProcedureReturn #True
	
EndProcedure 

Procedure RTML_ReplaceColor(name.s, color.i)

	Shared RTML_Colors()
	
	ForEach RTML_Colors()
		If RTML_Colors()\name = name
			RTML_Colors()\color = color
			ProcedureReturn #True
		EndIf 
	Next
	
	ProcedureReturn #False
	
EndProcedure 

Procedure.s RTML_Parse(input.s)
	
	input + "<color=black>" ;Add commands for standardstyle at the end of each line
	input + " " ;Add Space at the end of each line. Otherwise above commands won't work.
	
	Protected head.s,  foot.s 
	
	Shared RTML_Colors()
	
	;Sort Colors. Shouldn't be necessary if nothing is deleted. Thus commented out for speed.
	;SortStructuredList(RTML_Colors(), #PB_Sort_Ascending, OffsetOf(structure_RTML_Colors\colorID), #PB_Sort_Integer )
	
	head.s = "{\rtf {\colortbl;"
	ResetList(RTML_Colors())
	ForEach RTML_Colors()
		head + "\red"+Str(Red(RTML_Colors()\color))+""
		head + "\green"+Str(Green(RTML_Colors()\color))+""
		head + "\blue"+Str(Blue(RTML_Colors()\color))+";"
	Next
	head + "}{"
	
	foot.s = "}}"		
	
	ForEach RTML_Colors()
		input = ReplaceString(input, "<color=" + RTML_Colors()\name + ">", "\cf" + Str(RTML_Colors()\colorID) + " " )
	Next
	
	
	ProcedureReturn head + input + foot
	
EndProcedure 
  


;-
;-Programm start
;-OpenWindow etc...
OpenWindow(0, 0, 0, 400, 400, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
EditorGadget(0, 0, 0, 400, 400,  #PB_Editor_ReadOnly)


;-Add colors to color table
RTML_AddColor("black", 	$000000)	;Add colors at runtime
RTML_AddColor("red", 	$0000FF)
RTML_AddColor("green",	$009900)
RTML_AddColor("blue", 	$FF0000)
RTML_AddColor("orange",	$0099FF)

;-Add Lines to the editor gadget
AddGadgetItem(0, -1, RTML_Parse("<color=blue>Zelda: <color=black>Aren't you the boy from the <color=green>Forrest<color=black>?"))
AddGadgetItem(0, -1, RTML_Parse("<color=blue>Zelda: <color=black>This is <color=red>Ganondorf <color=black>, king of the <color=orange>Gerudos!"))

;-Replace some colors
RTML_ReplaceColor("red",	$000099)	;Replace Colors at runtime. 
RTML_ReplaceColor("blue",	$660000)	;e.g use a darker shade at night or if the player is in a dungeon...
RTML_ReplaceColor("orange",	$003399)

;-Add more lines to the gadget using the replaced colors
AddGadgetItem(0, -1, "Replace Colors at runtime. e.g use a darker shade at night or if the player is in a dungeon...")
AddGadgetItem(0, -1, RTML_Parse("<color=blue>Zelda: <color=black>This is <color=red>Ganondorf <color=black>, king of the <color=orange>Gerudos!"))

;-Mainloop
Repeat
   event = WaitWindowEvent(20)   
Until event = #PB_Event_CloseWindow
Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: wtf GUI Frameworks... rant I guess

Post by Zach »

You been busy!

Are you planning on making this a full blown Library / Include (Dll?) or something?

I guess it goes without saying I'm interested in what you're doing. I'm all for easy to use stuff :mrgreen:
Maybe I can throw a few dollars your way in the future if it turns into something really nice.
Image
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: wtf GUI Frameworks... rant I guess

Post by TomS »

Ok, then I'll put some more work into it.
It's an interesting topic, but I have currently no real use for it.
So there would have been no point in developing this into a lib if nobody's interested.

Yes, I plan to create an include for the purpose of adding formatted text for whatever use (text rpg, or a chat like Dingelings (abandoned) (that's where I got the idea of using RTF, btw) by Sirhc.ITI (Creator of simple OOP precompiler)).
Maybe if it turns out nicely one could use it in a callback for syntax highlighting like a mini scintilla.
Although the editorgadgets has some issues dealing with a certain amount of lines/chars...
But this is too far in the future to tell if I'll add something like that...

So I'm off to work on this little project now and hopefully you'll read from me in the Announcement-section in a few weeks or so ;)
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: wtf GUI Frameworks... rant I guess

Post by IdeasVacuum »

Looks very very interesting. I currently output RTF files and use MS Word or Abbi Word to display them (Open Office not so good for RTF). It would be nice to be able to display them in my app, which uses a pre-defined file that includes an image (logo).

I have been too busy (and too lazy) to learn Microsoft's XML, which would probably be a better solution than RTF since XML looks to be the RTF successor.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: wtf GUI Frameworks... rant I guess

Post by TomS »

But the editorgadget doesn't support the new xml-format.
To display an existing rtf-file, you just have to get its contents and use SetGadgetText() on the editor gadget. Then you just need to change the path of the image(s) and you're done.
Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: wtf GUI Frameworks... rant I guess

Post by Zach »

You were right.. the MSDN pages on the RTF spec are a pain in the ass to get anywhere with.. Although I kind of have a very basic feel, I'm currently googling around for tutorials on basic RTF syntax..

I'm actually gonna try and find a copy of "RTF Pocket Guide" by Sean M. Burke. He wrote some pretty interesting Perl tools as part of the book as well. Stuff like " rtf2rtf -- an RTF parser that dumps the parse tree as, yes, RTF! Very handy for debugging RTF."

lol.. But something slightly more interesting that caught my eye was " rtf2xml -- an RTF tokenizer that spits out an XML stream. "

The idea of using XML is certainly sparking ideas in my brain, but I wonder if it wouldn't seem redundant.. On the one hand, RTF is supposed to serve as a universal format for reading/writing text data between programs.. On the other hand, its a PITA to implement and using an XML based tag format would make this easier, and not much extra work since no matter what intermediary format is used to define things, its gonna need a parser for that format regardless..

But once the XML format is defined, and the parser is written, people would have all the info they need to implement support in their own programs and import/export the XML needed to share data between programs which want to use the Editor Gadget in the same way as we are discussing here..

Or maybe I am just off the wagon and having an over-complicated pipe dream... :mrgreen:


A couple of things I wanted to ask about, on a more serious note:

Line Position - I did a quick test to simulate a screen full of data that would require scrolling up/down. I copied and pasted one of the example text lines, so when the program starts the box is full and it needs to use the scrollbars. However it always starts at the top of the Editor box, and not at the line position where the last new text line was added... Was my method of testing just flawed, or does something else need to be done to ensure the Editor auto-scrolls with new lines?

Also... is there a #PB flag for turning on word-wrap? I couldn't find anything in the help so I'm wondering if I need to send a message via API to do that.

And lastly, but related to scrolling... I want to keep a small buffer of recent text printed to the Gadget, so the user can scroll back up to re-read something if they desire.. However I only want the buffer to be so large... a couple Megabytes (a couple hundred/thousand lines?).. I'm not sure how to implement that in this case.. I've only ever done this from scratch (Printing X lines from an Array to the screen, pushing out old lines as new ones are added).. Can that be done within the confines of an Editor Gadget?
Image
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: wtf GUI Frameworks... rant I guess

Post by TomS »

If you're going to use my RTML than you have to store your data in html, ofcourse ;)

The Editorgadget doesn't scroll on its own.
But it can be achieved with SetActiveGadget() after AddGAdgetItem()

Afaik there's no PB flag for wordwrap. I think you have to use API.

Your Buffer can be achieved with an internal counter and RemoveGadgetItem()

Example:

Code: Select all

#Buffer = 20

Procedure AddLine(gadget, text.s)
	Shared totalLines.i
	Protected buffer.i = #Buffer-1
	totalLines + 1
	If totalLines > buffer
		While totalLines > buffer
			RemoveGadgetItem(gadget,0)
			totalLines - 1
		Wend 
	EndIf 
	AddGadgetItem(gadget, -1, text)
	
	SetActiveGadget(gadget)
	
	
EndProcedure 


OpenWindow(0, 0, 0, 500, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

EditorGadget(0,0,0,400,200)
ButtonGadget(1,400,0,100,20,"Add Line")

Repeat
	event = WaitWindowEvent(20)
	Select event
		Case #PB_Event_Gadget
			If EventGadget()=1
				line + 1
				addline(0, Str(line))
			EndIf
	EndSelect 
	
	
Until event = #PB_Event_CloseWindow

Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: wtf GUI Frameworks... rant I guess

Post by Zach »

Thanks for the tips, I appreciate it!
Image
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: wtf GUI Frameworks... rant I guess

Post by Shardik »

Zach wrote:Also... is there a #PB flag for turning on word-wrap? I couldn't find anything in the help so I'm wondering if I need to send a message via API to do that.
I already proposed a new flag #PB_Editor_WordWrap in Feature Requests and Wishlists and also presented a crossplatform code example.
Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: wtf GUI Frameworks... rant I guess

Post by Zach »

Nice.. didn't notice you had done that before. Hope they decide to implement it.

Heck, I hope they finally get around to giving us bindings for GTK+ on Windows as well.. If not for the fact I'd have to write a bunch of prototypes and deal with the usual pointer mess, I'd probably be using GTK+ right now since looking through its docs reveals it has a multi-color/font Text Widget available :(

Would instantly resolve cross-platform issues...
Image
Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: wtf GUI Frameworks... rant I guess

Post by Zach »

Hi,

Well my work has been slow as I have been sick for the past 3 weeks but aside from some chest congestion I am doing a lot better (hope it stays that way).
So I started using the "RTML" code (it's really great!) from TomS, at the top of page 2, as a guide for writing my own routine from scratch.

I have a question about the most efficient way to process tags, however.. Due to the way it works currently, using the ReplaceString() command, it seems like you would have to do several passes to cover several different flag types.. i.e one pass for Color changes, another for Font changes, and a third for styling (bold, italics, etc). Is that correct?

I can't think of a way to use ReplaceString() in a single pass, to cover various keywords that are not the same type. When I had a similar thread going for this subject on the DarkBasic Forums, I ended up with a routine that would process each input string 1 character at a time, rebuilding the string without the tags, and with the color changes, as it went along.

Would there be a huge performance difference between these two methods? (1 to 3 ReplaceString() passes vs one pass, processing each character and branching off for all discovered tags to do the work needed). If we're talking a few milliseconds then I'd just stick with the ReplaceString() method as its faster to implement, but I don't want to end up slowing the CPU down and taking power away from other important tasks (like A.I, and other calculations going on in the background).

Another general question I was wondering about is about my RTF header generation. Because of the way RTF and the PB EditorGadget works, plus my own requirements for the Text Box to be scrollable with a finite History, the best way to get RTF formatted text into the EditorGadget is by using AddGadgetItem(), which requires each string sent to contain a full RTF header with the table definitions for any colors/fonts I will be using.

This could mean a rather large header with around 20 color definitions, as well as 2 or 3 Font definitions, and it would have to be sent each and every time a line is added to the EditorGadget.. Is there any potential for performance problems related to this?? Personally I would rather send a custom built header with only the colors/fonts I am using but that is a lot of work to code it to be dynamic, at least I think so? Since the color and font tables are assigned ID's in the order they are added, it seems like you'd have to do some convoluted list building / rebuilding on the fly each and every line you send, since the formatting tags have to be constant and can't be changed willy nilly. At the very least, it would involve building a new list from the master list, wasting precious time and memory.

Right now I am going on the assumption that multiple parser passes, and a large RTF header for each, won't really put much of a dent in things. But I thought I would get other opinions before it really becomes a pain to rip the system apart and make code changes.
Image
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: wtf GUI Frameworks... rant I guess

Post by TomS »

I'm working on a colortable creation process that lists only the colors that are used in that line for a header as small as it gets. The header had to be build after parsing the content. But that's not a problem. Reading from the masterlist would not cost extra memory. In case you decide to use $BBGGRR (which is not implemented yet) you wouldn't even need to add colors to the list.
But if I implement hardcoded colors it's necessary to build the header on the fly anyway.

As for ReplaceString. It's right that there are many passes. Two for each command (because you have to replace the end-tag), too. But since you're using it to display text and not to generate several 100.000 lines RTF-Files in the background this should not be a big problem.
But it is possible to create a function for a single pass replacement.

Code: Select all

Macro command_on(command, __output)
	Case command
						If *plus_two\c = '>'
							output + __output
							*ptrInput + (2 * SizeOf(CHARACTER))
						EndIf
EndMacro 

Macro command_off(command, __output)
	If *plus_two\c = command And *plus_three\c = '>'
							output + __output
							*ptrInput + (3 * SizeOf(CHARACTER))
						EndIf 
EndMacro 

Procedure.s SinglePassReplace(sInput.s)
	Protected *ptrInput.CHARACTER = @ sInput
	Protected *plus_one.CHARACTER 
	Protected *plus_two.CHARACTER 
	Protected *plus_three.CHARACTER 
	Protected output.s
	
	
	
	
	
	While (Not (*ptrInput\c = #Null))
		*plus_one 	= *ptrInput + SizeOf (CHARACTER)
		*plus_two 	= *plus_one + SizeOf (CHARACTER)
		*plus_three = *plus_two + SizeOf (CHARACTER)
		
		
		
		
		Select *ptrInput\c
			Case '<'
				Select *plus_one\c 
					command_on(Asc("i"), "\i ")	
					command_on(Asc("u"), "\ul ")	
					command_on(Asc("b"), "\b ")	
							
					Case '/'
						
						command_off(Asc("i"), "\i0 ")
						command_off(Asc("b"), "\b0 ")
						command_off(Asc("u"), "\ul0 ")
						
				EndSelect 
				
				
				
			Default
				output + Chr( *ptrInput\c )
		EndSelect 
		*ptrInput + SizeOf (CHARACTER)
	Wend
	
	ProcedureReturn "{\rtf {" + output + ";}}"
EndProcedure 


OpenWindow(0, 0, 0, 800, 600, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
EditorGadget(0, 0, 0,800, 600)


AddGadgetItem(0, -1, SinglePassReplace("<b>bold</b>"))
AddGadgetItem(0, -1, SinglePassReplace("<i>italic</i>"))
AddGadgetItem(0, -1, SinglePassReplace("<u>underlined</u>"))


Repeat : Until WaitWindowEvent(20) = #PB_Event_CloseWindow
No colors yet. Just a quick demo.
It's more complicated to implement commands that are longer (like color) with this method than just using ReplaceString() ofcourse. But it's quite possible.
Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: wtf GUI Frameworks... rant I guess

Post by Zach »

I am using $BBGGRR - did you mean its not implemented in your latest version? I thought it was used in your previous example (the one I am working off)?? PB's documentation states that when you list colors in Hex you have to swap the R & B fields, so that is what I have been doing...?

i.e instead of $0000FF for Blue, using $FF0000.

I was thinking of just using RGB values to define the colors, since that is what RTF takes in its table format anyway, but.... now I'm confused :|


re: Single pass.. Based on what you've said I'll probably just stick with ReplaceString() as you used it.. Much easier on my brain I'm sure. And not thrilled any time pointers are involved, personally :mrgreen:

Will be waiting to see what your Header generation looks like when you've completed it 8)
I'm also thinking about implementing support for "Profiles" of some kind, so you can define custom color themes.. I was thinking instead of referring to colors by their name, I'd just refer to them by number, and use a visual reference of the current Number->Color mapping in my world building application. That way you can store color profiles in external files, and all you need to do to change a color is change its value, and that way you don't have to comb through your world files changing the color name everywhere it occurs, since the new value will match to the Integer ID in the tag instead of a color name..

But I haven't decided on doing it or not, yet.. just an idea.
Image
User avatar
TomS
Enthusiast
Enthusiast
Posts: 342
Joined: Sun Mar 18, 2007 2:26 pm
Location: Munich, Germany

Re: wtf GUI Frameworks... rant I guess

Post by TomS »

Zach wrote:I thought it was used in your previous example
No. I mean instead of

Code: Select all

RTML_AddColor("name", color.i)
RTML_Parse("<color=name>colored text</color>")
Something like this will be possible in the future.

Code: Select all

RTML_Parse("<color=$0000FF>red text</color>")
So that you can use any color even if you dit not add it explicitly with AddColor().
It doesn't matter if you use RGB or BGR. It's a string and you have to parse it anyway. I was thinking $0000FF = blue (like in PB) but the same color is also #FF0000 (like in html).
Note: The "profile" idea below doesn't work if you put color values directly in the code.

I don't know about numbers as a reference. I'm all for human readable code. If I wanted cryptic code I would just use RTF instead of a nice clean xml-like format.
You don't need to use blue, red and green as IDs but you can also use player_saying, cpn_good_saying, cpn_neutral_saying, cpn_enemy_saying, etc...
Also you can create profiles.
See my first demo for on-the-fly color change.

You could use ini-files as profiles and just patch the colors with RTML_ReplaceColor()

Code: Select all

;Define standardcolors
AddColor("player_saying", $009900) ;greenish
AddColor("cpn_standard", $999999) ;gray
;Those colors could also come from a preferencefile in the first place (instead of hardcoding)

;If an alternative profile is selected:
ReplaceColor("player_saying", ReadPreferenceLong("player_saying"))
;...




EDIT:

Here's the latest version of RTML. It features italic, bold underline and strikethrough styles.
Also you can use </color> to go back to the standard color (black)

Ignore the second Editorgadget. It's just for Debugging the rtf code.
Not so clean (wip^^) but works ;)

Code: Select all

Structure structure_RTML_Colors
	name.s
	color.i
	colorID.i
EndStructure 

Define index_RTML_ColorID.i = 1

Global NewList RTML_Colors.structure_RTML_Colors()

Procedure.s __RemoveSpacesInCommands(string.s)
	Protected start.i = 1
	Protected temp.s
	
	While start > 0		
		start = FindString(string, "<", start + 1)		
		endTagPos = FindString(string, ">", start)		
		
		If start>0			
			temp = ReplaceString(Mid(string, start, endTagPos - start) , " ", "",  #PB_String_NoCase)
			string = ReplaceString(string, Mid(string, start, endTagPos - start), temp )
		EndIf 
		
	Wend 
	
	ProcedureReturn string
EndProcedure 



Procedure RTML_AddColor(name.s, color.i)
	
	Shared index_RTML_ColorID
	Shared RTML_Colors()
	
	ForEach RTML_Colors()
		If RTML_Colors()\name = name
			ProcedureReturn #False
		EndIf 
	Next
	
	AddElement(RTML_Colors())
	index_RTML_ColorID + 1
	RTML_Colors()\name = name
	RTML_Colors()\color = color
	RTML_Colors()\colorID = index_RTML_ColorID
	
	ProcedureReturn #True
	
EndProcedure 

Procedure RTML_ReplaceColor(name.s, color.i)

	Shared RTML_Colors()
	
	ForEach RTML_Colors()
		If RTML_Colors()\name = name
			RTML_Colors()\color = color
			ProcedureReturn #True
		EndIf 
	Next
	
	ProcedureReturn #False
	
EndProcedure 

Procedure.s RTML_Parse(input.s, header = 1)
	Protected head.s,  foot.s, colorName.s
	
	Shared RTML_Colors()
	
	;Sort Colors. Shouldn't be necessary if nothing is deleted. Thus commented out for speed.
	;SortStructuredList(RTML_Colors(), #PB_Sort_Ascending, OffsetOf(structure_RTML_Colors\colorID), #PB_Sort_Integer )
	
	If header = 0
		head.s = "{/rtf {\colortbl;\red0\green0\blue0;"
	Else 
		head.s = "{\rtf {\colortbl;\red0\green0\blue0;"
	EndIf 
	
	
		Protected start.i
	Protected extract.s 
	
	input = __RemoveSpacesInCommands(input)

	
	start = 1
	While start > 0
		
		start = FindString(input, "<color=", start + 1)
		
		endTagPos = FindString(input, ">", start)
		
		
		If start>0
			extract$ = Mid(input, start, endTagPos - start)
			colorName = ReplaceString(extract$, "<color=", "",  #PB_String_NoCase)
			ResetList(RTML_Colors())
			ForEach RTML_Colors()
				;If RTML_Colors()\name = colorName
					head + "\red"+Str(Red(RTML_Colors()\color))+""
					head + "\green"+Str(Green(RTML_Colors()\color))+""
					head + "\blue"+Str(Blue(RTML_Colors()\color))+";"
					;input = ReplaceString(input, extract$ + ">", "\cf" + Str(RTML_Colors()\colorID) + " " )
				;EndIf 
				Next
		EndIf 
	Wend 
	
	
	
	
	
	
	
	
	
	
	
	
	
	head + "}{\cf1 "
	
	foot.s = "}}"		
	
	ForEach RTML_Colors()
		input = ReplaceString(input, "<color=" + RTML_Colors()\name + ">", "\cf" + Str(RTML_Colors()\colorID) + " " )
	Next
	
	input = ReplaceString(input, "</color>", "\cf1  ", #PB_String_NoCase)
	
	input = ReplaceString(input, "<b>", "\b ", #PB_String_NoCase)
	input = ReplaceString(input, "</b>", "\b0 ", #PB_String_NoCase)
	
	input = ReplaceString(input, "<i>", "\i ", #PB_String_NoCase)
	input = ReplaceString(input, "</i>", "\i0 ", #PB_String_NoCase)
	
	input = ReplaceString(input, "<s>", "\strike ", #PB_String_NoCase)
	input = ReplaceString(input, "</s>", "\strike0 ", #PB_String_NoCase)
	
	input = ReplaceString(input, "<u>", "\ul ", #PB_String_NoCase)
	input = ReplaceString(input, "</u>", "\ul0 ", #PB_String_NoCase)
	
	

	ProcedureReturn head + input + foot
	
EndProcedure 


Macro AddLine(text)
	AddGadgetItem(0, -1, RTML_Parse(text))
	AddGadgetItem(1, -1, RTML_Parse(text,0))
EndMacro 


;-
;-Programm start
;-OpenWindow etc...
OpenWindow(0, 0, 0, 800, 400, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
EditorGadget(0, 0, 0, 800, 200,  #PB_Editor_ReadOnly)
EditorGadget(1, 0, 200, 800, 200,  #PB_Editor_ReadOnly)


;-Add colors to color table
RTML_AddColor("black", 	$000000)	;Add colors at runtime
RTML_AddColor("red", 	$0000FF)
RTML_AddColor("green",	$009900)
RTML_AddColor("blue", 	$FF0000)
RTML_AddColor("orange",	$0099FF)




;-Add Lines to the editor gadget
AddLine(("<color=blue><b>Zelda:</b></color> Aren't you the boy from the <color=green><i>Forrest</i><color=black>?"))
AddLine(("<color=blue><b>Zelda:</b> <color=black>This is <color=red>Ganondorf <color=black>, king of the <color=orange><u>Gerudos</u>!"))

;-Replace some colors
RTML_ReplaceColor("red",	$0000cc)	;Replace Colors at runtime. 
RTML_ReplaceColor("blue",	$660000)	;e.g use a darker shade at night or if the player is in a dungeon...
RTML_ReplaceColor("orange",	$005599)

;-Add more lines to the gadget using the replaced colors
AddLine(("Replace Colors at runtime. e.g use a darker shade at night or if the player is in a dungeon..."))
AddLine(("<color=blue>Zelda: <color=black>This is <color=red>Ganondorf <color=black>, king of the <color=orange>Gerudos!"))

;-Mainloop
Repeat
   event = WaitWindowEvent(20)   
Until event = #PB_Event_CloseWindow

Zach
Addict
Addict
Posts: 1656
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: wtf GUI Frameworks... rant I guess

Post by Zach »

Gonna dig into this newest update right away :)

I think we're on the same process, just have different ideas of how to do it.

I also thought about using specific names for colors, although I had only considered it for different sections of a room description (Header/"Room Name", entity list, item list, exits, etc)
But I should be able to use your examples with my ideas to create something uniquely suited to me, so its all good :)

This really is such a great extension of the editor gadget, I can't believe we're the only two to make serious attempts at it :shock:
Image
Post Reply