; _____________________________________________________________________________________________
;|                                                                                             |
;| Fresh.asm                                                                                   |
;|                                                                                             |
;| This file is the main file of:                                                              |
;|                                                                                             |
;| ..::Fresh::.. - assembler RAD IDE with built-in FASM assembler.                             |
;|                                                                                             |
;| Credits:                                                                                    |
;|   Tomasz Grysztar (aka Privalov) - for excelent work with FASM - the base for Fresh.        |
;|                                                                                             |
;| The people that contributed to the project:                                                 |
;|                                                                                             |
;|    John Found                                                                               |
;|    Fredrik Klasson (aka scientica)                                                          |
;|    Tommy Lillehagen                                                                         |
;|    Mateusz Tymek (aka decard)                                                               |
;|    Victor Loh (aka roticv)                                                                  |
;|    Yunus Sina Gulsen (aka VeSCeRa)                                                          |
;|    Pelaillo                                                                                 |
;|                                                                                             |
;|    Tomasz Grysztar - FASM compiler and AsmEdit control.                                     |
;|                                                                                             |
;| Contact the authors: http://board.flatassembler.net/                                        |
;| Fresh IDE main site: http://fresh.flatassembler.net/                                        |
;| FASM main site:      http://www.flatassembler.net/                                          |
;|                                                                                             |
;|_____________________________________________________________________________________________|
;

include '%lib%/freshlib.inc'

@BinaryType GUI, default

uses kernel32, user32, gdi32, comctl32, comdlg32, ole32

LIB_MODE  equ OLD


if TargetOS eq Win32
  stack 0x10020           ; 64K stack for HtmlHelp :/
end if

options.DebugMode = 0
options.ShowUserMessages = 0
options.ShowSkipped = 0
options.FastEnter = 0
options.CheckArguments = 0
options.ShowSizes = 0
options.DisableMMX = 0

include 'version.inc'

include '../include/libs/msgutils.inc'
include '../include/libs/gui.inc'
include '../include/libs/tform.inc'
include '../include/libs/templates.inc'
include '../include/libs/TDataGrid.inc'
include '../include/libs/buttonedit.inc'

include '../include/libs/asmedit/asmedit.inc'
include 'lister.inc'
include 'dumper.inc'
include 'designtime.inc'
include 'virtfiles.inc'
include 'resourceid.inc'
include 'projmanager.inc'
include 'Controls.inc'
include 'editorhost.inc'
include 'msgwindow.inc'
include 'propgrid.inc'
include 'MainWindow.inc'
include 'fasm/Version.inc'
include 'xref.inc'
include 'LabelsList.inc'
include 'debug.inc'
include 'debugger.inc'
include 'dbgserver.inc'
include 'propeditor.inc'
include 'filemanager.inc'
include 'FormEditor.inc'
include 'SizerClass.inc'


;;<OS INDEPENDENT SOURCES> all included files should resides here
include "%lib%/freshlib.asm"
include "%lib%/graphics/rectangles.asm"

include "BrowseHistory.asm"

include "help_server/server_main.asm"
include "help_server/requests.asm"
include "help_server/file_processing.asm"

include "Unroll.asm"

;<OS DEPENDENT SOURCES> - at the end this list should be empty.

  include 'strutils.asm'        ; some Win32 string utils, not to be ported to other OSes.
                                ; they will naturally dissaper when the whole GUI is portable.

  include 'frmConvertANSI.frm'
  include 'encodings.asm'

  include '../include/libs/asmedit/asmedit.asm'
  include '../include/libs/asmedit/syntax.asm'
  include "asmedit_utils.asm"

  include 'errors.asm'

  include 'LabelsList.asm'
  include 'fasm.asm'

  include 'virtfiles.asm'       ; almost OS independent. Has only one SendMessageA invoke.

  include 'LabelProperties.frm'
  include 'LabelsExplorer.frm'
  include 'LabelInfo.frm'

  include '../include/libs/tform.asm'
  include '../include/libs/templates.asm'

  include '../include/libs/giflib.asm'  ; this is the old version of giflib.

  include 'Controls.asm'
  include 'SizerClass.asm'

  include '../include/libs/TDataGrid.asm'

  include 'MainWindow.asm'

  include 'ActionEvents.asm'
  include 'actNewFile.asm'
  include 'opendialog.asm'

  include 'propeditor.asm'

  include 'projmanager.asm'

  include 'msgwindow.asm'

  include 'palette.asm'


  include '../include/libs/SplitGrid2.asm'
  include '../include/libs/buttonedit.asm'
  include 'propgrid.asm'

  include 'progresswnd.frm'

  include 'findreplace.asm'
  include 'editorhost.asm'
  include 'sourceeditor.asm'
  include 'CCList.asm'
  include 'PAHint.asm'
  include 'EmbededHelp.asm'

  include 'fileutils.asm'
  include 'mrulist.asm'

  include 'IDEparams.asm'

  include 'EditPath.frm'

  include 'IDEOptions.frm'
  include 'EditPathsOptions.frm'
  include 'IDEBehaviourOptions.frm'
  include 'EditorColors.frm'

  include 'formsDT.asm'
  include 'help.asm'

  include 'lister.asm'
  include 'dumper.asm'

  include 'dbgserver.asm'
  include 'debugger.asm'
  include 'debug.asm'

  include 'dialogs.asm'
  include 'FormEditor.asm'

  include 'filemanager.asm'

  include '../include/libs/msgutils.asm'
  include '../include/libs/gui.asm'

  include '../include/libs/scrollbars.asm'

;  include 'EDITOptions.frm'
;  include 'EditorBehaviour.frm'

  include 'frmStyleEditor.frm'
  include 'ProjectOptions.frm'
  include 'templates.frm'
  include 'ExternalOptions.frm'

  include 'HelpFileList.frm'

; Common initialized globals

; Standard class names
  cEditClassName          du  'EDIT', 0
  cStaticClassName        du  'STATIC', 0
  cButtonClassName        du  'BUTTON', 0
  cComboClassName         du  'COMBOBOX', 0
  cScrollClassName        du  'SCROLLBAR', 0
  cListboxClassName       du  'LISTBOX', 0

; some CommCtrl class names

iglobal
  cTabClassName         du  TABCONTROL_CLASS, 0
  cTreeViewClassName    du  TREEVIEW_CLASS, 0
  cStatusBarClassName   du  STATUS_CLASS, 0
  cProgressbarClassName du  PROGRESS_CLASS, 0
  cListviewClassName    du  LISTVIEW_CLASS, 0
  cTooltipClassName     du  TOOLTIPS_CLASS, 0

  cKernelLibName        du  "kernel32.dll", 0
  cWineGetFilename      db  "wine_get_unix_file_name", 0
endg


uglobal
  hInstance       dd ?  ; Instance handle for common use.
  ComCtrlsFlags   INITCOMMONCONTROLSEX
  procLinuxPath   dd ?

  hAccelerators   dd ?

endg



start:

        mov     [ResizeIt], StrategyAgressive

; Main init sequence
        invoke  GetModuleHandleW,0
        mov     [hInstance],eax

; Init ALL common controls
        mov     [ComCtrlsFlags.dwSize], sizeof.INITCOMMONCONTROLSEX
        mov     [ComCtrlsFlags.dwICC], $1fff
        invoke  InitCommonControlsEx, ComCtrlsFlags

; check for wine
        invoke  LoadLibraryW, cKernelLibName
        invoke  GetProcAddress, eax, cWineGetFilename
        mov     [procLinuxPath], eax

; call all "initialize" procedures in the included modules...
        InitializeAll

; Accelerator table creating
        invoke  CreateAcceleratorTableW, Accelerators, [Accelerators.Count]
        mov     [hAccelerators], eax

        stdcall InitMainWindow

        stdcall ParseCommandLine ; Command line parameters.
        stdcall StartHelpServer

; Main message loop
Run:
        call    ProcessMessages
        jc      .terminate

        invoke  SendMessageW, [hMainForm], FM_ONIDLE, 0, 0
        invoke  WaitMessage
        jmp     Run


.terminate:
        push    eax

        stdcall StopHelpServer

        FinalizeAll
        stdcall TerminateAll  ; exit code from the stack.



section '.res' resource from 'images\freshnew.res' data readable
