main.tcl 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ###########################################################
  2. # Name: main.tcl
  3. # Author: Daniele Bonini (posta@elettronica.lol)
  4. # Date: 25/11/2023
  5. # Desc: Main form of RadXIDE.
  6. # License: MIT.
  7. ###########################################################
  8. namespace eval main {
  9. # ________________________ Main _create _________________________ #
  10. proc _create {} {
  11. # Creates the main form of radxide.
  12. namespace upvar ::radxide dan dan
  13. ::radxide::win::makeMainWindow $dan(WIN).fra $dan(TITLE) $dan(BG) $dan(FG)
  14. }
  15. # ________________________ ShowHeader _________________________ #
  16. proc updateAppTitle {} {
  17. # Displays a file's name and modification flag (*) in alited's title.
  18. namespace upvar ::radxide dan dan project project
  19. #tk_messageBox -title $dan(TITLE) -icon error -message $project(CUR_FILE_PATH)
  20. set f "<no file>"
  21. if {$project(CUR_FILE_PATH) ne ""} {
  22. set f [string range $project(CUR_FILE_PATH) [expr [string length $dan(WORKDIR)]+1] end]
  23. }
  24. #tk_messageBox -title $dan(TITLE) -icon error -message $f
  25. set t $dan(TITLE)
  26. set templ $dan(TITLE_TEMPL)
  27. set ttl [string map [list %f $f %t $t] $templ]
  28. wm title $dan(WIN) [string trim $ttl]
  29. }
  30. # ________________________ Main _run _________________________ #
  31. proc _run {} {
  32. # Runs the alited, displaying its main form with attributes
  33. # 'modal', 'not closed by Esc', 'decorated with Contract/Expand buttons',
  34. # 'minimal sizes' and 'saved geometry'.
  35. #
  36. # After closing the alited, saves its settings (geometry etc.).
  37. namespace upvar ::radxide dan dan
  38. wm attributes $dan(WIN) -topmost
  39. updateAppTitle
  40. wm iconphoto $dan(WIN) $dan(ICONI)
  41. wm resizable $dan(WIN) 0 0
  42. ::radxide::win::centerWin $dan(WIN) $dan(WIDTH) $dan(HEIGHT)
  43. wm minsize $dan(WIN) $dan(WIDTH) $dan(HEIGHT)
  44. wm attributes $dan(WIN) -fullscreen 0
  45. wm protocol . WM_DELETE_WINDOW { radxide::quit }
  46. catch {focus -force $dan(TEXT)}
  47. # Modal
  48. set var 1
  49. ::radxide::win::waitWinVar $dan(WIN) $var 1
  50. # --
  51. destroy $dan(WIN)
  52. update
  53. return 1
  54. }
  55. }
  56. # _________________________________ EOF _________________________________ #