Subversion Repositories Kolibri OS

Rev

Rev 4157 | Rev 4198 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.     use32
  2.     org     0x0
  3. ;-------------------------------------------------------------------------------
  4.     db      "MENUET01"
  5.     dd      1, main, __dataend, __memend, __stackend, 0, sys_path
  6. ;-------------------------------------------------------------------------------
  7.     include "../../../macros.inc"
  8.     include "../../../proc32.inc"
  9.     include "../../../dll.inc"
  10.     include "../../../develop/libraries/box_lib/load_lib.mac"
  11.     ;include "../../../debug.inc"
  12.  
  13.     include "DATA.INC"
  14.     include "NAME.INC"
  15.  
  16.     @use_library_mem     \
  17.             mem.Alloc,   \
  18.             mem.Free,    \
  19.             mem.ReAlloc, \
  20.             dll.Load
  21. ;================================================================================
  22. main:
  23. ; ==== Init ====
  24.     mcall   18, 7
  25.     mov     [win.psid], eax
  26.  
  27.     mcall   40, 100101b
  28.  
  29. ; ==== Load libs ====
  30.     load_libraries load_lib_start, load_lib_end
  31.  
  32. ; ==== Config LibINI ====
  33.     invoke  ini.get_int, ini_data.file_name, ini_data.settings_name, ini_data.location_name, 1
  34.     mov     [dock_items.location], eax
  35.  
  36.     invoke  ini.sections, ini_data.file_name, sections_callback
  37.  
  38. ; ==== Load colors ====
  39.     mcall   48, 3, color
  40.     or      dword[color.bg],    0x10000000
  41.     or      dword[color.frame], 0x10000000
  42.     or      dword[color.text],  0x80000000
  43.  
  44. ; ==== Config LibIMG ====
  45.     mov     dword[fi.p00], 5
  46.     mov     dword[fi.p16], buf_128
  47.     mov     dword[fi.p21], img_data.file_name
  48.  
  49.     mcall   70, fi
  50.  
  51.     mov     edx, [buf_128 + 32]
  52.     imul    edx, 10
  53.  
  54.     stdcall mem.Alloc, edx
  55.     mov     [img_data.rgb_object], eax
  56.  
  57.     mov     dword[fi.p00], 0
  58.     mov     dword[fi.p12], edx
  59.     m2m     dword[fi.p16], dword[img_data.rgb_object]
  60.     mov     dword[fi.p21], img_data.file_name
  61.  
  62.     mcall   70, fi
  63.  
  64.     cmp     ebx, 0xFFFFFFFF
  65.     je      @f
  66.  
  67.     stdcall dword[img.decode], dword[img_data.rgb_object], ebx, 0
  68.     mov     dword[img_data.object], eax
  69.  
  70.   ; === ALPHA ===
  71.     mov     edi, eax
  72.     add     edi, 8
  73.     mov     edi, [edi]
  74.     imul    edi, 128
  75.     sub     edi, 4
  76.  
  77.     add     eax, 24
  78.     mov     eax, [eax]
  79.  .setalpha:
  80.     mov     ebx, [eax + edi]
  81.     shr     ebx, 24
  82.     cmp     ebx, 0
  83.     jne     .nonalpha
  84.  
  85.     mov     ecx, [color.bg]
  86.     mov     [eax + edi], ecx
  87.  .nonalpha:
  88.     sub     edi, 4
  89.     cmp     edi, 0
  90.     jne     .setalpha
  91.  
  92.   ; === CONVERTING TO BGR
  93.     stdcall dword[img.toRGB], dword[img_data.object], dword[img_data.rgb_object]
  94.     stdcall dword[img.destroy], dword[img_data.object]
  95.  
  96. ; ==== Config window ====
  97.     mov     eax, dword[dock_items.location]
  98.     and     eax, 1b
  99.     cmp     eax, 0
  100.     je      .vert
  101.     jmp     .setshape
  102.  
  103.  .vert:
  104.     mov     byte[win.isvert], 1
  105.  
  106.  .setshape:
  107.     cmp     byte[win.isvert], 1
  108.     je      .vert_sp
  109.  
  110.  .horz_sp:
  111.     call    .HORZ_WIDTH
  112.     call    .HORZ_X
  113.     call    .HORZ_HEIGHT
  114.     cmp     dword[dock_items.location], 1
  115.     je      .settop
  116.  
  117.  .setbottom:
  118.     call    .HORZ_Y_BOTTOM
  119.     jmp     .SETDEF
  120.  
  121.  .settop:
  122.     call    .HORZ_Y_TOP
  123.     jmp     .SETDEF
  124.  
  125.  
  126.  .vert_sp:
  127.     call    .VERT_WIDTH
  128.     call    .VERT_HEIGHT
  129.     call    .VERT_Y
  130.     cmp     dword[dock_items.location], 2
  131.     je      .setleft
  132.  
  133.  .setright:
  134.     call    .VERT_X_RIGHT
  135.     jmp     .SETDEF
  136.  
  137.  .setleft:
  138.     call    .VERT_X_LEFT
  139.     jmp     .SETDEF
  140.  
  141. ;-------------------------------------------------------------------------------
  142.  .HORZ_WIDTH:
  143.     mov     eax, BUTTON_SIZE
  144.     mov     ebx, [dock_items.count]
  145.     imul    eax, ebx
  146.     add     eax, 24
  147.     dec     eax
  148.     mov     [win.width_opn], eax
  149.     mov     [win.width_hdn], eax
  150.  
  151.     ret
  152.  
  153. ;-------------------------------------------------------------------------------
  154.  .HORZ_X:
  155.     mcall   14
  156.     shr     eax, 17
  157.     mov     ecx, [win.width_opn]
  158.     shr     ecx, 1
  159.     sub     eax, ecx
  160.     mov     [win.x_opn], eax
  161.     mov     [win.x_hdn], eax
  162.  
  163.     ret
  164.  
  165. ;-------------------------------------------------------------------------------
  166.  .HORZ_HEIGHT:
  167.     mov     dword[win.height_hdn], 3
  168.     mov     dword[win.height_opn], BUTTON_SIZE
  169.  
  170.     ret
  171.  
  172. ;-------------------------------------------------------------------------------
  173.  .HORZ_Y_BOTTOM:
  174.     mcall   14
  175.     and     eax, 0xFFFF
  176.     dec     eax
  177.     mov     [win.y_hdn], eax
  178.     sub     eax, 43
  179.     mov     [win.y_opn], eax
  180.  
  181.     ret
  182.  
  183.  .HORZ_Y_TOP:
  184.     mov     dword[win.y_opn], 0
  185.     mov     dword[win.y_hdn], 0
  186.  
  187.     ret
  188.  
  189. ;-------------------------------------------------------------------------------
  190.  .VERT_WIDTH:
  191.     mov     dword[win.width_opn], BUTTON_SIZE
  192.     mov     dword[win.width_hdn], 3
  193.  
  194.     ret
  195.  
  196. ;-------------------------------------------------------------------------------
  197.  .VERT_X_LEFT:
  198.     mov     dword[win.x_opn], 0
  199.     mov     dword[win.x_hdn], 0
  200.  
  201.     ret
  202.  
  203.  .VERT_X_RIGHT:
  204.     mcall   14
  205.     and     eax, 0xFFFF0000
  206.     shr     eax, 16
  207.     mov     [win.x_hdn], eax
  208.     sub     eax, BUTTON_SIZE
  209.     mov     [win.x_opn], eax
  210.  
  211.     ret
  212.  
  213. ;-------------------------------------------------------------------------------
  214.  .VERT_HEIGHT:
  215.     mov     eax, BUTTON_SIZE
  216.     mov     ebx, [dock_items.count]
  217.     imul    eax, ebx
  218.     dec     eax
  219.     add     eax, 12
  220.     mov     [win.height_opn], eax
  221.     mov     [win.height_hdn], eax
  222.  
  223.     ret
  224.  
  225. ;-------------------------------------------------------------------------------
  226.  .VERT_Y:
  227.     mcall   14
  228.     and     eax, 0xFFFF
  229.     shr     eax, 1
  230.  
  231.     mov     esi, [win.height_opn]
  232.     shr     esi, 1
  233.     sub     eax, esi
  234.  
  235.     mov     [win.y_hdn], eax
  236.     mov     [win.y_opn], eax
  237.  
  238.     ret
  239.  
  240. ;-------------------------------------------------------------------------------
  241.  .SETDEF:
  242.     mov     eax, [win.width_hdn]
  243.     mov     [win.width], eax
  244.  
  245.     mov     eax, [win.x_hdn]
  246.     mov     [win.x], eax
  247.  
  248.     mov     eax, [win.height_hdn]
  249.     mov     [win.height], eax
  250.  
  251.     mov     eax, [win.y_hdn]
  252.     mov     [win.y], eax
  253.  
  254. ;-------------------------------------------------------------------------------
  255. ; ==== START ====
  256.     mcall   9, win.procinfo, -1
  257.     mov     ecx, [win.procinfo + 30]
  258.     mcall   18, 21
  259.     and     eax, 0xFFFF
  260.     mov     [win.sid], eax
  261.  
  262.     call    main_loop
  263. ;-------------------------------------------------------------------------------
  264. exit:
  265.     stdcall mem.Free, [img_data.rgb_object]
  266.     mcall   18, 2, [nwin.sid]
  267.     mcall   -1
  268. ;-------------------------------------------------------------------------------
  269. main_loop:
  270.     mcall   10
  271.  
  272.     cmp     eax, EV_REDRAW
  273.     je      event_redraw
  274.  
  275.     cmp     eax, EV_BUTTON
  276.     je      event_button
  277.  
  278.     cmp     eax, EV_MOUSE
  279.     je      event_mouse
  280.  
  281.     jmp     main_loop
  282. ;-------------------------------------------------------------------------------
  283. event_redraw:
  284.     mcall   12, 1
  285.  
  286.     mov     esi, [color.bg]
  287.     or      esi, 0x01000000
  288.     mcall   0, <[win.x], [win.width]>, <[win.y], [win.height]>, [color.bg], , [color.frame]
  289.  
  290.     mov     edi, 0
  291.   @@:
  292.     cmp     edi, [dock_items.count]
  293.     je      @f
  294.  
  295.     push    edi
  296.     mov     eax, 8
  297.     mov     edx, 0x60000002
  298.     mov     esi, [color.bg]
  299.     imul    edi, BUTTON_SIZE
  300.     add     edi, 12
  301.     shl     edi, 16
  302.     add     edi, BUTTON_SIZE
  303.     cmp     byte[win.isvert], 1
  304.     je      .vert_btn
  305.     mcall   , edi, <0, BUTTON_SIZE>
  306.     jmp     .endbtn
  307.  .vert_btn:
  308.     sub     edi, 12 shl 16
  309.     mcall   , <0, BUTTON_SIZE>, edi
  310.  .endbtn:
  311.     pop     edi
  312.  
  313.     cmp     byte[dock_items.separator + edi], 1
  314.     jne     .end_separator
  315.  
  316.  .draw_separator:
  317.     push    ebx
  318.     push    ecx
  319.  
  320.     mov     eax, 13
  321.     mov     ebx, edi
  322.     imul    ebx, BUTTON_SIZE
  323.     add     ebx, BUTTON_SIZE
  324.     add     ebx, 12
  325.     dec     ebx
  326.     shl     ebx, 16
  327.     add     ebx, 1
  328.  
  329.     cmp     byte[win.isvert], 1
  330.     je      .vert_draw_sep
  331.     mcall   , , <4, 36>, [color.frame]
  332.     jmp     .end_inner_sep
  333.  .vert_draw_sep:
  334.     sub     ebx, 12 shl 16
  335.     mov     ecx, ebx
  336.     mcall   , <4, 36>, , [color.frame]
  337.  .end_inner_sep:
  338.     pop     ecx
  339.     pop     ebx
  340.  .end_separator:
  341.  
  342.     cmp     byte[win.isvert], 1
  343.     je      .vert_dig
  344.     mov     edx, ebx
  345.     and     edx, 0xFFFF0000
  346.     add     edx, 0x00060006
  347.     jmp     .digend
  348.  .vert_dig:
  349.     mov     edx, ecx
  350.     and     edx, 0xFFFF0000
  351.     shr     edx, 16
  352.     add     edx, 0x00060006
  353.  .digend:
  354.  
  355.     imul    ebx, edi, 4
  356.     add     ebx, dock_items.icon
  357.     mov     ebx, [ebx]
  358.     imul    ebx, ICON_SIZE_BGR
  359.     add     ebx, [img_data.rgb_object]
  360.  
  361.     mcall   7, , <32, 32>
  362.  
  363.     inc     edi
  364.     jmp     @b
  365.   @@:
  366.  
  367.  ; ==== DRAW SETTINGS ====
  368.     cmp     byte[win.isvert], 1
  369.     je      .cfg_vert
  370.  
  371.     mov     ebx, [win.width]
  372.     sub     ebx, 10
  373.     shl     ebx, 16
  374.     add     ebx, 8
  375.     mcall   8, , <2, BUTTON_SIZE - 4>, 0x60000003
  376.     jmp     @f
  377.  
  378.  .cfg_vert:
  379.     mov     ecx, [win.height]
  380.     sub     ecx, 10
  381.     shl     ecx, 16
  382.     add     ecx, 8
  383.     mcall   8, <2, BUTTON_SIZE - 4>, , 0x60000003
  384.   @@:
  385.  
  386.  ; ==== cfg image ====
  387.     mov     edi, 0
  388.   @@:
  389.     cmp     byte[set_img + edi], 0
  390.     je      .notdraw
  391.  
  392.     mov     eax, edi
  393.     mov     edx, 0
  394.     mov     ebx, 6
  395.     div     ebx
  396.     mov     ebx, edx
  397.     mov     ecx, eax
  398.  
  399.     add     ebx, [win.width]
  400.     cmp     byte[win.isvert], 0
  401.     je      .cfg_hoz
  402.     sub     ebx, [win.width]
  403.     add     ebx, [win.height]
  404.  .cfg_hoz:
  405.     sub     ebx, 10
  406.     add     ecx, 18
  407.  
  408.     cmp     byte[win.isvert], 0
  409.     je      .cfg_draw
  410.  
  411.     xchg    ebx, ecx
  412.  
  413.   .cfg_draw:
  414.     mcall   1, , , [color.frame]
  415.  
  416.  .notdraw:
  417.     inc     edi
  418.     cmp     edi, 36
  419.     jne     @b
  420.  
  421.     mcall   12, 2
  422.  
  423.     jmp     main_loop
  424. ;-------------------------------------------------------------------------------
  425. event_button:
  426.     mcall   17
  427.  
  428.     cmp     ah, 1
  429.     je      .button_close
  430.  
  431.     cmp     ah, 2
  432.     je      .button_dock
  433.  
  434.     cmp     ah, 3
  435.     je      .button_cfg
  436.  
  437.     jmp     @f
  438.  
  439.  .button_close:
  440.     jmp     exit
  441.  
  442.  .button_dock:
  443.     mov     edi, [win.button_index]
  444.     imul    edi, 256
  445.  
  446.     mov     dword[fi.p00], 7
  447.  
  448.     mov     esi, edi
  449.     add     esi, dock_items.path
  450.     mov     dword[fi.p21], esi
  451.  
  452.     mov     esi, edi
  453.     add     esi, dock_items.param
  454.     mov     dword[fi.p08], esi
  455.  
  456.     mcall   70, fi
  457.  
  458.     mov     ecx, eax
  459.     mcall   18, 21
  460.     and     eax, 0xFFFF
  461.     mov     [win.psid], eax
  462.  
  463.     jmp     wnd_hide
  464.  
  465.  .button_cfg:
  466.     mov     dword[fi.p00], 7
  467.     mov     dword[fi.p21], cfg_app
  468.     mcall   70, fi
  469.  
  470.     mov     ecx, eax
  471.     mcall   18, 21
  472.     and     eax, 0xFFFF
  473.     mov     [win.psid], eax
  474.  
  475.     jmp     wnd_hide
  476.  
  477.   @@:
  478.     jmp     main_loop
  479. ;-------------------------------------------------------------------------------
  480. event_mouse:
  481.     mcall   37, 1
  482.     mov     edi, eax
  483.     mov     esi, eax
  484.     shr     edi, 16
  485.     and     esi, 0xFFFF
  486.  
  487.     cmp     edi, 0
  488.     jl      wnd_hide
  489.     dec     edi
  490.     cmp     edi, [win.width]
  491.     jg      wnd_hide
  492.     cmp     esi, 0
  493.     jl      wnd_hide
  494.     dec     esi
  495.     cmp     esi, [win.height]
  496.     jg      wnd_hide
  497.  
  498.     mov     eax, [dock_items.location]
  499.     and     eax, 1b
  500.     cmp     eax, 1
  501.     jne     .vert
  502.     mov     eax, edi
  503.     jmp     .nxt
  504.  
  505.  .vert:
  506.     mov     eax, esi
  507.     add     eax, 12
  508.  
  509.  .nxt:
  510.     sub     eax, 12
  511.     mov     edx, 0
  512.     mov     ebx, BUTTON_SIZE
  513.     div     ebx
  514.  
  515.     cmp     eax, [dock_items.count]
  516.     jge     .set0
  517.     jmp     .nxtcmp
  518.  
  519.  .set0:
  520.     mov     eax, 100
  521.  
  522.  .nxtcmp:
  523.     cmp     [win.button_index], eax
  524.     je      .nxt2
  525.  
  526.     mov     [win.button_index], eax
  527.  
  528.  .nxt2:
  529.     mov     eax, [win.button_index]
  530.     imul    eax, BUTTON_SIZE
  531.     cmp     byte[win.isvert], 1
  532.     je      .vert_name
  533.     add     eax, [win.x]
  534.     mov     [nwin.x], eax
  535.     mov     byte[nwin.change_shape], 1
  536.     mcall   13, <0, [win.width]>, <[win.height], 1>, [color.frame]
  537.     jmp     .vert_end
  538.  .vert_name:
  539.     add     eax, [win.y]
  540.     add     eax, 14
  541.     mov     [nwin.y], eax
  542.     mov     byte[nwin.change_shape], 1
  543.     mcall   13, <[win.width], 1>, <0, [win.height]>, [color.frame]
  544.  .vert_end:
  545.  
  546.     cmp     byte[win.state], 1
  547.     je      main_loop
  548.  
  549.     mov     edx, esp
  550.     add     edx, 512
  551.     mcall   51, 1, n_main
  552.  
  553.     mov     eax, 18
  554.  
  555.     mcall   , 7
  556.     mov     [win.psid], eax
  557.  
  558.     mcall   18, 3, [win.sid]
  559.  
  560.     mov     byte[win.state], 1
  561.  
  562.     mov     eax, [win.width_opn]
  563.     mov     [win.width], eax
  564.  
  565.     mov     eax, [win.x_opn]
  566.     mov     [win.x], eax
  567.  
  568.     mov     eax, [win.height_opn]
  569.     mov     [win.height], eax
  570.  
  571.     mov     eax, [win.y_opn]
  572.     mov     [win.y], eax
  573.  
  574.     mcall   67, [win.x], [win.y], [win.width], [win.height]
  575.  
  576.     jmp     event_redraw
  577.  
  578. ;-------------------------------------------------------------------------------
  579. wnd_hide:
  580.     cmp     byte[win.state], 0
  581.     je      main_loop
  582.  
  583.     mov     byte[nwin.close], 1
  584.  
  585.     mcall   18, 3, [win.psid]
  586.  
  587.     mov     byte[win.state], 0
  588.     mov     byte[win.button_index], -1
  589.  
  590.     mov     eax, [win.width_hdn]
  591.     mov     [win.width], eax
  592.  
  593.     mov     eax, [win.x_hdn]
  594.     mov     [win.x], eax
  595.  
  596.     mov     eax, [win.height_hdn]
  597.     mov     [win.height], eax
  598.  
  599.     mov     eax, [win.y_hdn]
  600.     mov     [win.y], eax
  601.  
  602.     mcall   67, [win.x], [win.y], [win.width], [win.height]
  603.  
  604.     jmp     event_redraw
  605. ;-------------------------------------------------------------------------------
  606. proc sections_callback, _file_name, _section_name
  607.     mov     eax, [_section_name]
  608.     cmp     byte[eax], '@'
  609.     jne     @f
  610.  
  611.     dec     dword[dock_items.count]
  612.     jmp     .endproc
  613.  
  614.   @@:
  615.     ; ==== GET NAME ====
  616.     mov     ebx, [dock_items.count]
  617.     imul    ebx, 16
  618.     add     ebx, dock_items.name
  619.  
  620.     mov     eax, [_section_name]
  621.  
  622.     mov     edi, 0
  623.   @@:
  624.     mov     cl, byte[eax]
  625.     mov     byte[ebx + edi], cl
  626.  
  627.     inc     eax
  628.     inc     edi
  629.     cmp     edi, 10
  630.     jne     @b
  631.  
  632.   ; ==== GET PATH ====
  633.     mov     ebx, [dock_items.count]
  634.     imul    ebx, 256
  635.     add     ebx, dock_items.path
  636.  
  637.     invoke  ini.get_str, [_file_name], [_section_name], ini_data.path_name, ebx, 256, 0
  638.  
  639.   ; === GET  PARAM ===
  640.     mov     ebx, [dock_items.count]
  641.     imul    ebx, 256
  642.     add     ebx, dock_items.param
  643.  
  644.     invoke  ini.get_str, [_file_name], [_section_name], ini_data.param_name, ebx, 256, 0
  645.  
  646.   ; ==== GET ICON ====
  647.     invoke  ini.get_int, [_file_name], [_section_name], ini_data.icon_name, 0
  648.  
  649.     mov     ebx, [dock_items.count]
  650.     imul    ebx, 4
  651.     mov     [dock_items.icon + ebx], eax
  652.  
  653.   ; ==== GET SEPARATOR ====
  654.     invoke  ini.get_int, [_file_name], [_section_name], ini_data.separator_name, 0
  655.  
  656.     mov     ebx, [dock_items.count]
  657.     mov     byte[dock_items.separator + ebx], al
  658.  
  659.   ; ====== END =======
  660.  .endproc:
  661.     mov     eax, 1
  662.     inc     dword[dock_items.count]
  663.     ret
  664. endp
  665. ;-------------------------------------------------------------------------------
  666.     include "MEMORY.INC"