Subversion Repositories Kolibri OS

Rev

Rev 4195 | Rev 4234 | 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.     mov     [win.height_opn], eax
  220.     mov     [win.height_hdn], eax
  221.  
  222.     ret
  223.  
  224. ;-------------------------------------------------------------------------------
  225.  .VERT_Y:
  226.     mcall   14
  227.     and     eax, 0xFFFF
  228.     shr     eax, 1
  229.  
  230.     mov     esi, [win.height_opn]
  231.     shr     esi, 1
  232.     sub     eax, esi
  233.  
  234.     mov     [win.y_hdn], eax
  235.     mov     [win.y_opn], eax
  236.  
  237.     ret
  238.  
  239. ;-------------------------------------------------------------------------------
  240.  .SETDEF:
  241.     mov     eax, [win.width_hdn]
  242.     mov     [win.width], eax
  243.  
  244.     mov     eax, [win.x_hdn]
  245.     mov     [win.x], eax
  246.  
  247.     mov     eax, [win.height_hdn]
  248.     mov     [win.height], eax
  249.  
  250.     mov     eax, [win.y_hdn]
  251.     mov     [win.y], eax
  252.  
  253. ;-------------------------------------------------------------------------------
  254. ; ==== START ====
  255.     mcall   9, win.procinfo, -1
  256.     mov     ecx, [win.procinfo + 30]
  257.     mcall   18, 21
  258.     and     eax, 0xFFFF
  259.     mov     [win.sid], eax
  260.  
  261.     call    main_loop
  262. ;-------------------------------------------------------------------------------
  263. exit:
  264.     stdcall mem.Free, [img_data.rgb_object]
  265.     mcall   18, 2, [nwin.sid]
  266.     mcall   -1
  267. ;-------------------------------------------------------------------------------
  268. main_loop:
  269.     mcall   10
  270.  
  271.     cmp     eax, EV_REDRAW
  272.     je      event_redraw
  273.  
  274.     cmp     eax, EV_BUTTON
  275.     je      event_button
  276.  
  277.     cmp     eax, EV_MOUSE
  278.     je      event_mouse
  279.  
  280.     jmp     main_loop
  281. ;-------------------------------------------------------------------------------
  282. event_redraw:
  283.     call    DRAW_WINDOW
  284.     jmp     main_loop
  285. ;-------------------------------------------------------------------------------
  286. DRAW_WINDOW:
  287.     mcall   12, 1
  288.  
  289.     mov     esi, [color.bg]
  290.     or      esi, 0x01000000
  291.     mcall   0, <[win.x], [win.width]>, <[win.y], [win.height]>, [color.bg], , [color.frame]
  292.  
  293.     mov     edi, 0
  294.   @@:
  295.     cmp     edi, [dock_items.count]
  296.     je      @f
  297.  
  298.     push    edi
  299.     mov     eax, 8
  300.     mov     edx, 0x60000002
  301.     mov     esi, [color.bg]
  302.     imul    edi, BUTTON_SIZE
  303.     add     edi, 12
  304.     shl     edi, 16
  305.     add     edi, BUTTON_SIZE
  306.     cmp     byte[win.isvert], 1
  307.     je      .vert_btn
  308.     mcall   , edi, <0, BUTTON_SIZE>
  309.     jmp     .endbtn
  310.  .vert_btn:
  311.     sub     edi, 12 shl 16
  312.     mcall   , <0, BUTTON_SIZE>, edi
  313.  .endbtn:
  314.     pop     edi
  315.  
  316.     cmp     byte[dock_items.separator + edi], 1
  317.     jne     .end_separator
  318.  
  319.  .draw_separator:
  320.     push    ebx
  321.     push    ecx
  322.  
  323.     mov     eax, 13
  324.     mov     ebx, edi
  325.     imul    ebx, BUTTON_SIZE
  326.     add     ebx, BUTTON_SIZE
  327.     add     ebx, 12
  328.     dec     ebx
  329.     shl     ebx, 16
  330.     add     ebx, 2
  331.  
  332.     cmp     byte[win.isvert], 1
  333.     je      .vert_draw_sep
  334.     mcall   , , <4,  36>, [color.frame]
  335.     jmp     .end_inner_sep
  336.  .vert_draw_sep:
  337.     sub     ebx, 12 shl 16
  338.     mov     ecx, ebx
  339.     mcall   , <4, 36>, , [color.frame]
  340.  .end_inner_sep:
  341.     pop     ecx
  342.     pop     ebx
  343.  .end_separator:
  344.  
  345.     cmp     byte[win.isvert], 1
  346.     je      .vert_dig
  347.     mov     edx, ebx
  348.     and     edx, 0xFFFF0000
  349.     add     edx, 0x00060006
  350.     jmp     .digend
  351.  .vert_dig:
  352.     mov     edx, ecx
  353.     and     edx, 0xFFFF0000
  354.     shr     edx, 16
  355.     add     edx, 0x00060006
  356.  .digend:
  357.  
  358.     imul    ebx, edi, 4
  359.     add     ebx, dock_items.icon
  360.     mov     ebx, [ebx]
  361.     imul    ebx, ICON_SIZE_BGR
  362.     add     ebx, [img_data.rgb_object]
  363.  
  364.     mcall   7, , <32, 32>
  365.  
  366.     inc     edi
  367.     jmp     @b
  368.   @@:
  369.  
  370.     mcall   12, 2
  371.  
  372.     ret
  373. ;-------------------------------------------------------------------------------
  374. event_button:
  375.     mcall   17
  376.  
  377.     cmp     ah, 1
  378.     je      .button_close
  379.  
  380.     cmp     ah, 2
  381.     je      .button_dock
  382.  
  383.     jmp     @f
  384.  
  385.  .button_close:
  386.     jmp     exit
  387.  
  388.  .button_dock:
  389.     mov     edi, [win.button_index]
  390.     imul    edi, 256
  391.  
  392.     mov     dword[fi.p00], 7
  393.  
  394.     mov     esi, edi
  395.     add     esi, dock_items.path
  396.     mov     dword[fi.p21], esi
  397.  
  398.     mov     esi, edi
  399.     add     esi, dock_items.param
  400.     mov     dword[fi.p08], esi
  401.  
  402.     mcall   70, fi
  403.  
  404.     mov     ecx, eax
  405.     mcall   18, 21
  406.     and     eax, 0xFFFF
  407.     mov     [win.psid], eax
  408.  
  409.     jmp     wnd_hide
  410.  
  411.   @@:
  412.     jmp     main_loop
  413. ;-------------------------------------------------------------------------------
  414. event_mouse:
  415.   ; ==== IS MOUSE INNER ====
  416.     mcall   37, 1
  417.     mov     edi, eax
  418.     mov     esi, eax
  419.     shr     edi, 16
  420.     and     esi, 0xFFFF
  421.  
  422.     cmp     edi, 0
  423.     jl      wnd_hide
  424.     dec     edi
  425.     cmp     edi, [win.width]
  426.     jg      wnd_hide
  427.     cmp     esi, 0
  428.     jl      wnd_hide
  429.     dec     esi
  430.     cmp     esi, [win.height]
  431.     jg      wnd_hide
  432.  
  433.   ; ==== COUNT INDEX ====
  434.  
  435.     mov     eax, [dock_items.location]
  436.     and     eax, 1b
  437.     cmp     eax, 1
  438.     jne     .vert
  439.     mov     eax, edi
  440.     jmp     .nxt
  441.  
  442.  .vert:
  443.     mov     eax, esi
  444.     add     eax, 12
  445.  
  446.  .nxt:
  447.     sub     eax, 12
  448.     mov     edx, 0
  449.     mov     ebx, BUTTON_SIZE
  450.     div     ebx
  451.  
  452.     cmp     eax, [dock_items.count]
  453.     jge     .set0
  454.     jmp     .nxtcmp
  455.  
  456.  .set0:
  457.     mov     eax, 100
  458.  
  459.  .nxtcmp:
  460.     cmp     [win.button_index], eax
  461.     je      .nxt2
  462.  
  463.     push    dword[win.button_index]
  464.     pop     dword[win.prev_index]
  465.  
  466.     mov     [win.button_index], eax
  467.  
  468.  ; ==== DRAW SELECTION ====
  469.     call    DRAW_SELECTION
  470.  
  471.  .nxt2:
  472.     mov     eax, [win.button_index]
  473.     imul    eax, BUTTON_SIZE
  474.     cmp     byte[win.isvert], 1
  475.     je      .vert_name
  476.     add     eax, [win.x]
  477.     mov     [nwin.x], eax
  478.     mov     byte[nwin.change_shape], 1
  479.     mcall   13, <0, [win.width]>, <[win.height], 1>, [color.frame]
  480.     jmp     .vert_end
  481.  .vert_name:
  482.     add     eax, [win.y]
  483.     add     eax, 14
  484.     mov     [nwin.y], eax
  485.     mov     byte[nwin.change_shape], 1
  486.     mcall   13, <[win.width], 1>, <0, [win.height]>, [color.frame]
  487.  .vert_end:
  488.  
  489.  ; ==== OPEN/CLOSE WINDOW ====
  490.     cmp     byte[win.state], 1
  491.     je      main_loop
  492.  
  493.     mov     edx, esp
  494.     add     edx, 512
  495.     mcall   51, 1, n_main
  496.  
  497.     mov     eax, 18
  498.  
  499.     mcall   , 7
  500.     mov     [win.psid], eax
  501.  
  502.     mcall   18, 3, [win.sid]
  503.  
  504.     mov     byte[win.state], 1
  505.  
  506.     mov     eax, [win.width_opn]
  507.     mov     [win.width], eax
  508.  
  509.     mov     eax, [win.x_opn]
  510.     mov     [win.x], eax
  511.  
  512.     mov     eax, [win.height_opn]
  513.     mov     [win.height], eax
  514.  
  515.     mov     eax, [win.y_opn]
  516.     mov     [win.y], eax
  517.  
  518.     mcall   67, [win.x], [win.y], [win.width], [win.height]
  519.  
  520.     call    DRAW_WINDOW
  521.     call    DRAW_SELECTION
  522.     jmp     main_loop
  523.  
  524. ;-------------------------------------------------------------------------------
  525. wnd_hide:
  526.     cmp     byte[win.state], 0
  527.     je      main_loop
  528.  
  529.     mov     byte[nwin.close], 1
  530.  
  531.     mcall   18, 3, [win.psid]
  532.  
  533.     mov     byte[win.state], 0
  534.     mov     byte[win.button_index], -1
  535.  
  536.     mov     eax, [win.width_hdn]
  537.     mov     [win.width], eax
  538.  
  539.     mov     eax, [win.x_hdn]
  540.     mov     [win.x], eax
  541.  
  542.     mov     eax, [win.height_hdn]
  543.     mov     [win.height], eax
  544.  
  545.     mov     eax, [win.y_hdn]
  546.     mov     [win.y], eax
  547.  
  548.     mcall   67, [win.x], [win.y], [win.width], [win.height]
  549.  
  550.     call    DRAW_WINDOW
  551.     jmp     main_loop
  552. ;-------------------------------------------------------------------------------
  553. DRAW_SELECTION:
  554.     mov     ebx, [win.prev_index]
  555.     imul    ebx, BUTTON_SIZE
  556.     add     ebx, 14
  557.     shl     ebx, 16
  558.     add     ebx, 40
  559.     mov     ecx, 0x00020028
  560.  
  561.     cmp     byte[win.isvert], 1
  562.     jne     @f
  563.     xchg    ebx, ecx
  564.     sub     ecx, 0x000C0000
  565.   @@:
  566.  
  567.     mcall   13, , , [color.bg]
  568.  
  569.     mov     edx, ebx
  570.     shr     ecx, 16
  571.     mov     dx, cx
  572.     add     edx, 0x00040004
  573.  
  574.     mov     ebx, [win.prev_index]
  575.     imul    ebx, 4
  576.     add     ebx, dock_items.icon
  577.     mov     ebx, [ebx]
  578.     imul    ebx, ICON_SIZE_BGR
  579.     add     ebx, [img_data.rgb_object]
  580.  
  581.     mcall   7, , <32, 32>
  582.  
  583.     mov     ebx, [win.button_index]
  584.     imul    ebx, BUTTON_SIZE
  585.     add     ebx, 14
  586.     shl     ebx, 16
  587.     add     ebx, 40
  588.     mov     ecx, 0x00020028
  589.  
  590.     cmp     byte[win.isvert], 1
  591.     jne     @f
  592.     xchg    ebx, ecx
  593.     sub     ecx, 0x000C0000
  594.   @@:
  595.  
  596.     mcall   13, , , [color.bt]
  597.  
  598.     mov     edx, ebx
  599.     shr     ecx, 16
  600.     mov     dx, cx
  601.     add     edx, 0x00040004
  602.  
  603.     mov     ecx, [win.button_index]
  604.     imul    ecx, 4
  605.     add     ecx, dock_items.icon
  606.     mov     ecx, [ecx]
  607.     imul    ecx, ICON_SIZE_BGR
  608.     add     ecx, [img_data.rgb_object]
  609.  
  610.     mov     ebx, sel_img
  611.  
  612.     mov     edi, 0
  613.   @@:
  614.     mov     al, byte[ecx + 2]
  615.     shl     eax, 8
  616.     mov     al, byte[ecx + 1]
  617.     shl     eax, 8
  618.     mov     al, byte[ecx + 0]
  619.  
  620.     or      eax, 0x10000000
  621.     cmp     eax, [color.bg]
  622.     jne     .notbg
  623.     mov     eax, [color.bt]
  624.  .notbg:
  625.  
  626.     mov     byte[ebx + 0], al
  627.     shr     eax, 8
  628.     mov     byte[ebx + 1], al
  629.     shr     eax, 8
  630.     mov     byte[ebx + 2], al
  631.  
  632.     add     ebx, 3
  633.     add     ecx, 3
  634.  
  635.     add     edi, 3
  636.  
  637.     cmp     edi, 1024 * 3
  638.     jne     @b
  639.  
  640.     mcall   7, sel_img, <32, 32>
  641.  
  642.     ret
  643. ;-------------------------------------------------------------------------------
  644. proc sections_callback, _file_name, _section_name
  645.     mov     eax, [_section_name]
  646.     cmp     byte[eax], '@'
  647.     jne     @f
  648.  
  649.     dec     dword[dock_items.count]
  650.     jmp     .endproc
  651.  
  652.   @@:
  653.     ; ==== GET NAME ====
  654.     mov     ebx, [dock_items.count]
  655.     imul    ebx, 16
  656.     add     ebx, dock_items.name
  657.  
  658.     mov     eax, [_section_name]
  659.  
  660.     mov     edi, 0
  661.   @@:
  662.     mov     cl, byte[eax]
  663.     mov     byte[ebx + edi], cl
  664.  
  665.     inc     eax
  666.     inc     edi
  667.     cmp     edi, 10
  668.     jne     @b
  669.  
  670.   ; ==== GET PATH ====
  671.     mov     ebx, [dock_items.count]
  672.     imul    ebx, 256
  673.     add     ebx, dock_items.path
  674.  
  675.     invoke  ini.get_str, [_file_name], [_section_name], ini_data.path_name, ebx, 256, 0
  676.  
  677.   ; === GET  PARAM ===
  678.     mov     ebx, [dock_items.count]
  679.     imul    ebx, 256
  680.     add     ebx, dock_items.param
  681.  
  682.     invoke  ini.get_str, [_file_name], [_section_name], ini_data.param_name, ebx, 256, 0
  683.  
  684.   ; ==== GET ICON ====
  685.     invoke  ini.get_int, [_file_name], [_section_name], ini_data.icon_name, 0
  686.  
  687.     mov     ebx, [dock_items.count]
  688.     imul    ebx, 4
  689.     mov     [dock_items.icon + ebx], eax
  690.  
  691.   ; ==== GET SEPARATOR ====
  692.     invoke  ini.get_int, [_file_name], [_section_name], ini_data.separator_name, 0
  693.  
  694.     mov     ebx, [dock_items.count]
  695.     mov     byte[dock_items.separator + ebx], al
  696.  
  697.   ; ====== END =======
  698.  .endproc:
  699.     mov     eax, 1
  700.     inc     dword[dock_items.count]
  701.     ret
  702. endp
  703. ;-------------------------------------------------------------------------------
  704.     include "MEMORY.INC"