Page 1 of 4

WordPad clone source

Posted: Mon Jan 26, 2009 2:22 pm
by Fangbeast
I needed some of the functionality of WordPad namely, bold, italics, bullets, font colours etc and to learn how to do it, hunted the forum for snippets of all sorts and here is the result.

I know there is better in/ on the forums but I didn't need a full notepad, just the basics. Here is the source project below, hope it's useful to someone.

http://members.westnet.com.au/bangfeast ... ePiddle.7z

***** Update *****

Didn't realise that it had been nearly 6 (??) years since I worked on this and needed it again so I have done a massive update to PB 5.23 compatibily, fixed things that were wrong and added things I thought that I needed.

Hope the link above is working.
[Top menu bar]

Load an RTF file
Save to an RTF text file
Search text
Find first on RETURN then:
Find next on button or F3
Search exact case or not
Search up or down
Toggles
Screen snap
Word wrap
Read Only
AutoSave every 15 minutes
Help file (no!)

[Effects bar]

Graphical font selector (FluidByte)
Font Size
Character Locale (Not yet)
Bold, italic, underline, colour (SROD), Para left/middle/right, bullet

[Edit form]

Apart from typing in there (Grin), you can paste RTF text from other sources.
Select all text in the gadget
Control + Up or Down changes selected font size

[Statistics bar]

Number of lines, words and characters are displayed.

[Fake status bar]

Actually a stringgadget

Tried to add shortcuts for every menu option and also to keep the code consistent. Can't spend any more time on this as there are other programs to get out the door.

InfraTec was once again an invaluable help fixing things and giving suggestions when I had no hope of doing so.
Apart from the list of things above, there were lots of small improvements so go through the code with a fine toothed comb and improve it where I could not. Doubless there are a lot of things that could be better.

Posted: Mon Jan 26, 2009 2:28 pm
by rsts
As usual, looks very nice.

Thanks for sharing with us (again) :)

cheers

Posted: Mon Jan 26, 2009 6:16 pm
by srod
Looks nice fangles. Thanks. :)

Posted: Mon Jan 26, 2009 6:47 pm
by TerryHough
Fangles, I would love to look at it. But I can't unzip it. :cry:

Don't know why, but I can't get a 7zip running on my machine. Two different virus scanners object strenuously when I try to install it.

Posted: Mon Jan 26, 2009 6:48 pm
by Fangbeast
srod wrote:Looks nice fangles. Thanks. :)
For what?? Using *Most* of your code to make another toy??? :D :D :D

Posted: Mon Jan 26, 2009 6:49 pm
by Fangbeast
TerryHough wrote:Fangles, I would love to look at it. But I can't unzip it. :cry:

Don't know why, but I can't get a 7zip running on my machine. Two different virus scanners object strenuously when I try to install it.
Hi Terry. WinRar; as well as a lot of other archivers; also undo 7zip files.

Regards.

P.s I use Izarc' also free; that does 7Zip. It's a popular format these days, good compression.

Posted: Tue Jan 27, 2009 3:32 am
by pdwyer
Don't mind if I do ;)

Posted: Tue Jan 27, 2009 4:18 am
by idle
very nice thanks.

Posted: Tue Jan 27, 2009 6:05 am
by Fangbeast
pdwyer wrote:Don't mind if I do ;)
Don't mind if you do what????

Posted: Tue Jan 27, 2009 6:07 am
by Fangbeast
idle wrote:very nice thanks.
Still toying with it.

Now I want to add FluidByte's nice new ownerdrawn combobox with icons and fonts and srod's RTF routines that allow images.

But first, I have to survive the next week's temperatures.

Or someone else could do it:):)

P.S. Also need to add (Just like wordpad) that buttons act like toggles for when you select a block of text so they detect the current style on the selected text and the appropriate button is set to that state.

Update

Posted: Tue Jan 27, 2009 7:43 am
by Fangbeast
1. Just added FluidByte's nice ownerdrawn combo boxes with icons and font preview in the combo box itself, good one.

2. Fixed an enum I neglected to leave to the compiler which would have meant a crash sooner than later,

3. resized the form to accomodate some of the long font preview names.

@TerryHough, made the package a standard zip for you and everyone else. Link in first post.

Still lots could be done if we survive the heat:)

Posted: Tue Jan 27, 2009 9:20 am
by pdwyer
Fangbeast wrote:
pdwyer wrote:Don't mind if I do ;)
Don't mind if you do what????
help myself to your code :D

Posted: Tue Jan 27, 2009 9:36 am
by idle
Fangles sounds like you need a Beer but don't be drinking any of that Fosters or XXXX or vb bitter stuff as its like making love in a canoe in that it's f***ing near water.

Hope you get a moment to chill out!

Posted: Tue Jan 27, 2009 12:33 pm
by Fangbeast
idle wrote:Fangles sounds like you need a Beer but don't be drinking any of that Fosters or XXXX or vb bitter stuff as its like making love in a canoe in that it's f***ing near water.

Hope you get a moment to chill out!
I'm dizzy a lot lately and the heat doesn't help. Partly that diabetic medication I am on. Only good thing about alcohol is that it kills weeds. Give me a soy milk with milo and a huge pair of hooters every time!

Posted: Tue Jan 27, 2009 12:37 pm
by Fangbeast
Folks, I made a mistake with FluidByte's routine so that setting fonts don't work any more. Replace the existing #Gadget_notepiddle_font handler with the one below.

Code: Select all

Select EventGadget()
  Case #Gadget_notepiddle_font
    Select EventType()
      Case #PB_EventType_RightClick
        Editor_SetFont(#Gadget_notepiddle_edit) ; Wrapper for Editor_Font
    EndSelect
Add this wrapper to your code:

Code: Select all

Procedure Editor_SetFont(Gadget)
  CurrentFontNumber = GetGadgetState(Gadget)
  ForEach ftd()
    If ListIndex(ftd()) = CurrentFontNumber
      CurrentFontName.s = ftd()\Name
      Break
    EndIf
  Next
  If CurrentFontName
    Editor_Font(Gadget, CurrentFontName)
  EndIf
EndProcedure