Skip to content

Commit

Permalink
Code changes 1.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSquires committed Jul 22, 2018
1 parent d87aad7 commit c7e0d0f
Show file tree
Hide file tree
Showing 17 changed files with 268 additions and 156 deletions.
Binary file modified Sample_Projects/VisualDesigner/FormTest.wfbe
Binary file not shown.
Binary file modified Sample_Projects/VisualDesigner/frmLogon.inc
Binary file not shown.
Binary file modified Sample_Projects/VisualDesigner/frmPopup.inc
Binary file not shown.
Binary file added Sample_Projects/VisualDesigner/logon.exe
Binary file not shown.
Binary file modified WinFBE.wfbe
Binary file not shown.
Binary file modified WinFBE32.exe
Binary file not shown.
Binary file modified WinFBE64.exe
Binary file not shown.
5 changes: 4 additions & 1 deletion changes.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Version 1.6.6 (July 22, 2018)
- Fixed: Many changes related to the experimental visual designer.

Version 1.6.5 (July 15, 2018)
- Added: Visual Designer enabled but it is limited and experiemental at this point.
- Added: Visual Designer enabled but it is limited and experimental at this point.
- Added: FreeBASIC Compiler nightly build July 3, 2018 (32 and 64 bit versions).
- Added: Extended style to the Explorer treeview to give it modern looking icons rather than +/- boxes.
- Changed: Removed WinFBX include paths from "Environment Options" / "Compiler Setup". No longer needed.
Expand Down
84 changes: 49 additions & 35 deletions src/clsDocument.inc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ Function clsDocument.CreateDesignerWindow( ByVal hWndParent As HWnd ) as hwnd
' out the DesignFrame whenever the tabcontrol switches between design/code view.
'
this.IsDesigner = true
this.FileEncoding = FILE_ENCODING_UTF16_BOM
dim rc as RECT
' (1) Create the DesignMain window
Expand Down Expand Up @@ -247,11 +248,8 @@ Function clsDocument.CreateCodeWindow( ByVal hWndParent As HWnd, _
' contains visual designer code then we only want to apply control properties after all of
' the file is read, otherwise it would get applied immediately after each call to CreateToolboxControl.
this.LoadingFromFile = true
dim sText as string
dim sText as string ' this will be a UTF-8 encoded string
if GetFileToString(*pwszFile, sText, @this) = false then
' Need to parse sText to remove/process any possible visual designer code. Only
' the non-VD text is returned.
sText = this.ParseDesignerString(hWndParent, sText)
this.SetText( sText )
this.DateFileTime = AfxGetFileLastWriteTime( *pwszFile )
else
Expand All @@ -277,8 +275,9 @@ Function clsDocument.CreateCodeWindow( ByVal hWndParent As HWnd, _
' Display the ToolBox/PropertyList
frmVDToolbox_Show( HWND_FRMMAIN, SW_SHOW)
DisplayPropertyList(@this)
' Set flag to regenerate code for the visual designer
' Regenerate code for the visual designer
this.bRegenerateCode = true
GenerateCode(@this)
end if
this.ApplyProperties()
Expand Down Expand Up @@ -344,42 +343,63 @@ Function clsDocument.InsertFile() As BOOLEAN
Function = 0
End Function
' ========================================================================================
' Parse all of the file's code to remove and process any visual designer specific code.
' Returns a string representing just the code only (visual designer metastatements removed).
' ========================================================================================
function clsDocument.ParseDesignerString( ByVal hWndParent As HWnd, byref sAllText as CWSTR ) as CWSTR
function clsDocument.ParseDesignerString( ByVal hWndParent As HWnd, byref wszAllText as wstring ) as CWSTR
' NOTE: The incoming wszAllText string is UTF-16 encoded. The resulting string that
' is returned from this function is also UTF-16 encoded. All WinFBE form files
' must be unicode encoded.
' This function filters out all form metadata as well as any code generated code between
' the two codegen tags:
' ' WINFBE_CODEGEN_START
' ' WINFBE_CODEGEN_END
dim pCtrl as clsControl ptr
dim pCtrlActive as clsControl ptr
dim as RECT rc, rcCtrl
dim as CWSTR wst, wszControlType, wszPropName, wszPropValue, wszEventName
dim as CWSTR wszControlType, wszPropName, wszPropValue, wszEventName
dim as CWSTR wst
dim as Long nControlType, numLines, numOffsetLines
' The first line MUST contain the identifier that this is a form file.
if left(sAllText, 13) = "' WINFBE FORM" then
if left(wszAllText, 13) = "' WINFBE FORM" then
this.IsDesigner = true
this.CreateDesignerWindow(hWndParent)
numOffsetLines = 1
else
' This is just a regular code file with no visual designer
this.IsDesigner = false
return sAllText
return wszAllText
END IF
' Iterate all of the lines related to the visual designer
numLines = AfxStrParseCount(sAllText, vbcrlf)
dim as long iLineStart = 1
dim as long iLineEnd
for i as long = 2 to numLines
wst = AfxStrParse(sAllText, i, vbcrlf)
do until iLineStart >= len(wszAllText)
iLineEnd = instr(iLineStart, wszAllText, vbcrlf)
if iLineEnd = 0 then iLineEnd = len(wszAllText) ' cr/lf not found
wst = mid(wszAllText, iLineStart, iLineEnd - iLineStart)
iLineStart = iLineStart + len(wst) + len(vbcrlf)
numOffsetLines = numOffsetLines + 1
if left(wst, 17) = "' WINFBE FORM_END" then
this.ErrorOffset = numOffsetLines
sAllText = ltrim(AfxStrRemain( sAllText, "' WINFBE FORM_END" ), vbcrlf)
return sAllText
elseif left(wst, 20) = "' WINFBE_CODEGEN_END" then
this.ErrorOffset = numOffsetLines
wszAllText = ltrim(AfxStrRemain( wszAllText, "' WINFBE_CODEGEN_END" ), vbcrlf)
return wszAllText
elseif left(wst, 23) = "' WINFBE CONTROL_START " then
' The control type name is parse #4 (blank space)
wszControlType = AfxStrParse(wst, 4, " ")
Expand All @@ -392,26 +412,28 @@ function clsDocument.ParseDesignerString( ByVal hWndParent As HWnd, byref sAllTe
ApplyControlProperties( @this, pCtrl )
pCtrl->SuspendLayout = false
elseif left(wst, 20) = "' PROPERTIES_START" then
elseif left(wst, 18) = "' PROPERTIES_END" then
'elseif left(sLine, 20) = "' PROPERTIES_START" then
'elseif left(sLine, 18) = "' PROPERTIES_END" then
elseif left(wst, 16) = "' PROP_NAME=" then
wszPropName = mid(wst, 17)
elseif left(wst, 17) = "' PROP_VALUE=" then
wszPropValue = mid(wst, 18)
wszPropValue = mid(wst, 18) ' utf8 encoded
SetControlProperty(pCtrl, wszPropName, wszPropValue)
elseif left(wst, 16) = "' EVENTS_START" then
elseif left(wst, 14) = "' EVENTS_END" then
'elseif left(sLine, 16) = "' EVENTS_START" then
'elseif left(sLine, 14) = "' EVENTS_END" then
elseif left(wst, 17) = "' EVENT_NAME=" then
wszEventName = mid(wst, 18)
SetControlEvent(pCtrl, wszEventName, true)
end if
NEXT
loop
return wszAllText
end function
' ========================================================================================
Expand Down Expand Up @@ -490,15 +512,9 @@ Function clsDocument.SaveFile( ByVal bSaveAs As BOOLEAN = False ) As BOOLEAN
' saved at the start of the file before any of the code is displayed.
if this.IsDesigner then
wszDesigner = this.CreateDesignerString
' Also, regenerate visual designer code
if this.bRegenerateCode then
dim as hwnd hEdit = this.hWindow(0)
dim as long nFirstLine = SendMessage( hEdit, SCI_GETFIRSTVISIBLELINE, 0, 0)
dim as long curPos = SendMessage( hEdit, SCI_GETCURRENTPOS, 0, 0)
GenerateCode(@this)
SendMessage( hEdit, SCI_GOTOPOS, curPos, 0)
SendMessage( hEdit, SCI_SETFIRSTVISIBLELINE, nFirstLine, 0)
END IF
GenerateCode(@this) ' Also, regenerate visual designer code
end if
END IF
' Save text buffer to disk by directly accessing buffer rather
Expand All @@ -518,10 +534,8 @@ Function clsDocument.SaveFile( ByVal bSaveAs As BOOLEAN = False ) As BOOLEAN
select CASE this.FileEncoding
case FILE_ENCODING_ANSI
if sciCodePage = 0 THEN
put #f, , STR(**wszDesigner)
put #f, , *psz ' no conversion necessary
else
put #f, , STR(**wszDesigner)
' need to convert
put #f, , Utf8ToAscii(*psz)
end if
Expand All @@ -531,10 +545,8 @@ Function clsDocument.SaveFile( ByVal bSaveAs As BOOLEAN = False ) As BOOLEAN
put #f, , chr(&HEF, &HBB, &HBF)
if sciCodePage = SC_CP_UTF8 THEN
' no conversion necessary
put #f, , wszDesigner.Utf8
put #f, , *psz
else
put #f, , wszDesigner.Utf8
' need to convert
put #f, , AnsiToUtf8(*psz)
end if
Expand All @@ -543,11 +555,13 @@ Function clsDocument.SaveFile( ByVal bSaveAs As BOOLEAN = False ) As BOOLEAN
' Output the BOM first
put #f, , chr(&HFF, &HFE)
if sciCodePage = SC_CP_UTF8 THEN
put #f, , **wszDesigner
put #f, , CAST(BYTE PTR, wszDesigner.m_pBuffer)[0], wszDesigner.m_BufferLen
put #f, , CAST(BYTE PTR, this.wszCodeGen.m_pBuffer)[0], wszCodeGen.m_BufferLen
' convert utf8 to utf16
put #f, , Utf8ToUnicode(*psz)
else
put #f, , **wszDesigner
put #f, , CAST(BYTE PTR, wszDesigner.m_pBuffer)[0], wszDesigner.m_BufferLen
put #f, , CAST(BYTE PTR, this.wszCodeGen.m_pBuffer)[0], wszCodeGen.m_BufferLen
' need to convert ansi to unicode
put #f, , WStr(*psz)
end if
Expand Down
33 changes: 20 additions & 13 deletions src/frmMain.inc
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,10 @@ End Function
' Save project file to disk
' ========================================================================================
Function OnCommand_ProjectSave( ByVal HWnd As HWnd, ByVal bSaveAs As BOOLEAN = False) As LRESULT

' Do the actual saving to disk
' Save all dirty files
OnCommand_FileSaveAll( HWnd )
' Do the actual saving to disk of the Project file
dim idx as long = gApp.GetActiveProjectIndex()
gApp.Projects(idx).SaveProject(bSaveAs)

Expand Down Expand Up @@ -1481,6 +1483,7 @@ Function frmMain_OnCommand(ByVal HWnd As HWnd, ByVal id As Long, ByVal hwndCtl A
end if
end if
pDoc->Controls.Remove(pCtrl)
pDoc->bRegenerateCode = true
pDoc->UserModified = true
exit for
END IF
Expand Down Expand Up @@ -1830,16 +1833,7 @@ Function frmMain_OnNotify(ByVal HWnd As HWnd, ByVal id As Long, ByVal pNMHDR As
end if
case IDC_DESIGNTABCTRL
frmMain_PositionWindows(HWnd)
if pDoc then
if IsDesignerView(pDoc) = false then ' clicked on the code window
dim as hwnd hEdit = pDoc->hWindow(0)
dim as long nFirstLine = SendMessage( hEdit, SCI_GETFIRSTVISIBLELINE, 0, 0)
dim as long curPos = SendMessage( hEdit, SCI_GETCURRENTPOS, 0, 0)
GenerateCode(pDoc)
if curPos >=0 then SendMessage( hEdit, SCI_GOTOPOS, curPos, 0)
if nFirstLine >=0 then SendMessage( hEdit, SCI_SETFIRSTVISIBLELINE, nFirstLine, 0)
END IF
end if
PostMessage(hwnd, MSG_USER_GENERATECODE, 0, 0)
END SELECT
Expand Down Expand Up @@ -2144,7 +2138,7 @@ Function frmMain_TabCtl_SubclassProc ( _
if pDoc->IsDesigner then
nCurSel = TabCtrl_GetCurSel(pDoc->hDesignTabCtrl)
nCurSel = iif(nCurSel = 0, 1, 0)
TabCtrl_SetCurSel(pDoc->hDesignTabCtrl, nCurSel)
TabCtrl_SetCurFocus(pDoc->hDesignTabCtrl, nCurSel)
frmMain_PositionWindows(HWND_FRMMAIN)
END IF
END IF
Expand Down Expand Up @@ -2254,6 +2248,19 @@ Function frmMain_WndProc( ByVal HWnd As HWnd, _
HANDLE_MSG (HWnd, WM_DROPFILES, frmMain_OnDropFiles)
case MSG_USER_GENERATECODE
Dim pDoc As clsDocument Ptr = gTTabCtl.GetActiveDocumentPtr()
if pDoc then
if IsDesignerView(pDoc) = false then ' clicked on the code window
dim as hwnd hEdit = pDoc->hWindow(0)
dim as long nFirstLine = SendMessage( hEdit, SCI_GETFIRSTVISIBLELINE, 0, 0)
dim as long curPos = SendMessage( hEdit, SCI_GETCURRENTPOS, 0, 0)
GenerateCode(pDoc)
if curPos >=0 then SendMessage( hEdit, SCI_GOTOPOS, curPos, 0)
if nFirstLine >=0 then SendMessage( hEdit, SCI_SETFIRSTVISIBLELINE, nFirstLine, 0)
END IF
end if

case MSG_USER_SHOWAUTOCOMPLETE
return ShowAutocompleteList()

Expand Down
4 changes: 3 additions & 1 deletion src/modDeclares.bi
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ Enum
MSG_USER_TOGGLE_TVCHECKBOXES
MSG_USER_SHOWAUTOCOMPLETE
MSG_USER_APPENDEQUALSSIGN
MSG_USER_GENERATECODE
IDM_CREATE_THEME, IDM_IMPORT_THEME, IDM_DELETE_THEME
IDM_FILE, IDM_FILENEW
IDM_FILEOPEN, IDM_FILECLOSE, IDM_FILECLOSEALL, IDM_FILESAVE, IDM_FILESAVEAS
Expand Down Expand Up @@ -762,6 +763,7 @@ Type clsDocument
ptBlueStart as POINT ' Start of blue line for snapping
ptBlueEnd as POINT ' End of blue line for snapping
SnapUpWait as long ' #pixels of movement to wait until snap operation ends
wszCodeGen as CWSTR ' Code generated via

' Code document related
ProjectIndex as long ' array index into gApp.Projects
Expand Down Expand Up @@ -794,7 +796,7 @@ Type clsDocument
Declare Function FindReplace( ByVal strFindText As String, ByVal strReplaceText As String ) As Long
Declare Function InsertFile() As BOOLEAN
declare function GenerateDesignerCode() as long
declare function ParseDesignerString( ByVal hWndParent As HWnd, byref sAllText as CWSTR ) as CWSTR
declare function ParseDesignerString( ByVal hWndParent As HWnd, byref sAllText as wstring ) as CWSTR
declare function CreateDesignerString() as CWSTR
Declare Function SaveFile(ByVal bSaveAs As BOOLEAN = False) As BOOLEAN
Declare Function ApplyProperties() As Long
Expand Down
Loading

0 comments on commit c7e0d0f

Please sign in to comment.