Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » ArrayCtrl with labels / layouts inside ?
ArrayCtrl with labels / layouts inside ? [message #12885] Sun, 25 November 2007 19:23 Go to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
Hi,

I'm new to Upp and i'm doing tests.
I dunno if its possible but i'd like to have an array control filled with labels.

My app have a main layout called myFirstUppApp with an ArrayCtrl called testArray.
I made a second layout with a label containing 3 others labels.

I want to use this second layout as a widget to fill my testArray.

Is it posible ? How can i do it, i'm lost Smile

jf
Re: ArrayCtrl with labels / layouts inside ? [message #12886 is a reply to message #12885] Sun, 25 November 2007 19:49 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
Sorry i just found : http://www.ultimatepp.org/reference$ArrayCtrlEdits.html

i think this partially answer to my needs Embarassed

But creating a new layout is it the right way to create a kind of new widget ?

jf

[Updated on: Sun, 25 November 2007 19:50]

Report message to a moderator

Re: ArrayCtrl with labels / layouts inside ? [message #12887 is a reply to message #12886] Sun, 25 November 2007 21:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
jiaif wrote on Sun, 25 November 2007 13:49

Sorry i just found : http://www.ultimatepp.org/reference$ArrayCtrlEdits.html

i think this partially answer to my needs Embarassed

But creating a new layout is it the right way to create a kind of new widget ?



Yep, if layout is useful for the widget, why not...

Mirek
Re: ArrayCtrl with labels / layouts inside ? [message #12888 is a reply to message #12887] Sun, 25 November 2007 22:07 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
Thanks for you answer.
Sorry, i'm searching and i dont find how to do what i want.

I posted a picture who looks like what i want to do.

if you can give me just a piece of code, a little example, i'll be very very happy Smile
Or maybe a tuto where i can find how to create my own widget ?
What class to derivate ?

here is my second layout :

LAYOUT(myLayout, 196, 52)
ITEM(Label, lbl_name, LeftPosZ(4, 132).TopPosZ(4, 20))
ITEM(Label, lbl_surname, LeftPosZ(4, 132).TopPosZ(28, 20))
ITEM(Label, lbl_country, LeftPosZ(144, 48).TopPosZ(4, 44))
END_LAYOUT

myArray.AddColumn("test"). ... ?

thanks

Jf
  • Attachment: thing.png
    (Size: 20.59KB, Downloaded 344 times)
Re: ArrayCtrl with labels / layouts inside ? [message #12889 is a reply to message #12888] Mon, 26 November 2007 09:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
jiaif wrote on Sun, 25 November 2007 16:07

Thanks for you answer.
Sorry, i'm searching and i dont find how to do what i want.

I posted a picture who looks like what i want to do.

if you can give me just a piece of code, a little example, i'll be very very happy Smile
Or maybe a tuto where i can find how to create my own widget ?
What class to derivate ?

here is my second layout :

LAYOUT(myLayout, 196, 52)
ITEM(Label, lbl_name, LeftPosZ(4, 132).TopPosZ(4, 20))
ITEM(Label, lbl_surname, LeftPosZ(4, 132).TopPosZ(28, 20))
ITEM(Label, lbl_country, LeftPosZ(144, 48).TopPosZ(4, 44))
END_LAYOUT

myArray.AddColumn("test"). ... ?

thanks

Jf


Actually, for the purpose I can see on screenshot, rather use Display.

Widgets are good if you want to change things. For static stuff, Display is better.

Mirek
Re: ArrayCtrl with labels / layouts inside ? [message #12890 is a reply to message #12889] Mon, 26 November 2007 17:03 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
Hi Mirek,

I want to change things ! Smile
I want to change the wole world !

more seriously, i think i'm near the solution but i need to understand some things..

Supposing i want to fill my array with buttons (but i don't want the user to fill this array, i want to do this programatically).

I understand that i can do :

myArray.AddColumn("test").Ctrls<Button>();

But i don't know how to add a particular button.
If i just do : myArray.Add(); its add a button but without label and i don't understand how to set its label.

Button b;
b.SetLabel("test");

How can i add this button to the array ?
It's not DoAppend, Add or AddCtrl..

jf
Re: ArrayCtrl with labels / layouts inside ? [message #12891 is a reply to message #12890] Mon, 26 November 2007 18:06 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
If I understood you right, try using myArray.SetCtrl()


Below is the modified code of Arrayctrl reference example.


ArrayCtrlExample::ArrayCtrlExample()
{
	CtrlLayoutExit(*this, "ArrayCtrl example");
	

	array.AddColumn("integer").Sorting();
	array.AddIndex(ID1);
	array.AddColumn(ID2, "combined").Add(ID1).AddIndex(ID3).SetConvert(Single<MyConvert>());
	array.AddColumn("editable").Edit(myedit).Sorting();
	array.AddColumn("with display").SetDisplay(Single<MyDisplay>());
	array.AddCtrl(editor);
	array.AddRowNumColumn("rownum");
	array.WhenLeftDouble = THISBACK(DoubleClick);
	array.ColumnWidths("51 120 60 102 62");

	for(int i = 0; i < 20; i++)
		array.Add(i, AsString(i * 10), GetSysDate(), i * 3, rand() % 1000,
		          Color(byte(i * 77), byte(i * 200), byte(i * 135)), FormatIntRoman(i));
//==========================================================
	bt.SetLabel("Test"); // bt should be declared in the interface
	array.SetCtrl(2, 2, bt);
//==========================================================
}



Just overwrite the original code, and declare "Button bt" before compiling, and see what it does.
Smile


[Updated on: Mon, 26 November 2007 18:10]

Report message to a moderator

Re: ArrayCtrl with labels / layouts inside ? [message #12892 is a reply to message #12891] Mon, 26 November 2007 18:32 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
i'm sorry but :

error: no matching function for call to ‘Upp::ArrayCtrl::SetCtrl(int, int, Upp::Button&)’

note: candidates are: Upp::Ctrl& Upp::ArrayCtrl::SetCtrl(int, int, Upp::Ctrl*)

when i try to do :

Button b;
b.SetLabel("test");
myArray.AddColumn("test").Ctrls<Button>();
myArray.SetCtrl(0,0,b);

I don't understand what means the documentation about this method. I think it's not what i need. but i maybe i'm wrong ?

If you could give me a shorter and simple example it would be very cool Smile

[Updated on: Mon, 26 November 2007 18:33]

Report message to a moderator

Re: ArrayCtrl with labels / layouts inside ? [message #12893 is a reply to message #12892] Mon, 26 November 2007 18:55 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Ok, here is a very simple example. Smile
Edit: Example removed!
Regards.


[Updated on: Tue, 27 November 2007 22:14]

Report message to a moderator

Re: ArrayCtrl with labels / layouts inside ? [message #12894 is a reply to message #12893] Mon, 26 November 2007 19:18 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
Thank you for the code, but i'm sorry, i have the same errors Sad
I don't understand why.

Maybe because myArray is added before i add buttons ?
I mean in my code, myArray is defined in the layout.

Maybe because i'm under linux ? Very Happy

[edit]
if i do :
Button b;
b.SetLabel("test");
myArray.AddColumn("test");
myArray.SetCtrl(0,0,&b);

it compile well but the button don't appear. Any idea ?

[Updated on: Mon, 26 November 2007 19:24]

Report message to a moderator

Re: ArrayCtrl with labels / layouts inside ? [message #12896 is a reply to message #12894] Mon, 26 November 2007 20:07 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Interesting. Which version of U++ do you use?
As of Upp 711b, there should be a:

SetCtrl(int iž int colž Ctrl& ctrlž bool value = true)


You can use this instead.

Ps: If you allocate Button from the stack (e.g. Button bt), try not to "declare" it inside the same method.
And, as far as I know, you have to "Add" something before you can "append" or "set" a ctrl seperately in an ArrayCtrl.

Eg,


Button *bt = new Button();
bt->SetLabel("Test");
myArray.AddColumn("Column1");
myArray.Add("");
myArray.SetCtrl(0, 0, bt);



Or/And


Button *bt = new Button();
bt->SetLabel("Test");
myArray.AddColumn("Column1");
myArray.AddColumn("Column2");
myArray.Add("This is a text");
myArray.SetCtrl(0, 1, bt);



should work.


Re: ArrayCtrl with labels / layouts inside ? [message #12897 is a reply to message #12896] Mon, 26 November 2007 20:26 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
I use 2007.1, there is no deb package for other versions.

my def is :
SetCtrl(int i, int j, Ctrl *newctrl)

And your code (as mine) don't work.

it's sad
Re: ArrayCtrl with labels / layouts inside ? [message #12899 is a reply to message #12897] Mon, 26 November 2007 22:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
jiaif wrote on Mon, 26 November 2007 14:26

I use 2007.1, there is no deb package for other versions.




Yes, sorry. Our Linux maintainer took a long vacation...

Anyway, all you need to do is to download sources and create assemblies for them. It is simple.

Mirek
Re: ArrayCtrl with labels / layouts inside ? [message #12902 is a reply to message #12899] Tue, 27 November 2007 00:28 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
OK..

But without readme or makefile, it would not be so simple.

With a tuto or a simple INSTALL it would be cool Smile

[Updated on: Tue, 27 November 2007 00:43]

Report message to a moderator

Re: ArrayCtrl with labels / layouts inside ? [message #12904 is a reply to message #12902] Tue, 27 November 2007 12:13 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
Ouch !...

I followed a tuto on the forum for compiling svn sources under linux, and it works.. but not very well. (eats 7% of my load, layout editor as fast as a turtle, and tons of bugs when compiling my project..)
Maybe should i try a dev release instead. That's what i'm going to do.
Re: ArrayCtrl with labels / layouts inside ? [message #12905 is a reply to message #12904] Tue, 27 November 2007 12:52 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
The easiest way I've found of installing/updating on Linux (I don't usually use the SVN version):
1- Download last Linux installer (If you already have Upp installed you can ignore this)
2- Download latest dev release source. Replace uppsrc with new version.
3- If desired, recompile TheIDE

That's all you should have to do.
Re: ArrayCtrl with labels / layouts inside ? [message #12906 is a reply to message #12904] Tue, 27 November 2007 12:54 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
I tried 711-dev2, it's a bit better, but why is it so slow compared to 2007.1 ?

I have the same problem, i can add buttons on my array but they don't appear.

SetCtrl method definition is the same as in 2007.1 version :
Ctrl *newctrl
and not
Ctrl& ctrl

any other ideas ?
Re: ArrayCtrl with labels / layouts inside ? [message #12907 is a reply to message #12905] Tue, 27 November 2007 12:57 Go to previous messageGo to next message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
thanks mrjt,

but i followed this tuto
Re: ArrayCtrl with labels / layouts inside ? [message #12908 is a reply to message #12907] Tue, 27 November 2007 19:43 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Here is a "heap" version of the example. I hope that it will work. If not, there is probably a problem with the debian U++ dist.
(it works fine with ubuntu (7.10) and pardus)
code is using the:
myArray.SetCtrl(int iž int jž Ctrl *newctrl)





[Updated on: Tue, 27 November 2007 22:12]

Report message to a moderator

Re: ArrayCtrl with labels / layouts inside ? [message #12909 is a reply to message #12908] Tue, 27 November 2007 21:36 Go to previous messageGo to previous message
jiaif is currently offline  jiaif
Messages: 17
Registered: November 2007
Location: France
Promising Member
OK.. so.. in fact your code runs, but try with another layout.
For example try a layout with a label, some arrays and buttons, and the famous myarray
Try to do it with the layout editor.

Then try your code again.. without "Add(myArray.SizePos());"

And you will see the problem i'm talking about.
There is a grayed case, but the button don't appear.

Smile
Previous Topic: How to use WithDropChoice?
Next Topic: PromptOK - little error in textselection
Goto Forum:
  


Current Time: Mon Apr 29 09:30:26 CEST 2024

Total time taken to generate the page: 0.02218 seconds