Subversion Repositories Kolibri OS

Rev

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