[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: seeking resize listener help

Good one, Marc.
I thought I would try to help you out today, but it's much better that you 
figured out the problem youself.  ;)
Nice!

GridLayout would work, too, but you have to set the layout data in all the 
right places to tell the controls to fill.
By default, controls in a GridLayout don't fill.

Carolyn

"Marc E" <marc_e@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message 
news:fr6v3j$d0j$1@xxxxxxxxxxxxxxxxxxxx
> Dumb!
>
> talking it out to myself really helped. it was that last sentence that 
> sparked the aha moment:  i was using gridlayout, when i should've been 
> using filllayout. i didn't even see that because i was so hung up on just 
> seeing the canvas not stretching, thinking it was a problem with the 
> listener. jeeesh.
>
>
> "Marc E" <marc_e@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message 
> news:fr6spg$ala$1@xxxxxxxxxxxxxxxxxxxx
>> So, to demonstrate my still utter cluelessness, i did this:
>>
>> my canvas object creates a listener; out in the createPartControl code, i 
>> create the canvas object, get the listener it creates, and then attach 
>> that listener to the topHalf composite.
>>
>> even that didn't work.  so now i'm really confused: I can pass in the 
>> tophalf as the parent to the canvas and attach a listener like that. but 
>> if i pass in a new composite as the parent, have the canvas return a 
>> listener, and attach the listener to the same composite i attached it to 
>> in prior tests, it doesn't work. well... the listener gets called, but 
>> the redraw() events inside the listener don't seem to have any effect; 
>> i.e. my canvas object doesn't change.
>>
>> it's as if that new composite i'm passing in there is effectively locking 
>> my canvas or something, like it's stuck in place and can't stretch.
>>
>> weird.
>>
>> well, i'm sure it's not weird. i'm sure it's something super stupid i'm 
>> doing... i just can't figure it out!
>>
>> any help is most appreciated, as always.
>>
>>
>> "Marc E" <marc_e@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message 
>> news:fqq16k$boh$1@xxxxxxxxxxxxxxxxxxxx
>>> Greetings all.
>>>
>>> I've got a view that contains a number of composites. all the composites 
>>> use either in the top or bottom half of a sash form. one of the 
>>> composites has an object in it that extends canvas. Sort of picture the 
>>> junit view with the progress bar as the canvas.
>>>
>>> sort of like this:
>>>
>>> SashForm
>>>   --Composite: topHalf, SashForm is parent
>>>      --Composite, topHalf is parent
>>>      --Canvas, topHalf is parent
>>>      --Composite, topHalf is parent
>>>
>>>   --Composite: bottomHalf, SashForm is parent
>>>       -- number of Composites, all taking bottomHalf as parent
>>>
>>>
>>> now, what I want is to have my canvas object inside its own composite. 
>>> The reason is that this seems to be the only way I can have a layout 
>>> object for the canvas; otherwise, it takes on the layout of the parent 
>>> (topHalf). But I want my layout to have different margins and whatnot 
>>> for the canvas. However, if I do that, i.e. like so:
>>>
>>>
>>> Composite composite= new Composite(parent, SWT.NONE);
>>> GridLayout layout= new GridLayout();
>>> composite.setLayout(layout);
>>> myCanvas = new MyCanvasObject(composite);
>>> GridData gd = new GridData(GridData.GRAB_HORIZONTAL | 
>>> GridData.HORIZONTAL_ALIGN_FILL);
>>> myCanvas.setLayoutData(gd);
>>>
>>> Then the resize listener doesn't work because it's attaching to the 
>>> composite i'm creating and passing into the canvas. What I need, though, 
>>> is to have my MyCanvasObject attach its resize listener to the topHalf 
>>> parent object.
>>>
>>> Or, more specifically, I need to have my canvas object attach its resize 
>>> listener to whatever the heck it is in the view itself that announces 
>>> that "hey, i'm resized!".
>>>
>>> So, ideally, if I have that canvas, and I put it in any composite, i'd 
>>> like to have that canvas be able to respond to resizes of its containing 
>>> view.
>>>
>>> Now, if I pass in the parent topHalf directly to the canvas, and forego 
>>> creating a new composite with its own layout to use as the parent of the 
>>> canvas, then the resize listener works fine.
>>>
>>> by the way, here's the simple code for the resize listener:
>>>
>>> public MyCanvasObject(Composite parent) {
>>> super(parent, SWT.NONE);
>>> parent.addControlListener(new ControlAdapter() {
>>> public void controlResized(ControlEvent e) {
>>> System.out.println(e);
>>>
>>> }
>>> });
>>>
>>> thanks for any advice!
>>>
>>> Marc
>>>
>>
>>
>
>