looking for tiny editor

Just starting out? Need help? Post your questions and find answers here.
startup
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Feb 25, 2015 5:55 pm

looking for tiny editor

Post 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
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: looking for tiny editor

Post 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?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
startup
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Feb 25, 2015 5:55 pm

Re: looking for tiny editor

Post 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.
startup
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Feb 25, 2015 5:55 pm

Re: looking for tiny editor

Post 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?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: looking for tiny editor

Post 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.
BERESHEIT
startup
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Feb 25, 2015 5:55 pm

Re: looking for tiny editor

Post 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
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: looking for tiny editor

Post 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
User avatar
spikey
Enthusiast
Enthusiast
Posts: 750
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: looking for tiny editor

Post 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)
startup
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Feb 25, 2015 5:55 pm

Re: looking for tiny editor

Post by startup »

Gentlemen - thank you very much.
Last edited by startup on Tue Jun 28, 2016 2:17 pm, edited 1 time in total.
startup
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Feb 25, 2015 5:55 pm

Re: looking for tiny editor

Post 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?
startup
Enthusiast
Enthusiast
Posts: 105
Joined: Wed Feb 25, 2015 5:55 pm

Re: looking for tiny editor

Post by startup »

i solved the problem.
thank you all again.
Post Reply