{"name":"safeZoneW","operator":null,"title":"safeZoneW","type":"command","url":"https://community.bistudio.com/wiki/safeZoneW","revid":349848,"updated":"2023-11-20T22:10:41Z","groups":["GUI Control - Positioning"],"status":"ok","replaced_by":[],"games":[{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2","name":"Arma 2","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Returns the width of the screen in screen measurement units.\nTaken from top left corner of the default viewport (0,0) of the screen and going in the same direction as the X axis, the value will be positive but resulting X will end up beyond the right border.\nTherefore in order to calculate X of the right screen border, the length of safeZoneX must be subtracted from safeZoneW, but because it is negative, it must be added instead.\n`_screenRightBorderX = safeZoneW + safeZoneX`. The measurement units depend on the current screen resolution getResolution. See also SafeZone.","syntaxes":[{"syntax":"safeZoneW","since":null,"effect":null,"exec":null,"params":[],"returns":{"type":"Number","types":["Number"],"description":"screen width in screen measurement units","text":"Number - screen width in screen measurement units"},"form":"nullary","operator":null,"left":null,"right":null}],"examples":[{"text":"```sqf\n_screenWidth = safeZoneW;\n```","code":["_screenWidth = safeZoneW;"]},{"text":"```sqf\n_screenLeftBorderX = safeZoneX;\n_screenRightBorderX = safeZoneW + safeZoneX;\n```","code":["_screenLeftBorderX = safeZoneX;\n_screenRightBorderX = safeZoneW + safeZoneX;"]},{"text":"Create control 50% wide, 30% tall, centered on screen:\n\n```sqf\nprivate _ctrl = findDisplay 46 createDisplay \"RscDisplayEmpty\" ctrlCreate [\"RscText\", -1];\n_ctrl ctrlSetBackgroundColor [1,0,0,0.5];\nprivate _ctrlWidth = 0.5 * safeZoneW; // 50% of screen width\nprivate _ctrlHeight = 0.3 * safeZoneH; // 30% of screen height\n_ctrl ctrlSetPositionW _ctrlWidth;\n_ctrl ctrlSetPositionH _ctrlHeight;\n_ctrl ctrlSetPositionX ((safeZoneW - _ctrlWidth) / 2 + safeZoneX); // center it horizontally\n_ctrl ctrlSetPositionY ((safeZoneH - _ctrlHeight) / 2 + safeZoneY); // center it vertically\n_ctrl ctrlCommit 0;\n```","code":["private _ctrl = findDisplay 46 createDisplay \"RscDisplayEmpty\" ctrlCreate [\"RscText\", -1];\n_ctrl ctrlSetBackgroundColor [1,0,0,0.5];\nprivate _ctrlWidth = 0.5 * safeZoneW; // 50% of screen width\nprivate _ctrlHeight = 0.3 * safeZoneH; // 30% of screen height\n_ctrl ctrlSetPositionW _ctrlWidth;\n_ctrl ctrlSetPositionH _ctrlHeight;\n_ctrl ctrlSetPositionX ((safeZoneW - _ctrlWidth) / 2 + safeZoneX); // center it horizontally\n_ctrl ctrlSetPositionY ((safeZoneH - _ctrlHeight) / 2 + safeZoneY); // center it vertically\n_ctrl ctrlCommit 0;"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["SafeZone","safeZoneX","safeZoneY","safeZoneH","safeZoneXAbs","safeZoneWAbs"],"notes":[],"categories":["Arma 2: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control - Positioning","Introduced with Arma 2 version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}