<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interface\FrameXML\UI.xsd">
	<Script file="localization.lua"/> 
	<Script file="MyInventory.lua"/> 
	
	<CheckButton name="MyInventoryBackpackButtonTemplate" inherits="ItemButtonTemplate" id="0" hidden="false" virtual="true">
		<CheckedTexture alphaMode="ADD" file="Interface\Buttons\ButtonHilight-Square"/>
		<HighlightTexture alphaMode="ADD" file="Interface\Buttons\CheckButtonHilight"/>
		<Size><AbsDimension x="37" y="37"/></Size>
		<Scripts>
			<OnLoad>
				local button = getglobal(this:GetName().."IconTexture");
				button:SetTexture("Interface\\Buttons\\Button-Backpack-Up");
				--MainMenuBarBackpackButton:Hide();
			</OnLoad>			
		</Scripts>
	</CheckButton>
	<CheckButton name="MyInventoryBagButtonTemplate" inherits="BagSlotButtonTemplate" hidden="false" virtual="true">
		<CheckedTexture alphaMode="ADD" file="Interface\Buttons\ButtonHilight-Square"/>
		<HighlightTexture alphaMode="ADD" file="Interface\Buttons\CheckButtonHilight"/>
		<Scripts>		
			<OnLoad>
				this.isBag = 1;
				local getBag = getglobal("Character"..strsub(this:GetName(),10));
				this:SetID(getBag:GetID());
				PaperDollItemSlotButton_OnLoad();
				this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
				this:RegisterForDrag("LeftButton");
			</OnLoad>			
		</Scripts>
	</CheckButton>

	<Button name="MyInventoryResizeTemplate" virtual="true">
		<Size>
			<AbsDimension x="16" y="16"/>
		</Size>
		<NormalTexture file="Interface\AddOns\MyInventory\Skin\Buttons">
			<TexCoords left=".75" right=".875" top="0" bottom=".125"/>
		</NormalTexture>
		<HighlightTexture file="Interface\AddOns\MyInventory\Skin\Buttons" alphaMode="ADD">
			<TexCoords left=".75" right=".875" top="0" bottom=".125"/>
		</HighlightTexture>
		<Scripts>
			<OnLoad>
				this:SetFrameLevel(this:GetFrameLevel()+2);
			</OnLoad>
			<OnMouseDown>
				MyInventoryFrame_StartResizing();
			</OnMouseDown>
			<OnMouseUp>
				MyInventoryFrame_StopResizing();
			</OnMouseUp>
		</Scripts>
	</Button>

	<Button name="MIStealBagSlotTemplate" enableMouse="true" hidden="false" virtual="true">
		<Scripts>
			<OnLoad>
				this:SetAllPoints(this:GetParent():GetName());
				this:SetID(this:GetParent():GetID());
				this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
				this:RegisterForDrag("LeftButton");
				this:Hide();
			</OnLoad>
			
			<OnEnter>
				if strfind(this:GetName(), "Backpack") then
					MyInventory_Backpack_OnEnter();
				else
					MyInventory_BagButton_OnEnter();
				end
			</OnEnter>
			<OnLeave>
				if strfind(this:GetName(), "Backpack") then
					MyInventory_Backpack_OnLeave();
				else
					MyInventory_BagButton_OnLeave();
				end
			</OnLeave>
			
			<OnClick>
				if strfind(this:GetName(), "Backpack") then
					MyInventory_Backpack_OnClick(true);
				else
					MyInventory_BagButton_OnClick(true);
				end
			</OnClick>
			<OnDragStart>
				if strfind(this:GetName(), "Backpack") then
				else
					MyInventory_BagButton_OnDragStart();
				end
			</OnDragStart>
			<OnReceiveDrag>
				if strfind(this:GetName(), "Backpack") then
					PutItemInBackpack();
				else
					MyInventory_BagButton_OnReceiveDrag();
				end
			</OnReceiveDrag>
		</Scripts>
	</Button>
	<Button name="MIStealBackpackButton" parent="MainMenuBarBackpackButton" inherits="MIStealBagSlotTemplate"/>
	<Button name="MIStealItBag0Slot" parent="CharacterBag0Slot" inherits="MIStealBagSlotTemplate"/>
	<Button name="MIStealItBag1Slot" parent="CharacterBag1Slot" inherits="MIStealBagSlotTemplate"/>
	<Button name="MIStealItBag2Slot" parent="CharacterBag2Slot" inherits="MIStealBagSlotTemplate"/>
	<Button name="MIStealItBag3Slot" parent="CharacterBag3Slot" inherits="MIStealBagSlotTemplate"/>
	
	<Frame name="MyInventoryAnchorFrame" parent="UIParent" hidden="false" movable="true">
		<Size><AbsDimension x="1" y="1"/></Size>
		<Anchors>
			<Anchor point="CENTER" >
				<Offset><AbsDimension x="0" y="0"/></Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				RegisterForSaveFrame();
			</OnLoad>
		</Scripts>
	</Frame>

	<Frame name="MyInventoryFrame" parent="UIParent" frameStrata="MEDIUM" toplevel="true" movable="true" resizable="true" enableMouse="true" hidden="true" clampedToScreen="true">
		<Anchors>
			<Anchor point="TOPLEFT" relativeto="MyInventoryAnchorFrame" relativePoint="TOPLEFT" >
				<Offset><AbsDimension x="0" y="0"/></Offset>
			</Anchor>
		</Anchors>
		<Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
			<BackgroundInsets><AbsInset left="5" right="5" top="5" bottom="5"/></BackgroundInsets>
			<TileSize><AbsValue val="16"/></TileSize>
			<EdgeSize><AbsValue val="16"/></EdgeSize>
		</Backdrop>
		<Layers>
			<Layer level="BACKGROUND">
				<Texture name="$parentPortrait" hidden="true" file="Interface\AddOns\MyInventory\Skin\Backpack" > <!--   -->
					<Size><AbsDimension x="58" y="58"/></Size>
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset><AbsDimension x="-7" y="2"/></Offset>
						</Anchor>
					</Anchors>
				</Texture>
	<!-- -LITE{ -->
				<Texture name="$parentTextureTopLeft" file="Interface\AddOns\MyInventory\Skin\TopLeft" hidden="true">
					<Size><AbsDimension x="128" y="128"/></Size>
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset><AbsDimension x="-67" y="60"/></Offset>
						</Anchor>
					</Anchors>
				</Texture>
				<Texture name="$parentTextureTopRight" file="Interface\AddOns\MyInventory\Skin\TopRight" hidden="true">
					<Size><AbsDimension x="64" y="128"/></Size>
					<Anchors>
						<Anchor point="TOPRIGHT"> 
							<Offset><AbsDimension x="36" y="60"/></Offset>
						</Anchor>
					</Anchors>
				</Texture>
				<Texture name="$parentTextureTopCenter" file="Interface\AddOns\MyInventory\Skin\TopCenter" hidden="true">
					<Size><AbsDimension x="128" y="128"/></Size>
					<Anchors>
						<Anchor point="BOTTOMLEFT" relativeTo="$parentTextureTopLeft" relativePoint="BOTTOMRIGHT"/>
						<Anchor point="BOTTOMRIGHT" relativeTo="$parentTextureTopRight" relativePoint="BOTTOMLEFT"/>
					</Anchors>
				</Texture>
				<!-- }-LITE -->
				<!-- -LITE{ -->
				<Texture name="$parentTextureBottomLeft" file="Interface\AddOns\MyInventory\Skin\BottomLeft" hidden="true">
					<Size><AbsDimension x="128" y="128"/></Size>
					<Anchors>
						<Anchor point="BOTTOMLEFT">
							<Offset><AbsDimension x="-67" y="-60"/></Offset>
						</Anchor>
					</Anchors>
				</Texture>
				<Texture name="$parentTextureBottomRight" file="Interface\AddOns\MyInventory\Skin\BottomRight" hidden="true">
					<Size><AbsDimension x="64" y="128"/></Size>
					<Anchors>
						<Anchor point="BOTTOMRIGHT"> 
							<Offset><AbsDimension x="36" y="-60"/></Offset>
						</Anchor>
					</Anchors>
				</Texture>
				<Texture name="$parentTextureBottomCenter" file="Interface\AddOns\MyInventory\Skin\BottomCenter" hidden="true">
					<Size><AbsDimension x="128" y="128"/></Size>
					<Anchors>
						<Anchor point="TOPLEFT" relativeTo="$parentTextureBottomLeft" relativePoint="TOPRIGHT"/>
						<Anchor point="TOPRIGHT" relativeTo="$parentTextureBottomRight" relativePoint="TOPLEFT"/>
					</Anchors>
				</Texture>
				<!-- }-LITE -->
				<!-- -LITE{ -->
				<Texture name="$parentTextureLeft" file="Interface\AddOns\MyInventory\Skin\Left" hidden="true">
					<Size><AbsDimension x="64" y="128"/></Size>
					<Anchors>
						<Anchor point="TOPRIGHT" relativeTo="$parentTextureTopLeft" relativePoint="BOTTOMRIGHT"/>
						<Anchor point="BOTTOMRIGHT" relativeTo="$parentTextureBottomLeft" relativePoint="TOPRIGHT"/>
					</Anchors>
				</Texture>
				<Texture name="$parentTextureRight" file="Interface\AddOns\MyInventory\Skin\Right" hidden="true">
					<Size><AbsDimension x="64" y="128"/></Size>
					<Anchors>
						<Anchor point="TOPLEFT" relativeTo="$parentTextureTopRight" relativePoint="BOTTOMLEFT"/>
						<Anchor point="BOTTOMLEFT" relativeTo="$parentTextureBottomRight" relativePoint="TOPLEFT"/>
					</Anchors>
				</Texture>
				<Texture name="$parentTextureCenter" file="Interface\AddOns\MyInventory\Skin\Center" hidden="true">
					<Size><AbsDimension x="128" y="128"/></Size>
					<Anchors>
						<Anchor point="TOPLEFT" relativeTo="$parentTextureTopCenter" relativePoint="BOTTOMLEFT"/>
						<Anchor point="TOPRIGHT" relativeTo="$parentTextureTopCenter" relativePoint="BOTTOMRIGHT"/>
						<Anchor point="BOTTOMLEFT" relativeTo="$parentTextureBottomCenter" relativePoint="TOPLEFT"/>
						<Anchor point="BOTTOMRIGHT" relativeTo="$parentTextureBottomCenter" relativePoint="TOPRIGHT"/>
					</Anchors>
				</Texture>
				<!-- }-LITE -->
			</Layer>
			<Layer level="ARTWORK">
				<FontString name="$parentName" inherits="GameFontNormal" justifyH="LEFT">
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset><AbsDimension x="7" y="-10"/></Offset>
						</Anchor>
					</Anchors>
				</FontString>
				<FontString name="$parentSlots" inherits="GameFontNormal" justifyH="LEFT">
					<Anchors>
						<Anchor point="BOTTOMLEFT">
							<Offset><AbsDimension x="7" y="8"/></Offset>
						</Anchor>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<Frames>
			<Frame name="$parentMoneyFrame" inherits="SmallMoneyFrameTemplate" hidden="true">
				<Anchors>
					<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT">
						<Offset><AbsDimension x="-5" y="8"/></Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnLoad>
						SmallMoneyFrame_OnLoad();
						MoneyFrame_SetType("STATIC");
					</OnLoad>
				</Scripts>
			</Frame>
		
			<Frame name="MyInventoryBagButtonsBar" hidden="false">
				<Size><AbsDimension x="190" y="37"/></Size>
				<Anchors>
					<Anchor point="TOP">
						<Offset><AbsDimension x="0" y="-28"/></Offset>
					</Anchor>
				</Anchors>
				<Frames>
					<CheckButton name="MyInventoryBackpackButton" inherits="MyInventoryBackpackButtonTemplate" id="0">
						<Anchors>
							<Anchor point="LEFT" relativeto="MyInventoryBagButtonsBar" relativepoint="LEFT"/>
						</Anchors>
					</CheckButton>
					<CheckButton name="MyInventoBag0Slot" inherits="MyInventoryBagButtonTemplate" id="20">
						<Anchors>
							<Anchor point="LEFT" relativeto="MyInventoryBackpackButton" relativepoint="RIGHT"/>
						</Anchors>
					</CheckButton>
					<CheckButton name="MyInventoBag1Slot" inherits="MyInventoryBagButtonTemplate" id="21">
						<Anchors>
							<Anchor point="LEFT" relativeto="MyInventoBag0Slot" relativepoint="RIGHT">
								<Offset><AbsDimension x="2" y="0"/></Offset>
							</Anchor>
						</Anchors>
					</CheckButton>
					<CheckButton name="MyInventoBag2Slot" inherits="MyInventoryBagButtonTemplate" id="22">
						<Anchors>
							<Anchor point="LEFT" relativeto="MyInventoBag1Slot" relativepoint="RIGHT">
								<Offset><AbsDimension x="2" y="0"/></Offset>
							</Anchor>
						</Anchors>
					</CheckButton>
					<CheckButton name="MyInventoBag3Slot" inherits="MyInventoryBagButtonTemplate" id="23">
						<Anchors>
							<Anchor point="LEFT" relativeto="MyInventoBag2Slot" relativepoint="RIGHT">
								<Offset><AbsDimension x="2" y="0"/></Offset>
							</Anchor>
						</Anchors>
					</CheckButton>
				</Frames>
			</Frame>
		
			<Button name="$parentCloseButton" inherits="UIPanelCloseButton">
				<Anchors>
					<Anchor point="TOPRIGHT" relativeTo="$parent" relativePoint="TOPRIGHT">
						<Offset>
							<AbsDimension x="-1" y="-1"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						this:GetParent():Hide();
					</OnClick>
				</Scripts>
			</Button>
			<Button name="$parentLockButton" inherits="UIPanelCloseButton">
				<NormalTexture name="MILockNormalTexture" file="Interface\AddOns\MyInventory\Skin\LockButton-Unlocked-Up"/>
				<PushedTexture name="MILockPushedTexture" file="Interface\AddOns\MyInventory\Skin\LockButton-Locked-Down"/>
				<Anchors>
					<Anchor point="RIGHT" relativeTo="$parentCloseButton" relativePoint="LEFT">
						<Offset><Absdimension x="10" y="0"/></Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						MyInventory_Toggle_Option("Lock");
						MyInventoryFrame_UpdateLook(MyInventory_GetBagsTotalSlots());
					</OnClick>
				</Scripts>
			</Button>
			<Button name="$parentHideBagsButton" inherits="UIPanelCloseButton">
				<NormalTexture name="MIHideBagsNormalTexture" file="Interface\AddOns\MyInventory\Skin\SettingsButton-Up"/>
				<PushedTexture name="MIHideBagsPushedTexture" file="Interface\AddOns\MyInventory\Skin\SettingsButton-Down"/>
				<Anchors>
					<Anchor point="RIGHT" relativeTo="$parentLockButton" relativePoint="LEFT">
						<Offset><Absdimension x="15" y="0"/></Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						ShowUIPanel(MyInventoryOptionsFrame);
					</OnClick>
				</Scripts>
			</Button>
			
			<Button name="$parentBag0" hidden="false" id="0"></Button>
			<Button name="$parentBag1" hidden="false" id="1"></Button>
			<Button name="$parentBag2" hidden="false" id="2"></Button>
			<Button name="$parentBag3" hidden="false" id="3"></Button>
			<Button name="$parentBag4" hidden="false" id="4"></Button>
			<!-- Tab1 -->
			<Button name="$parentPlayerTab" inherits="GuildFrameColumnHeaderTemplate" id="1" Text="MI_CURRENT_PLAYERS" hidden="true">
				<Size><AbsDimension x="80" y="24"/></Size>
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset><AbsDimension x="54" y="-40"/></Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnLoad>
						getglobal(this:GetName() .. "Middle"):SetWidth(70);
						this:LockHighlight();
					</OnLoad>
					<OnClick>
						MyInventoryFrame_TabOnClick();
					</OnClick>
				</Scripts>
			</Button>
			<!-- Tab2 -->
			<Button name="$parentViewTab" inherits="GuildFrameColumnHeaderTemplate" id="2" Text="MI_VIEW_PLAYERS" hidden="true">
				<Size><AbsDimension x="80" y="24"/></Size>
				<Anchors>
					<Anchor point="LEFT" relativeTo="$parentPlayerTab" relativePoint="RIGHT">
						<Offset><AbsDimension x="-2" y="0"/></Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnLoad>
						getglobal(this:GetName() .. "Middle"):SetWidth(70);
					</OnLoad>
					<OnClick>
						MyInventoryFrame_TabOnClick();
					</OnClick>
				</Scripts>
			</Button>

			<Frame name="MyInventoryViewDropDown" inherits="BDropDownMenuTemplate" enableMouse="true" hidden="true">				
				<Anchors>
					<Anchor point="TOPRIGHT" relativePoint="TOPRIGHT">
						<Offset>
							<AbsDimension x="12" y="-38"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnLoad>
						MyInventroyAjustDropDown();
					</OnLoad>
					<OnShow>
						MyInventoryViewDropDown_OnLoad();
					</OnShow>
					<OnEnter>
						if (this.tooltip) then
							GameTooltip:SetOwner(this, "ANCHOR_TOPRIGHT");
							GameTooltip:SetText(this.tooltip, nil, nil, nil, nil, 1);
						end						
					</OnEnter>
					<OnLeave>
						GameTooltip:Hide();
					</OnLeave>
				</Scripts>
			</Frame>

			<Button name="MyInventoryResizeButton" inherits="MyInventoryResizeTemplate">
				<Anchors>
					<Anchor point="BOTTOMRIGHT">
						<Offset>
							<AbsDimension x="1" y="-1"/>
						</Offset>
					</Anchor>
				</Anchors>
			</Button>
		</Frames>
		<Scripts>
			<OnEvent>
				--MyInventoryFrame_OnEvent(event);
			</OnEvent>
			<OnLoad>
				--MyInventoryFrame_OnLoad();
				for i=1, 160, 1 do
					local name = string.format("MyInventoryFrameItem%d",i);
					local button = CreateFrame("Button",name,this,"ContainerFrameItemButtonTemplate");
					local texture = button:CreateTexture(name.."Border", "OVERLAY");
					texture:SetWidth(64);
					texture:SetHeight(64);
					texture:SetPoint("CENTER", button, "CENTER", 0, -1);
					texture:SetTexture("Interface\\AddOns\\MyInventory\\Skin\\Border");				
				end

				MyInventoryFrame_SetViewType(1);
			</OnLoad>
			<OnHide>
				MyInventoryFrame_OnHide();
			</OnHide>
			<OnShow>
				MyInventoryFrame_OnShow();
			</OnShow>
			<OnMouseDown>
				MyInventoryFrame_OnMouseDown(arg1);
			</OnMouseDown>
			<OnMouseUp>
				MyInventoryFrame_OnMouseUp(arg1);
			</OnMouseUp>
		</Scripts>
	</Frame>

	<GameTooltip name="MyInventoryTooltip" frameStrata="TOOLTIP" hidden="false" inherits="GameTooltipTemplate">
		<Scripts>
			<OnLoad>
				this:SetOwner(UIParent, "ANCHOR_NONE");
			</OnLoad>
		</Scripts>
	</GameTooltip>
</Ui>
