I am starting to fall in love with wxWerlang.<br>Thanks a lot.<br><br>Am Donnerstag, 8. März 2012 08:54:27 UTC+1 schrieb Dan Gudmundsson:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">You want the actual font size to change?<p>If so you will have to write that yourself there is no such<br>functionality in wx that I'm aware of.</p><p>Something like this:</p><p>go() -><br> wx:new(),<br> Parent = wxFrame:new(wx:null(), ?wxID_ANY, "Foobar"),<br> %% wxFrame:connect(Parent, close_window),<br> Panel = wxPanel:new(Parent, []),</p><p> %% Setup sizers<br> TextSizer = wxBoxSizer:new(?wxVERTICAL),<br> ClockText = wxStaticText:new(Panel,1,"00 : 00 :<br>00",[{style,?wxALIGN_CENTER}])<wbr>,</p><p> %% Add to sizers<br> wxSizer:add(TextSizer,<wbr>ClockText,[{flag,?wxEXPAND},{<wbr>proportion,0}]),<br> DrawArea = wxPanel:new(Panel, [{style, ?wxFULL_REPAINT_ON_RESIZE}]),<br> wxSizer:add(TextSizer,<wbr>DrawArea,[{flag,?wxEXPAND},{<wbr>proportion,1}]),<br> Fonts = create_fonts(),<br> wxPanel:connect(DrawArea, paint, [{callback, fun(Ev, _) -><br>draw(Ev, Fonts) end}]),<br> wxPanel:setSizer(Panel,<wbr>TextSizer),<br> wxFrame:show(Parent).</p><p>create_fonts() -><br> [wxFont:new(Sz, ?wxFONTFAMILY_DEFAULT, ?wxFONTSTYLE_NORMAL,<br>?wxFONTWEIGHT_NORMAL) ||<br> Sz <- lists:reverse([8, 10, 12, 14, 16, 18, 24, 28, 40, 48, 60])].</p><p>draw(#wx{obj=Panel}, Fonts) -><br> DC = wxPaintDC:new(Panel),<br> Sz = {W,H} = wxWindow:getClientSize(Panel),<br> wxDC:drawRectangle(DC, {3,3,W-6, H-6}),<br> Str = "00 : 00 : 00",<br> Pos = set_font(Fonts, Str, DC, Sz),<br> wxDC:drawText(DC, Str, Pos),<br> wxPaintDC:destroy(DC).</p><p>set_font([Font|Fs], Str, DC, Sz = {MaxW, MaxH}) -><br> wxDC:setFont(DC, Font),<br> case wxDC:getTextExtent(DC, Str) of<br> {W,H} when W < MaxW, H < MaxH -><br> {(MaxW - W) div 2, (MaxH - H) div 2};<br> _ -><br> set_font(Fs, Str, DC, Sz)<br> end;<br>set_font([], _, _, _) -><br> {0,0}.</p><p>/Dan</p><p>On Wed, Mar 7, 2012 at 5:03 PM, eigenfunction <<a href="mailto:emeka_1978@yahoo.com" target="_blank">emeka_1978@yahoo.com</a>> wrote:<br>> I have a static text centered in a panel. When i resize the panel, i<br>> would like the text to resize as well. This is my code:<br>><br>> wxFrame:connect(Parent, close_window),<br>> Panel = wxPanel:new(Parent, []),<br>><br>> %% Setup sizers<br>> TextSizer = wxBoxSizer:new(?wxVERTICAL),<br>> ClockText = wxStaticText:new(Panel,1,"00 : 00 : 00",[{style,?<br>> wxALIGN_CENTER}]),<br>><br>> %% Add to sizers<br>> wxSizer:add(TextSizer,<wbr>ClockText,[{flag,?wxEXPAND},{<wbr>proportion,<br>> 1}]),<br>><br>> wxPanel:setSizer(Panel,<wbr>TextSizer),<br>> wxFrame:show(Parent)<br>><br>> ______________________________<wbr>_________________<br>> erlang-questions mailing list<br>> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>______________________________<wbr>_________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p></blockquote>