I've been working on the new StoryBook project, well the REF Control specifically.
My goal was to take the RTF from Diary/Journal Product and Enhance it Greatly, but more specifically encapsulate it (as much as possible) and try to get it into a plug-n-play Gadget of sorts. Allow it to be placed "ON" a form/window instead of BEING the form/Window. to Allow it to be on multiple forms in a project without having Multiple copies of it's code.
For those who have built these RTF forms You can realize that this has been no small undertaking. There are roughly 3000-5000 lines of code behind the RTF, closely tied to the EditorGadget, converting them all to handle Multiple EditorGadget without duplication of code It has taken 4 days of solid work, but I think I have gotten as close as I can.
It's NOT a true RTFGadget as such.
Every Form in Project can have it's own RTFEditor, with Menus & Toolbars & Right-Click menu & Spellcheck and all the other features with only a FEW lines of code. The Code is a little Cumbersome, as I wanted the Editor Gadget to have it's OWN StatusBar with Statistics.
Here is the FORM/Window Code:
Code: Select all
Procedure Chapter()
Define FormWidth, FormHeight, HeadHeight, EventID, MenuID, GadgetID, WindowID
;Window Definition --- other than RTF
OpenWindow(#Window_frmChapters,0,0,714,616,"Chapter Detail",#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_Invisible,WindowID(#Window_StoryBook))
TextGadget(#Gadget_frmChapters_lbName,40,35,150,25,"Name: ",#PB_Text_Right)
SetGadgetFont(#Gadget_frmChapters_lbName,LoadFont(#Gadget_frmChapters_lbName,"Rockwell",14))
StringGadget(#Gadget_frmChapters_txtName,195,35,375,25,"")
TextGadget(#Gadget_frmChapters_lbScene,40,65,150,25,"Scene: ",#PB_Text_Right)
SetGadgetFont(#Gadget_frmChapters_lbScene,LoadFont(#Gadget_frmChapters_lbScene,"Rockwell",14))
ComboBoxGadget(#Gadget_frmChapters_cbScenes,195,65,375,25)
ButtonGadget(#Gadget_frmChapters_btScene,575,60,35,30,"...")
ButtonGadget(#Gadget_frmChapters_btSave,460,555,105,30,"Save")
ButtonGadget(#Gadget_frmChapters_btCancel,575,555,105,30,"Cancel")
;RTF Gadget definition ----
;[ RTF Statusbar Fields =============================================================]
Define S, Height = 400
S = 510-380
Define CHLabel = TextGadget(#PB_Any, 0, Height-31, S, 35, "", #PB_Text_Center)
Define CHRow = TextGadget(#PB_Any , S, Height-31, 90, 35, "",#PB_Text_Center)
Define CHLine = TextGadget(#PB_Any , S+90, Height-31, 90, 35, "",#PB_Text_Center)
Define CHCount = TextGadget(#PB_Any, S+180, Height-31, 100, 35, "",#PB_Text_Center)
Define CHZoom = TextGadget(#PB_Any , S+280, Height-31, 100, 35, " Z: 100%")
;Call to actually build the RTF Gadget ion Form
;=================================================================================================================
; PanelGadget EditorGadget [ ======== Status Bar Fields ============][ X, Y, Width, Height]
RTFGadget(#Gadget_pChapter, #Gadget_eChapter, #CHLabel, #CHRow, #CHLine, #CHCount, #CHZoom, 35, 105, 645, 400)
;[ Search and Replace hooks ================================
uFindReplaceMsg = RegisterWindowMessage_(#FINDMSGSTRING)
SetWindowCallback(@WindowChapterCallback())
;Show Window
HideWindow(#Window_frmChapters,#False)
;Build RTF Menues Menues
BuildMenues(#Gadget_pChapter)
;Set REF Background Color
SetCtrlBackColor(#Gadget_eChapter, RGB(222, 184, 135))
;Make Window Visible
SetActiveGadget(#Gadget_eChapter)
;Control loop
Repeat
EventID =WaitWindowEvent()
MenuID =EventMenu()
GadgetID =EventGadget()
WindowID =EventWindow()
;Check RTF Control
;RTFGadget Event Call
;============================================================================================================================
; [======= EVENTS ==========] [======== Editor Status Bar ========]
;Check RTF FormName EditorGadget Event Menu Gadget Window Status1 Status2 Status3 Status4 Status5
RTFEvents(#Window_frmChapters, #Gadget_eChapter, EventID, MenuID, GadgetID, WindowID, #CHLabel, #CHRow, #CHLine, #CHCount, #CHZoom)
;Standard Eventloop for rest of Form Gadgets other than RTF
;=======================================================
Select EventID
Please check it out, and post your thoughts and comments.
https://www.pahlabs.com/product/productspbxstorybook/
(And for those who wanted Full Justification, I've yet to figure that one out, but I haven't given up)
This "RTFGadget" WILL be RELEASED as Source, via a ZIP file on my site (Spell Check has DLL and Dictionaries) When the Product is released.
--Origins --
Spell Check was imported from the old PurePad Project, modified for this project, as were several functions, although modified heavily for use here. So I want to give shout outs to the PurePad team of developers:
Library: RichEdit.pbi
Author: Thomas (ts-soft) Schulz
Co-Author: Michael (neotoma) Taupitz
Offcut: Stolen from: freak, danilo, srod, andreas and others
Though I Did not use their code directly, it was my "knowledge of origin" that I pulled upon for this endeavor. I want to honor their Open Source Release, and to pay it forward to others.
Also my use of this Uses ProGUI Menus and Toolbars....so you'll need to insert your key into marked area of RTFGadget.pbi
Pete