Hi, all.

For example in attach.

1. Setup scrollbox's size greater than the size of it contens. For example 200 x 200 via valuators max values.
2. Add few buttons.
3. Left mouse click on free scrollbox's space cause, sometime, realign for content like "ADOWN". It's ok? For next mouse-wheel's scrollup or down - content immediatly realigned to "ATOP".

4. Add several buttons, until appears scrollbox's vertical scrollbar. Ok.
5. Del few buttons, until scrollbar disapper.
6. Now, try to mouse-wheel scroll up/down. We see, as content partially scrolled up under top border. And scroll step depend of content vertical size. For example, one button - scrolls up for few pixels. But eight buttons - scrolls up almost for 20 pixels.
require "iuplua"

vb = iup.vbox{
}

counter = 0

btn_add = iup.button{
    title = "Add Control",
    rastersize = "100x20",
    action = function (self)
        local btn = iup.button{
            title="Button "..counter,
            rastersize = "100x20",
            action = function (self)
                print(self.title)
            end,
        }
        counter = counter + 1
        -- three mandatory steps: append, map, refresh
        iup.Append(vb, btn)
        iup.Map(btn)
        iup.Refresh(vb)
    end,
}

btn_del = iup.button{
    title = "Del Control",
    rastersize = "100x20",
    action = function (self)
        local n = iup.GetChildCount(vb)
        if n <= 0 then return end
        local child = iup.GetChild(vb, n - 1)
        iup.Destroy(child)
        counter = counter - 1
        iup.Refresh(vb)
    end,
}

sb = iup.scrollbox{
    vb,
    rastersize = "100x100",
    expand = "HORIZONTAL",
    border = "YES",
    scrollbar = "VERTICAL",
}

function dlg_refresh()
    iup.SetAttribute(dlg, "SIZE", nil)
    iup.Refresh(dlg)
end


val_w = iup.val{
    min = 0,
    max = 200,
    rastersize = "200x30",
    value = 100,
}
function val_w:valuechanged_cb()
    local w,h = sb.naturalsize:match("(%d+)x(%d+)")
    w = math.floor(self.value)
    sb.rastersize = w .. "x" .. h
    dlg_refresh()
end


val_h = iup.val{
    min = 0,
    max = 200,
    rastersize = "200x30",
    value = 100,
}
function val_h:valuechanged_cb()
    local w,h = sb.naturalsize:match("(%d+)x(%d+)")
    h = math.floor(self.value)
    sb.rastersize = w .. "x" .. h
    dlg_refresh()
end

dlg = iup.dialog{
    iup.hbox{
        iup.vbox{
            margin = "5x5",
            gap = 5,
            alignment = "acenter",
            normalizesize = "horizontal",
            iup.frame{val_w, title="Width",},
            iup.frame{val_h, title="Height",},
            btn_add,
            btn_del,
        },
        iup.vbox{
            sb,
        },
    },
--    rastersize = "QUADxQUAD",
}

dlg:showxy(iup.CENTER, iup.CENTER)

iup.MainLoop()

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to