RAD lite tool

RAD lite tool

Postby Otto » Sun Nov 08, 2009 6:45 pm

I need your help. The prototype of a RAD lite tool is ready.

Please keep in mind that this should only be a “lite” tool.

It should become a two way tool.

- First you could select from a combobox a control an objectinspector opens and you can insert and select “menu driven” attributes belonging to this control. Then you can insert command syntax into your source code.

- Second you could mark a bit of command syntax source code and then a window pops up and you can insert and select “menu driven” attributes belonging to this control.

At the moment I only have TDialog and TTimer working for testing. Please see the code maybe someone will help to get the other controls ready.
If someone take a control to work on please post here.

How does the program work?

You select a control in source code which you would like to work on – at the moment only TDialog or TTimer – press Ctrl + C to copy the text to the clipboard.
In RAD lite there is a button Clipboard. The objectinspector pops up.


Regards,
Otto
Code: Select all  Expand view

 /*
 for testing
 DEFINE DIALOG oDlg FROM 5, 5 TO 20, 40 TITLE "A Dialog Box"

 DEFINE TIMER oTmr  INTERVAL 500 ACTION  (oTmr:DeActivate(),;
 oWnd:Say( 10, 17, Time() ), openWin(aufruf:="TIMER"), oTmr:Activate() ) of oWnd

*/



// An object inspector using XBrowse
// (c) FiveTech Software 2008

#include "FIVEWIN.CH"
#INCLUDE "BOX.CH"
#INCLUDE "FILEIO.CH"
#INCLUDE "INKEY.CH"
#include "Splitter.ch"
#include "XBrowse.ch"

#define COLOR_WINDOW        5
#define COLOR_WINDOWTEXT    8

static oWnd, oClp
//----------------------------------------------------------------------------//

function Main()
   local oTmr
   local aufruf  := ""
   local oCbx
   local cCbx    := ""

   DEFINE WINDOW oWnd TITLE "AutoCode5" FROM    50,   650 TO  300,  975 PIXEL

   DEFINE CLIPBOARD oClp OF oWnd
   SETWINDOWPOS( oWnd:hWnd, -1, 0, 0, 0, 0, 3 )

   DEFINE TIMER oTmr  INTERVAL 500 ACTION  (oTmr:DeActivate(),;
      oWnd:Say( 10, 17, Time() ), openWin(aufruf:="TIMER"), oTmr:Activate() ) of oWnd

   @ 0.5, 1 COMBOBOX oCbx VAR cCbx STYLE CBS_DROPDOWN Size 100,100;
      ITEMS { "DEFINE TIMER oTmr", "DEFINE DIALOG oDlg", "Three" } ;
      ON CHANGE SetSomeText( cCbx )

   @ 4,10 BUTTON "&CLIPBOARD" OF oWnd SIZE 80,80 ;
      ACTION GetSomeText()

   ACTIVATE TIMER oTmr

   ACTIVATE WINDOW oWnd

   oTmr:End()

return nil


function SetSomeText(cText)
   local cDatei   := "text.txt"
   memoWrit( cDatei, ALLTRIM(cText) )
return nil
//----------------------------------------------------------------------------//

function GetSomeText()
   local cDatei   := "text.txt"
   local cText    := oClp:GetText()

   oClp:Clear()
   memoWrit( cDatei, ALLTRIM(cText) )

return nil
//----------------------------------------------------------------------------//

function openWin(aufruf)
   local cText
   local cDatei         := "text.txt"
   local cTxtFile
   local nFrom
   local cLine          := ""
   local cMemoRead      := ""
   local nPos           := 0
   local aData          := {}
   local cParameters    := ""
   local cRest           := ""

   if file(cDatei) = .t.

      if aufruf = "TIMER"

         cMemoRead := memoread(cDatei)
         cText := "#include 'FiveWin.ch'" + CRLF +;
            "#include 'XBrowse.Ch'" + CRLF +;
            "#include 'Splitter.ch'" + CRLF +;
            cMemoRead

         FERASE (cDatei)
         
         memowrit("datei.prg",cText)
         
         waitrun ("buildh.bat datei" ,0)
         cTxtFile = MemoRead( "datei.ppo" )

         nFrom = 1
         while nFrom < Len( cTxtFile )
            cLine = ExtractLine( cTxtFile, @nFrom )
            SysRefresh()
         end

         if AT("TDialog():New", cLine ) > 1

            aData := { { "DEFINE DIALOG",   "<oDlg>",        EDIT_GET },;
               { "TITLE",          "<cTitle>",      EDIT_GET },;
               { "FROM Top",       "<nTop>",        EDIT_GET },;
               { "FROM Left",      "<nLeft>",       EDIT_GET },;
               { "FROM Bottom",    "<nBottom>",     EDIT_GET },;
               { "FROM Right",     "<nRight>" ,     EDIT_GET },;
               { "FROM Width",     "<nWidth>" ,     EDIT_GET },;
               { "FROM Height",    "<nHeight>" ,    EDIT_GET },;
               { "LIBRARY",        "<hResources>",  EDIT_GET },;
               { "VBX",            "<VBX>",         EDIT_GET },;
               { "STYLE",           "<nStyle>",     EDIT_GET },;
               { "COLOR nClrFore",  "<nClrFore>",   EDIT_GET },;
               { "COLOR nClrBack",  "<nClrBack>",   EDIT_GET },;
               { "BRUSH",           "<oBrush>",     EDIT_GET },;
               { "OF",              "<oParent>",    EDIT_GET },;
               { "PIXEL" ,          "result",       EDIT_BUTTON,  { || MsgYesNo( "Select a value" ) } },;
               { "ICON",            "<oIco>",       EDIT_GET },;
               { "FONT",            "<oFont>",      EDIT_GET },;
               { "HELP",            "<nHelpId>",    EDIT_GET },;
               { "TRANSPARENT",     "<TRANSPARENT>",EDIT_GET } }


            aData[1,2]   := "<oDlg> "
            aData[2,2]   := "<cTitle>"
            aData[3,2]   := "<nTop>"
            aData[4,2]   := "<nLeft>"
            aData[5,2]   := "<nBottom>"
            aData[6,2]   := "<nRight>"
            aData[7,2]   := "<nWidth>"
            aData[8,2]   := "<nHeight>"
            aData[9,2]   := "<cResName>"
            aData[10,2]  := "<.vbx.>"
            aData[11,2]  := "<nStyle>"
            aData[12,2]  := "<nClrText>"
            aData[13,2]  := "<nClrBack>"
            aData[14,2]  := "<oBrush>"
            aData[15,2]  := "<oWnd>"
            aData[16,2]  := "<.pixel.>"
            aData[17,2]  := "<oIco>"
            aData[18,2]  := "<oFont>"
            aData[19,2]  := "<nHelpId>"
            aData[20,2]  := "<.transparent.>"

            aData[1,2] := left( cLine,  (AT("=" , cLine) - 1 ) ) + space(100)

            nPos       := AT("TDialog():New", cLine ) + len("TDialog():New") + 1

            cParameters := SubStr( cLine, nPos + 1 )
            aData[3,2]  := left( cParameters,( AT( ",", cParameters ) - 1) ) + space(100)
            cRest       := SubStr( cParameters, AT(",", cParameters ) + 1  )
            aData[4,2]  := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[5,2]  := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[6,2]  := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[2,2]  := left(cRest, AT( ",", cRest ) - 1 ) + space(100) //cTitle
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[7,2]  := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[8,2]  := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[9,2]  := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[10,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[11,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[12,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[13,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[14,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[15,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[16,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[17,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[18,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr( cRest, AT(",", cRest ) + 1)
            aData[19,2] := left(cRest, AT( ",", cRest ) - 1 ) + space(100)
            cRest       := SubStr(cRest, ( AT(",", cRest ) + 2 ) )
            aData[20,2] := left( cRest, ( AT(")", cRest ) - 1 ) ) + space(100)

         elseif   AT("TTimer():New", cLine ) > 1

            aData := { ;
               { "DEFINE TIMER",   "<oTimer>",       EDIT_GET },;
               { "INTERVAL",        "<nInterval>",   EDIT_GET },;
               { "ACTION",         "<uAction>",      EDIT_GET },;
               { "OF",             "<oWnd>",         EDIT_GET } }

            aData[1,2]  := "cTimer"
            aData[2,2]  := "nInterval"
            aData[3,2]  := "uAction"
            aData[4,2]  := "oWnd"

            aData[1,2]  := left( cLine,  (AT(":" , cLine) - 1 ) ) + space(100)

            nPos        := AT("TTimer():New", cLine ) + len("TTimer():New") + 1
            cParameters := SubStr( cLine, nPos + 1 )

            aData[2,2]  := left( cParameters,( AT( ",", cParameters ) - 1) ) + space(100)

            cRest       := SubStr( cParameters, AT(",", cParameters ) + 1)
            aData[3,2]  := left(cRest, AT( "}", cRest ) ) + space(100)

            cRest       := SubStr(cRest, ( AT("}", cRest ) + 2 ) )
            aData[4,2]  := left( cRest, ( AT(")", cRest ) - 1 ) )    + space(100)

         else

            msginfo( cLine + CRLF +"not supported")
         endif

      endif

      objectInspector(aData)

   endif

return nil


function objectInspector(aData)
   local oWndlocal, oBrw, oBar


   DEFINE WINDOW oWndlocal TITLE "Object inspector" FROM 10, 10 TO 40, 48

   DEFINE BUTTONBAR oBar OF oWndlocal SIZE 60, 60 2007

   DEFINE BUTTON OF oBar ACTION (TextToClip(aData),oWndlocal:end()) ;
      RESOURCE "attach" PROMPT "Clipboard" TOOLTIP "Clipboard"

   oWndlocal:ToolWindow()

   @ 0, 0 XBROWSE oBrw ARRAY aData COLUMNS 1, 2 COLSIZES 100, 140 ;
      ON CHANGE SetEditType( oBrw, aData )

   oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
   oBrw:aCols[ 1 ]:cHeader = "Property"
   oBrw:aCols[ 2 ]:cHeader = "Value"
   oBrw:aCols[ 1 ]:bLDClickData = { || oBrw:aCols[ 2 ]:Edit() }

   oBrw:aCols[ 1 ]:cHeader = "Property"
   oBrw:aCols[ 2 ]:cHeader = "Value"
   oBrw:aCols[ 1 ]:bLDClickData = { || oBrw:aCols[ 2 ]:Edit() }
   oBrw:bKeyChar = { | nKey | If( nKey == VK_RETURN .and. ! oBrw:lEditMode, oBrw:aCols[ 2 ]:Edit(), ) }

   oWndlocal:oClient = oBrw

   oBrw:CreateFromCode()

   ACTIVATE WINDOW oWndlocal ;
      ON RESIZE oBrw:aCols[ 2 ]:nWidth := oWndlocal:nWidth - oBrw:aCols[ 1 ]:nWidth - 63

return nil
//----------------------------------------------------------------------------//

function TextToClip(aData)
   local oClp
   local cText := ""
   local I     := 0
   LOCAL cTextTemp := ""


   For I = 1 to len(aData)

      IF  VALTYPE(aData[I,2]) = nil

      ELSEif  VALTYPE(aData[I,2]) = "C"

         //FROM    50,   50 TO  300,  275
         if     ALLTRIM(aData[I,1]) = "FROM Top"
            cTextTemp := "FROM " + ALLTRIM(aData[I,2] ) + ", "
         elseif ALLTRIM(aData[I,1]) = "FROM Left"
            cTextTemp := cTextTemp + ALLTRIM(aData[I,2] ) + " TO "
         elseif ALLTRIM(aData[I,1]) = "FROM Bottom"
            cTextTemp := cTextTemp + ALLTRIM(aData[I,2] ) + ", "
         elseif ALLTRIM(aData[I,1]) = "FROM Right"
            cText := cText + cTextTemp + ALLTRIM(aData[I,2] ) + ";"  + CRLF

         ELSE
            cText :=  cText +   ALLTRIM(aData[I,1] + space(5) + aData[I,2])+ ";"  + CRLF
         endif


      elseif  VALTYPE(aData[I,2]) = "N"
         cText :=  cText + ALLTRIM(aData[I,1] + space(5) + STR(aData[I,2])) +";"  + CRLF
      elseIF VALTYPE(aData[I,2]) = "L"

         if aData[I,2]=.t.
            cText :=  cText + aData[I,1] + space(5) + ".T. ;"  + CRLF
         else
            cText :=  cText + aData[I,1] + space(5) + ".F. ;"  + CRLF
         endif

      else
         //msginfo(aData[I,2])

      endif

   NEXT


/*


   if len(ALLTRIM(oBrush))>0
      cText :=  cText + "BRUSH " + ALLTRIM(oBrush) + "  ; " + CRLF
   endif

   if len(ALLTRIM(oCursor))>0
      cText :=  cText + "CURSOR " + ALLTRIM(oCursor) + "  ; " + CRLF
   endif

   if len(ALLTRIM(oMenu))>0
      cText :=  cText + "MENU " + ALLTRIM(oMenu) + "  ; " + CRLF
   endif

   if len(ALLTRIM(oIcon))>0
      cText :=  cText + "ICON " + ALLTRIM(oIcon) + "  ; " + CRLF
   endif

   if len(ALLTRIM(oParent))>0
      cText :=  cText + "OF " + ALLTRIM(oParent) + "  ; " + CRLF
   endif

   if lVScroll =.t.
      cText :=  cText + "VSCROLL " + " ; " + CRLF
   endif

   if lHScroll =.t.
      cText :=  cText + "HSCROLL " + " ; " + CRLF
   endif

   if nClrFore > 0 .or. nClrBack > 0
      cText :=  cText + "COLORS " + str(nClrFore) + " , " + str(nClrBack) + "  ; " + CRLF
   endif

   if lPixel =.t.
      cText :=  cText + "PIXEL " + " ; " + CRLF
   endif

   if len(ALLTRIM(cBorder))>0
      cText :=  cText + "BORDER " + cBorder + "  ; " + CRLF
   endif

   // cText :=  cText +   "<HelpId: HELPID, HELP ID> <nHelpId>  ; " + CRLF +;

   if nStyle > 0
      cText :=  cText + "STYLE " + str(nStyle) + "  ; " + CRLF
   endif

   if lSysMenu = .t.
      cText :=  cText + "NOSYSMENU " + " ; " + CRLF
   endif

   if lCaption =.t.
      cText :=  cText + "NOCAPTION " + " ; " + CRLF
   endif
   if lMin =.t.
      cText :=  cText + "NOICONIZE " + " ; " + CRLF
   endif
   if lMax =.t.
      cText :=  cText + "NOMAXIMIZE " + " ; " + CRLF
   endif

   // "MDICHILD  ; " + CRLF + ;


*/


   cText := ALLTRIM(cText)

   cText := left(cText, (len(cText)-4))

   msginfo( procname() + "   " + str(procline()) + "   " + cText )

   DEFINE CLIPBOARD oClp OF oWnd
   oClp:Clear()
   oClp:SetText( (cText))

return nil
//----------------------------------------------------------------------------//

function SetEditType( oBrw, aData )

   local nEditType := aData[ oBrw:nArrayAt ][ 3 ]
   local oCol      := oBrw:aCols[ 2 ]

   oCol:nEditType := nEditType

   do case
   case nEditType == EDIT_LISTBOX
      oCol:aEditListTxt   = aData[ oBrw:nArrayAt ][ 4 ]
      oCol:aEditListBound = aData[ oBrw:nArrayAt ][ 4 ] // remove this if you want the index, not the string

   case nEditType == EDIT_BUTTON
      oCol:bEditBlock = aData[ oBrw:nArrayAt ][ 4 ]
      // whatever is returned by the codeblock, it will be asigned
   endcase

   oBrw:Refresh()

return nil
//----------------------------------------------------------------------------//
 



Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6329
Joined: Fri Oct 07, 2005 7:07 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 101 guests