Hi Petr,
long time no see :-)
Just a blind guess - I could imagine that the image object doesn't get
width/height properties updated until it is rendered - maybe you should
try to add an "appear" listener!?
A qooxdoo based gallery would be great - I always liked the idea, but I
have time to realise such for myself...
Maybe your project could become a contribution someday?
HTH,
greetings
Stefan
On 03.01.2011 18:25, Petr Kobalíček wrote:
> Hello,
>
> I have this code:
>
> control = new qx.ui.basic.Image(this.getIcon());
> control.addListener("loaded", this._onLoaded, this);
> control.addListener("loadingFailed", this._onLoadingFailed, this);
>
> How can I access image width / height after image is loaded (in
> "loaded" event handler)?
>
> I tried to use control.getWidth()/getHeight(), but it's null. I looked
> at the documentation for qx.ui.basic.Image and qx.html.Image, but it
> didn't help me to create a working code.
>
>
> ----------------
>
> BTW: I'm trying to create a gallery like widget where I can see the
> thumbnails, but instead of zooming small images I want them small so I
> need to center the image widget.
>
> My dirty code for such thing is:
>
> qx.Class.define("ux.core.FileTileView",
> {
> extend : qx.ui.form.List,
>
> construct : function()
> {
> this.base(arguments);
> this.getChildrenContainer().setLayout(new qx.ui.layout.Flow());
> },
>
> members :
> {
> _applyOrientation: function(value)
> {
> this.getChildrenContainer().setAllowStretchY(false);
> }
> }
> });
>
> qx.Class.define("ux.core.FileTileItem",
> {
> extend: qx.ui.form.ListItem,
>
> construct: function()
> {
> // Call superclass constructor.
> this.base(arguments);
>
> // Layout.
> this._setLayout(new qx.ui.layout.Canvas());
>
> this._iconCtrl = this.getChildControl("icon");
> this._labelCtrl = this.getChildControl("label");
> },
>
> destruct: function()
> {
> },
>
> members:
> {
> // Property.
> _applyGap : function(value)
> {
> // this._getLayout().setSpacing(value);
> },
>
> // Overridden.
> _createChildControlImpl : function(id)
> {
> var control;
>
> var w = 128;
> var h = 128;
>
> switch(id)
> {
> case "icon":
> control = new qx.ui.basic.Image(this.getIcon());
> control.addListener("loaded", this._onLoaded, this);
> control.addListener("loadingFailed", this._onLoadingFailed, this);
> control.setAnonymous(true);
> this._add(control, { left: 0, top: 0 });
> break;
>
> case "label":
> control = new qx.ui.basic.Label(this.getLabel());
> control.setAnonymous(true);
> control.setTextAlign("center");
> control.set({
> minWidth: w,
> maxWidth: w,
> width: w
> });
> this._add(control, { left: 0, top: h });
> break;
> }
>
> return control || this.base(arguments, id);
> },
>
> // Events
> _onLoaded: function(e)
> {
> var control = this._iconCtrl;
>
> var w = control.getWidth();
> var h = control.getHeight();
>
> // not works...
> this.debug(w);
> this.debug(h);
>
> if (w> 128) w = 128;
> if (h> 128) h = 128;
>
> control.setLayoutProperties({
> left: Math.floor((128 - w) / 2),
> top: Math.floor((128 - h) / 2)
> });
> },
>
> _onLoadingFailed: function(e)
> {
> }
> }
> });
>
> Thank you for ideas / Best regards
> Petr
>
> ------------------------------------------------------------------------------
> Learn how Oracle Real Application Clusters (RAC) One Node allows customers
> to consolidate database storage, standardize their database environment, and,
> should the need arise, upgrade to a full multi-node Oracle RAC database
> without downtime or disruption
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and,
should the need arise, upgrade to a full multi-node Oracle RAC database
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel