From: Edward W. <Edward.Wildgoose@FRMHedge.com> - 2003-12-24 10:34:29
|
Thanks=20to=20everyone=20for=20all=20their=20hints.=20=20I=20am=20still=20= no=20closer=20to=20working=20this=20out=20so=20I=20have=20attached=20a=20s= ample=20chunk=20of=20code=20below.=20=20This=20uses=20a=20panel=20resource= ,=20but=20at=20least=20on=20my=20perl=20(5.8=20under=20Win32)=20does=20not= =20a)=20resize=20at=20all,=20or=20b)=20resize=20the=20text=20control=20in=20= the=20top=20row=20of=20the=20flexgridsizer. Basically=20this=20simple=20example=20should=20have=20a=20flexgrid=20with=20= two=20rows,=20the=20top=20row=20has=20a=20static=20box=20sizer=20in=20it,=20= which=20in=20turn=20contains=20a=20text=20control,=20this=20should=20resiz= e=20to=20be=20the=20major=20part=20of=20the=20whole=20screen.=20=20The=20l= ower=20row=20has=20a=20check=20box=20in=20it,=20this=20should=20be=20cente= red,=20but=20otherwise=20take=20up=20the=20min=20space=20required.=20=20So= =20we=20should=20have=20an=20effect=20where=20the=20text=20box=20takes=20u= p=20as=20much=20of=20the=20screen=20as=20is=20left=20once=20the=20check=20= box=20is=20accounted=20for. Now,=20the=20problems=20are=20that: -=20the=20idea=20of=20putting=20a=20flexgridsizer=20inside=20the=20staticb= oxsizer=20is=20not=20doing=20anything=20useful,=20the=20control=20remains=20= only=20capable=20of=20resizing=20the=20inner=20text=20box=20in=20one=20dim= ension=20only. -=20Using=20a=20grey=20background=20(#d4d0c8)=20looks=20pretty=20bad=20on=20= my=20machine.=20=20I=20have=20a=20hunch=20that=20this=20is=20windows=20col= our=20correction=20kicking=20in=20because=20the=20colour=20suggested=20is=20= actually=20not=20quite=20grey=20with=20a=20slight=20hint=20of=20green.=20=20= My=20laptop=20colours=20are=20actually=20slightly=20off=20and=20I=20have=20= a=20colour=20profile=20installed=20which=20brings=20them=20back=20to=20neu= tral.=20=20I=20suspect=20that=20wxwindows=20outputs=20to=20the=20display=20= directly=20and=20bypasses=20the=20windows=20colour=20correction=20hints?=20= =20If=20so=20this=20is=20a=20great=20shame... -=20Adding=20stuff=20into=20a=20panel=20seems=20to=20help,=20but=20I=20the= n=20don't=20have=20a=20resizable=20set=20of=20controls.=20=20Probably=20I=20= have=20failed=20to=20set=20some=20interesting=20attribute=20of=20the=20siz= ers,=20but=20I'm=20not=20really=20sure=20what. If=20anyone=20could=20help=20tweak=20the=20code=20below=20(probably=20a=20= one=20line=20change!)=20then=20I=20would=20be=20extremely=20grateful=20-=20= it=20was=20originally=20generated=20using=20wxdesigner: Thanks=20all #!/usr/bin/perl use=20Wx; use=20strict; #=20WDR:=20classes package=20MyDialog; use=20strict; use=20vars=20qw(@ISA); @ISA=3Dqw(Wx::Frame); use=20Wx=20qw(wxID_OK=20wxID_CANCEL=20wxGROW=20wxALL); sub=20new=20{ =20=20=20=20my(=20$class,=20$app=20)=20=3D=20(shift,=20shift); =20=20=20=20my(=20$this=20)=20=3D=20$class->SUPER::new(=20@_=20); =20=20=20=20 =20=20=20=20my=20$panel=20=3D=20Wx::Panel->new($this,=20-1); =20=20=20=20#=20WDR:=20dialog=20function=20MyDialogFunc=20for=20MyDialog =20=20=20=20&main::MyDialogFunc(=20$panel,=201=20); =20=20=20=20my(=20$item0=20)=20=3D=20Wx::FlexGridSizer->new(=200,=201,=200= ,=200=20); =20=20=20=20$item0->AddWindow(=20$panel,=200,=20wxGROW|wxALL,=205=20); =20=20=20=20$this->SetAutoLayout(=201=20); =20=20=20=20$this->SetSizer(=20$item0=20); =20=20=20=20$item0->Fit(=20$this=20); =20=20=20=20$item0->SetSizeHints(=20$this=20); =20=20=20=20 =20=20=20=20#=20WDR:=20handler=20declarations=20for=20MyDialog =20=20=20=20 =20=20=20=20$this; } #=20WDR:=20methods=20for=20MyDialog #=20WDR:=20handler=20implementations=20for=20MyDialog package=20MyApp; use=20strict; use=20vars=20qw(@ISA); @ISA=3Dqw(Wx::App); use=20Wx=20qw(wxDefaultSize=20wxDefaultPosition=20wxTAB_TRAVERSAL=20wxRESI= ZE_BORDER=20wxDEFAULT_DIALOG_STYLE=20wxSIGTERM=20wxSIGKILL); use=20Wx::Event=20qw(EVT_SOCKET_CONNECTION=20EVT_SOCKET_INPUT=20EVT_SOCKET= _OUTPUT=20EVT_SOCKET_LOST); use=20Wx=20qw(:socket); my=20$dialog; sub=20OnInit=20{ =20=20my(=20$this=20)=20=3D=20@_; =20=20#=20Create=20the=20dialog =20=20$dialog=20=3D=20MyDialog->new(=20$this, =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20undef,=20-1, =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20"Stats=20&=20Logging", =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20wxDefaultPosition, =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20wxDefaultSize, =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20wxDEFAULT_DIALOG_STYLE=20|=20wxRESIZE_BORDER =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20); =20=20$this->{DIALOG}=20=3D=20$dialog; =20=20$this->SetTopWindow($dialog); =20=20$dialog->Show(1); =20=20=20=20return=201; =20} =20 package=20main; use=20Wx=20qw(=20wxDefaultSize=20wxDefaultPosition=20wxID_OK=20wxID_CANCEL= =20wxID_YES=20); use=20Wx=20qw(=20wxVERTICAL=20wxHORIZONTAL=20wxALL=20wxLEFT=20wxRIGHT=20wx= TOP=20wxBOTTOM=20wxCENTRE=20wxGROW=20); use=20Wx=20qw(=20wxALIGN_RIGHT=20wxALIGN_BOTTOM=20wxALIGN_CENTER=20wxALIGN= _CENTER_VERTICAL=20wxALIGN_CENTER_HORIZONTAL=20); use=20Wx=20qw(=20wxTE_MULTILINE=20); use=20vars=20qw($ID_TEXTCTRL);=20$ID_TEXTCTRL=20=3D=2010000; use=20vars=20qw($ID_CHECKBOX);=20$ID_CHECKBOX=20=3D=2010001; #=20Main my(=20$app=20)=20=3D=20MyApp->new(); $app->MainLoop(); sub=20MyDialogFunc=20{ =20=20=20=20my(=20$item0=20)=20=3D=20Wx::FlexGridSizer->new(=200,=201,=200= ,=200=20); =20=20=20=20my(=20$item2=20)=20=3D=20Wx::StaticBox->new(=20$_[0],=20-1,=20= "Text"=20); =20=20=20=20my(=20$item1=20)=20=3D=20Wx::StaticBoxSizer->new(=20$item2,=20= wxHORIZONTAL=20); =20=20=20=20my(=20$item3=20)=20=3D=20Wx::FlexGridSizer->new(=200,=202,=200= ,=200=20); =20=20=20=20my(=20$item4=20)=20=3D=20Wx::TextCtrl->new(=20$_[0],=20$main::= ID_TEXTCTRL,=20"",=20wxDefaultPosition,=20[80,40],=20wxTE_MULTILINE=20); =20=20=20=20$item3->AddWindow(=20$item4,=200,=20wxGROW,=205=20); =20=20=20=20$item1->Add(=20$item3,=200,=20wxGROW|wxALIGN_CENTER_HORIZONTAL= |wxALL,=205=20); =20=20=20=20$item0->Add(=20$item1,=200,=20wxGROW|wxALL,=205=20); =20=20=20=20my(=20$item5=20)=20=3D=20Wx::CheckBox->new(=20$_[0],=20$main::= ID_CHECKBOX,=20"Check",=20wxDefaultPosition,=20wxDefaultSize,=200=20); =20=20=20=20$item0->AddWindow(=20$item5,=200,=20wxALIGN_CENTER|wxALL,=205=20= ); =20=20=20=20my(=20$set_size=20)=20=3D=20@_=20>=3D=203=20?=20$_[2]=20:=201;= =20=20=20=20my(=20$call_fit=20)=20=3D=20@_=20>=3D=202=20?=20$_[1]=20:=201;= =20=20=20=20if(=20$set_size=20=3D=3D=201=20)=20{ =20=20=20=20=20=20=20=20=20$_[0]->SetAutoLayout(=201=20); =20=20=20=20=20=20=20=20=20$_[0]->SetSizer(=20$item0=20); =20=20=20=20=20=20=20=20=20if(=20$call_fit=20=3D=3D=201=20)=20{ =20=20=20=20=20=20=20=20=20=20=20=20=20$item0->Fit(=20$_[0]=20); =20=20=20=20=20=20=20=20=20=20=20=20=20$item0->SetSizeHints(=20$_[0]=20); =20=20=20=20=20=20=20=20=20} =20=20=20=20} =20=20=20=20$item0; } ... |