<commit_before>/** * Appcelerator Titanium - licensed under the Apache Public License 2
 * see LICENSE in the root folder for details on the license.
 * Copyright (c) 2008 Appcelerator, Inc. All Rights Reserved.
 */
#import "osx_user_window.h"
#import "osx_ui_binding.h"
#import "osx_menu_item.h"

#define STUB() printf("Method is still a stub, %s:%i\n", __FILE__, __LINE__)

namespace ti
{
	bool OSXUserWindow::initial = false;
	static unsigned int toWindowMask(WindowConfig *config)
	{
		unsigned int mask = 0;
		if (!config->IsUsingChrome() || config->IsFullScreen())
		{
			mask = NSBorderlessWindowMask;
		}
		else
		{
			mask |= NSTitledWindowMask;
			if (config->IsResizable())
			{
				mask |= NSResizableWindowMask;
			}
			if (config->IsCloseable())
			{
				mask |= NSClosableWindowMask;
			}
			if (config->IsMaximizable())
			{
				mask |= NSMiniaturizableWindowMask;
			}
			if (config->IsMaximizable())
			{
				// handled in the window code
			}
		}
		return mask;
	}

	OSXUserWindow::OSXUserWindow(UIBinding* binding, WindowConfig* config, SharedUserWindow parent) :
		UserWindow(binding, config, parent),
		window(NULL),
		opened(false),
		closed(false),
		osx_binding(binding.cast<OSXUIBinding>())
	{
		unsigned int mask = toWindowMask(config);

		NSRect mainFrame = [[NSScreen mainScreen] frame];
		NSRect frame = mainFrame;

		// Set up the size and position of the
		// window using our Set<...> methods so
		// we avoid duplicating the logic here.
		if (!config->IsFullScreen())
			frame = NSMakeRect(0, 0, 10, 10);

		window = [[NativeWindow alloc]
		           initWithContentRect: frame
		           styleMask: mask
		           backing: NSBackingStoreBuffered
		           defer: false];

		if (!config->IsFullScreen())
		{
			this->SetX(config->GetX());
			this->SetY(config->GetY());
			this->SetHeight(config->GetHeight());
			this->SetWidth(config->GetWidth());
		}

		[window setupDecorations:config host:binding->GetHost() userwindow:this];
		if (OSXUserWindow::initial)
		{
			OSXuserWindow::intial = false;
			[window setInitialWindow:YES];
		}

		this->SetTopMost(config->IsTopMost());

	}
	OSXUserWindow::~OSXUserWindow()
	{
		window = nil; // don't release
		
		if (!closed)
		{
			UserWindow::Close();
		}
	}
	void OSXUserWindow::Hide()
	{
		this->config->SetVisible(false);
		if (opened)
		{
			this->Unfocus();
			[window fireWindowEvent:HIDDEN];
		}
	}
	void OSXUserWindow::Focus()
	{
		if (!focused)<commit_msg>Build fixes for OS X<commit_after>/** * Appcelerator Titanium - licensed under the Apache Public License 2
 * see LICENSE in the root folder for details on the license.
 * Copyright (c) 2008 Appcelerator, Inc. All Rights Reserved.
 */
#import "../ui_module.h"
#import "osx_menu_item.h"

#define STUB() printf("Method is still a stub, %s:%i\n", __FILE__, __LINE__)

namespace ti
{
	bool OSXUserWindow::initial = false;
	static unsigned int toWindowMask(WindowConfig *config)
	{
		unsigned int mask = 0;
		if (!config->IsUsingChrome() || config->IsFullScreen())
		{
			mask = NSBorderlessWindowMask;
		}
		else
		{
			mask |= NSTitledWindowMask;
			if (config->IsResizable())
			{
				mask |= NSResizableWindowMask;
			}
			if (config->IsCloseable())
			{
				mask |= NSClosableWindowMask;
			}
			if (config->IsMaximizable())
			{
				mask |= NSMiniaturizableWindowMask;
			}
			if (config->IsMaximizable())
			{
				// handled in the window code
			}
		}
		return mask;
	}

	OSXUserWindow::OSXUserWindow(SharedUIBinding binding, WindowConfig* config, SharedUserWindow parent) :
		UserWindow(binding, config, parent),
		window(NULL),
		opened(false),
		closed(false),
		osx_binding(binding.cast<OSXUIBinding>())
	{
		unsigned int mask = toWindowMask(config);

		NSRect mainFrame = [[NSScreen mainScreen] frame];
		NSRect frame = mainFrame;

		// Set up the size and position of the
		// window using our Set<...> methods so
		// we avoid duplicating the logic here.
		if (!config->IsFullScreen())
			frame = NSMakeRect(0, 0, 10, 10);

		window = [[NativeWindow alloc]
		           initWithContentRect: frame
		           styleMask: mask
		           backing: NSBackingStoreBuffered
		           defer: false];

		if (!config->IsFullScreen())
		{
			this->SetX(config->GetX());
			this->SetY(config->GetY());
			this->SetHeight(config->GetHeight());
			this->SetWidth(config->GetWidth());
		}

		[window setupDecorations:config host:binding->GetHost() userwindow:this];
		if (OSXUserWindow::initial)
		{
			OSXUserWindow::initial = false;
			[window setInitialWindow:YES];
		}

		this->SetTopMost(config->IsTopMost());

	}
	OSXUserWindow::~OSXUserWindow()
	{
		window = nil; // don't release
		
		if (!closed)
		{
			UserWindow::Close();
		}
	}
	void OSXUserWindow::Hide()
	{
		this->config->SetVisible(false);
		if (opened)
		{
			this->Unfocus();
			[window fireWindowEvent:HIDDEN];
		}
	}
	void OSXUserWindow::Focus()
	{
		if (!focused)
{'fraction_non_alphanumeric': 0.136986301369863, 'fraction_numerical': 0.0049069719893682275, 'mean_word_length': 3.5338276181649677, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1195740', 'n_tokens_mistral': 1897, 'n_tokens_neox': 1624, 'n_words': 377}