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 » Community » Newbie corner » How to achieve dynamic layout scaling ?
Re: How to achieve dynamic layout scaling ? [message #55950 is a reply to message #55939] Wed, 06 January 2021 15:24 Go to previous messageGo to previous message
mingodad is currently offline  mingodad
Messages: 53
Registered: February 2008
Location: Spain
Member
The idea is to resize the window and have everything resized proportionally (widgets, fonts).

Here is a small calculator layout to use as a basis to show possible ways to achieve "Dynamic Layout Scaling".

- CalculatorDynLayout.h
#ifndef _CalculatorDynLayout_CalculatorDynLayout_h
#define _CalculatorDynLayout_CalculatorDynLayout_h

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#define LAYOUTFILE <CalculatorDynLayout/CalculatorDynLayout.lay>
#include <CtrlCore/lay.h>

class CalculatorDynLayout : public WithCalculatorDynLayoutLayout<TopWindow> {
public:
	CalculatorDynLayout();
};

#endif


- main.cpp
#include "CalculatorDynLayout.h"

CalculatorDynLayout::CalculatorDynLayout()
{
	CtrlLayout(*this, "Calculator");
}

GUI_APP_MAIN
{
	CalculatorDynLayout().Sizeable().Run();
}


- CalculatorDynLayout.lay
LAYOUT(CalculatorDynLayoutLayout, 160, 136)
	ITEM(Upp::Label, entry, SetFrame(BlackFrame()).HSizePosZ(12, 8).TopPosZ(8, 19))
	ITEM(Upp::Button, clear, SetLabel(t_("C")).LeftPosZ(80, 20).TopPosZ(32, 15))
	ITEM(Upp::Button, clearAll, SetLabel(t_("AC")).LeftPosZ(104, 20).TopPosZ(32, 15))
	ITEM(Upp::Button, bksp, SetLabel(t_("<-")).LeftPosZ(132, 20).TopPosZ(32, 15))
	ITEM(Upp::Button, b7, SetLabel(t_("7")).LeftPosZ(12, 20).TopPosZ(52, 15))
	ITEM(Upp::Button, b8, SetLabel(t_("8")).LeftPosZ(40, 20).TopPosZ(52, 15))
	ITEM(Upp::Button, b9, SetLabel(t_("9")).LeftPosZ(68, 20).TopPosZ(52, 15))
	ITEM(Upp::Button, bdiv, SetLabel(t_("/")).LeftPosZ(96, 20).TopPosZ(52, 15))
	ITEM(Upp::Button, bsqrt, SetLabel(t_("sqrt")).LeftPosZ(124, 28).TopPosZ(52, 15))
	ITEM(Upp::Button, b4, SetLabel(t_("4")).LeftPosZ(12, 20).TopPosZ(72, 15))
	ITEM(Upp::Button, b5, SetLabel(t_("5")).LeftPosZ(40, 20).TopPosZ(72, 15))
	ITEM(Upp::Button, b6, SetLabel(t_("6")).LeftPosZ(68, 20).TopPosZ(72, 15))
	ITEM(Upp::Button, bmul, SetLabel(t_("*")).LeftPosZ(96, 20).TopPosZ(72, 15))
	ITEM(Upp::Button, bpct, SetLabel(t_("%")).LeftPosZ(124, 28).TopPosZ(72, 15))
	ITEM(Upp::Button, b1, SetLabel(t_("1")).LeftPosZ(12, 20).TopPosZ(92, 15))
	ITEM(Upp::Button, b2, SetLabel(t_("2")).LeftPosZ(40, 20).TopPosZ(92, 15))
	ITEM(Upp::Button, b3, SetLabel(t_("3")).LeftPosZ(68, 20).TopPosZ(92, 15))
	ITEM(Upp::Button, bminus, SetLabel(t_("-")).LeftPosZ(96, 20).TopPosZ(92, 15))
	ITEM(Upp::Button, b0, SetLabel(t_("0")).LeftPosZ(12, 20).TopPosZ(112, 15))
	ITEM(Upp::Button, bsep, SetLabel(t_(".")).LeftPosZ(40, 20).TopPosZ(112, 15))
	ITEM(Upp::Button, blessplus, SetLabel(t_("-/+")).LeftPosZ(68, 20).TopPosZ(112, 15))
	ITEM(Upp::Button, bplus, SetLabel(t_("+")).LeftPosZ(96, 20).TopPosZ(112, 15))
	ITEM(Upp::Button, beq, SetLabel(t_("=")).LeftPosZ(124, 28).TopPosZ(92, 36))
END_LAYOUT
 
Read Message
Read Message
Read Message
Previous Topic: SqlSchema sch(MY_SQL) compound and or unique indexes
Next Topic: Keyboard navigation doesn't work
Goto Forum:
  


Current Time: Sat Jul 05 18:14:32 CEST 2025

Total time taken to generate the page: 0.04276 seconds