Page 1 of 1

looking for tiny editor

Posted: Wed Jun 15, 2016 10:56 am
by startup
looking for a tiny editor (gadget style) with the following features:

text: bold, italic, underline
embed pictures

is there such a thing in pb source code?

thanks

Re: looking for tiny editor

Posted: Wed Jun 15, 2016 11:39 am
by IdeasVacuum
That sounds like the PB EditorGadget using Rich Text Format. Do you mean you want to add this as a feature of your own app, or you just want a stand-alone editor app to use yourself?

Re: looking for tiny editor

Posted: Wed Jun 15, 2016 12:46 pm
by startup
i would like kind of a gadget in a pb program that can do that. enter text and drag/drop one or more pictures on lines and on lines in between text lines.

Re: looking for tiny editor

Posted: Mon Jun 27, 2016 4:12 pm
by startup
thanks for the help so far. i looked at:
http://www.purebasic.fr/english/viewtop ... t&start=45

and it looks really good. if i try to use this gadget in a windows with a splitter, i get the message:

[ERROR] The specified #Gadget is not initialised.

I use x64. what do i have to watch out for?

Re: looking for tiny editor

Posted: Tue Jun 28, 2016 2:46 am
by netmaestro
With no code posted it's impossible to say what might be wrong. Show us what you have so far and someone will point out the error.

Re: looking for tiny editor

Posted: Tue Jun 28, 2016 10:17 am
by startup
thank you for your reply!

here is an example:

Code: Select all

XIncludeFile "RichEdit.pbi"

UseModule RichEdit

Global Window_0, Event.i, Quit.i
Global ListIcon_0, Tree_0, Splitter_2, Splitter_3
Global.RichEdit Editor_0; Objectvariable für unser RTF-Control

Enumeration FormMenu
  #newdatabase
  #openmailbase
  #closemailbase
  #Exit
  #ManageAccounts
  #newcertificate
  #deletecertificate
  #usecertificate
  #Buddyaddcert
  #buddymanagecert
EndEnumeration

Declare ResizeGadgetsWindow_0()


Procedure OpenWindow_0(x = 0, y = 0, width = 1190, height = 680)
  Window_0 = OpenWindow(#PB_Any, x, y, width, height, "Mailer", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
  CreateMenu(0, WindowID(Window_0))
  MenuTitle("File")
  MenuItem(#newdatabase, "New Database")
  MenuBar()
  MenuItem(#openmailbase, "Open Mailbase")
  MenuItem(#closemailbase, "Close Mailbase")
  MenuBar()
  MenuItem(#Exit, "Exit")
  MenuTitle("Accounts")
  MenuItem(#ManageAccounts, "Manage")
  MenuTitle("My Certificates")
  MenuItem(#newcertificate, "New")
  MenuBar()
  MenuItem(#deletecertificate, "Delete")
  MenuBar()
  MenuItem(#usecertificate, "Use")
  MenuTitle("Friend Certificates")
  MenuItem(#Buddyaddcert, "Add Certificate")
  MenuBar()
  MenuItem(#buddymanagecert, "Manage")
  ListIcon_0 = ListIconGadget(#PB_Any, 324, 0, 866, 215, "Column 1", 100, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
  ;Editor_0 = EditorGadget(#PB_Any, 324, 224, 866, 434, #PB_Editor_WordWrap)
  Tree_0 = TreeGadget(#PB_Any, 0, 0, 315, 658, #PB_Tree_AlwaysShowSelection)
  
  Editor_0 = New_RichEdit(324, 224, 866, 434)
  Editor_0\SetLeftMargin(5)
  Editor_0\SetRightMargin(5)
  Editor_0\SetInterface()
;  CloseGadgetList()
    
  Splitter_2 = SplitterGadget(#PB_Any, 324, 0, 866, 658, ListIcon_0, Editor_0, #PB_Splitter_Separator | #PB_Splitter_FirstFixed)
  SetGadgetState(Splitter_2, 215)
  Splitter_3 = SplitterGadget(#PB_Any, 0, 0, 1190, 658, Tree_0, Splitter_2, #PB_Splitter_Vertical | #PB_Splitter_Separator | #PB_Splitter_FirstFixed)
  SetGadgetState(Splitter_3, 315)
  
  SetActiveWindow(Window_0)
  ResizeWindow(Window_0, 0,0, 1190, 680)
EndProcedure

Procedure ResizeGadgetsWindow_0()
  Protected FormWindowWidth, FormWindowHeight
  FormWindowWidth = WindowWidth(Window_0)
  FormWindowHeight = WindowHeight(Window_0)
  ResizeGadget(ListIcon_0, FormWindowWidth - 866, 0, 866, 215)
  ResizeGadget(Editor_0, FormWindowWidth - 866, 224, 866, FormWindowHeight - MenuHeight() - 224)
  ResizeGadget(Tree_0, 0, 0, 315, FormWindowHeight - MenuHeight() - 0)
  ResizeGadget(Splitter_2, FormWindowWidth - 866, 0, 866, FormWindowHeight - MenuHeight() - 0)
  ResizeGadget(Splitter_3, 0, 0, 1190, GadgetHeight(Splitter_2) - 0)
EndProcedure

OpenWindow_0()
  DisableMenuItem(0, #closemailbase, 1)
  DisableMenuItem(0, #ManageAccounts, 1)
  DisableMenuItem(0, #newcertificate, 1)
  DisableMenuItem(0, #deletecertificate, 1)
  DisableMenuItem(0, #usecertificate, 1)
  DisableMenuItem(0, #Buddyaddcert, 1)
  DisableMenuItem(0, #buddymanagecert, 1)

  Repeat
    Event = WaitWindowEvent()
    Select event
      Case #PB_Event_SizeWindow
        ResizeGadgetsWindow_0()
      Case #PB_Event_CloseWindow
        Quit = 1  
      Case #PB_Event_Menu
        Select EventMenu()
          Case #newdatabase
            If databaseconnection <> 0
              DisableMenuItem(0, #closemailbase, 0)
              DisableMenuItem(0, #ManageAccounts, 0)
              DisableMenuItem(0, #newcertificate, 0)
              DisableMenuItem(0, #deletecertificate, 0)
              DisableMenuItem(0, #usecertificate, 0)
              DisableMenuItem(0, #Buddyaddcert, 0)
              DisableMenuItem(0, #buddymanagecert, 0)
            EndIf
          Case #openmailbase
            If databaseconnection <> 0
              DisableMenuItem(0, #closemailbase, 0)
              DisableMenuItem(0, #ManageAccounts, 0)
              DisableMenuItem(0, #newcertificate, 0)
              DisableMenuItem(0, #deletecertificate, 0)
              DisableMenuItem(0, #usecertificate, 0)
              DisableMenuItem(0, #Buddyaddcert, 0)
              DisableMenuItem(0, #buddymanagecert, 0)
            EndIf
          Case #closemailbase
            If databaseconnection = 0
              DisableMenuItem(0, #closemailbase, 1)
              DisableMenuItem(0, #ManageAccounts, 1)
              DisableMenuItem(0, #newcertificate, 1)
              DisableMenuItem(0, #deletecertificate, 1)
              DisableMenuItem(0, #usecertificate, 1)
              DisableMenuItem(0, #Buddyaddcert, 1)
              DisableMenuItem(0, #buddymanagecert, 1)
            EndIf
          Case #Exit
            Quit = 1
          Case #ManageAccounts
          Case #newcertificate
          Case #deletecertificate
          Case #usecertificate
          Case #Buddyaddcert
          Case #buddymanagecert
        EndSelect  
      Case #PB_Event_Gadget
        Select EventGadget()
        EndSelect
    EndSelect
  Until Quit = 1

Re: looking for tiny editor

Posted: Tue Jun 28, 2016 1:13 pm
by infratec
Hi,

you didn't use the pbi in the right way :mrgreen:

New_RichEdit() returns not a gadget number, it returns a structure.

In your case you have to replace all Editor_0 with

Code: Select all

Editor_0\GetID()
Bernd

Re: looking for tiny editor

Posted: Tue Jun 28, 2016 1:26 pm
by spikey
You will also need to replace the function call to

Code: Select all

ResizeGadget(Editor_0, FormWindowWidth - 866, 224, 866, FormWindowHeight - MenuHeight() - 224)
with the member function in the interface.

Code: Select all

Editor_0\Resize(FormWindowWidth - 866, 224, 866, FormWindowHeight - MenuHeight() - 224)

Re: looking for tiny editor

Posted: Tue Jun 28, 2016 1:50 pm
by startup
Gentlemen - thank you very much.

Re: looking for tiny editor

Posted: Tue Jun 28, 2016 2:16 pm
by startup
there is still one error.

when sizing the window, the width of the edit and listicon do not extend to right. any good tip?

Re: looking for tiny editor

Posted: Tue Jun 28, 2016 6:26 pm
by startup
i solved the problem.
thank you all again.