/*
**  ItemImportPanel.m
**
**  Copyright (c) 2003
**
**  Author: Yen-Ju Chen <yjchenx@hotmail.com>
**
**  This program is free software; you can redistribute it and/or modify
**  it under the terms of the GNU General Public License as published by
**  the Free Software Foundation; either version 2 of the License, or
**  (at your option) any later version.
**
**  This program is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**  GNU General Public License for more details.
**
**  You should have received a copy of the GNU General Public License
**  along with this program; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

#include "ItemImportPanel.h"
#include <AppKit/AppKit.h>

@implementation ItemImportPanel

- (void) layoutWindow
{
  NSRect frame;
  NSTextField *categoryLabel, *bundleLabel, *locationLabel;

  frame = NSMakeRect(10, 120, 83, 18);
  categoryLabel = [[NSTextField alloc] initWithFrame: frame];
  [categoryLabel setStringValue: _(@"Category:")];
  [categoryLabel setEditable: NO];
  [categoryLabel setSelectable: NO];
  [categoryLabel setBordered: NO];
  [categoryLabel setBezeled: NO];
  [categoryLabel setBackgroundColor: [NSColor controlBackgroundColor]];
  [[self contentView] addSubview: categoryLabel];
  RELEASE(categoryLabel);

  frame = NSMakeRect(102, 120, 302, 20);
  categoryButton = [[NSPopUpButton alloc] initWithFrame: frame
                                              pullsDown: NO];
  [[self contentView] addSubview: categoryButton];
  RELEASE(categoryButton);

  frame = NSMakeRect(10, 94, 83, 18);
  bundleLabel = [[NSTextField alloc] initWithFrame: frame];
  [bundleLabel setStringValue: _(@"From:")];
  [bundleLabel setEditable: NO];
  [bundleLabel setSelectable: NO];
  [bundleLabel setBordered: NO];
  [bundleLabel setBezeled: NO];
  [bundleLabel setBackgroundColor: [NSColor controlBackgroundColor]];
  [[self contentView] addSubview: bundleLabel];
  RELEASE(bundleLabel);
  
  frame = NSMakeRect(102, 94, 302, 20);
  bundleButton = [[NSPopUpButton alloc] initWithFrame: frame
                                            pullsDown: NO];
  [[self contentView] addSubview: bundleButton];
  RELEASE(bundleButton);

  frame = NSMakeRect(10, 68, 83, 18);
  locationLabel = [[NSTextField alloc] initWithFrame: frame];
  [locationLabel setStringValue: _(@"Item:")];
  [locationLabel setEditable: NO];
  [locationLabel setSelectable: NO];
  [locationLabel setBordered: NO];
  [locationLabel setBezeled: NO];
  [locationLabel setBackgroundColor: [NSColor controlBackgroundColor]];
  [[self contentView] addSubview: locationLabel];
  RELEASE(locationLabel);
 
  frame = NSMakeRect(102, 68, 302, 20);
  locationField = [[NSTextField alloc] initWithFrame: frame];
  [[self contentView] addSubview: locationField];
  RELEASE(locationField);

  frame = NSMakeRect(102, 68, 302, 20);
  itemButton = [[NSPopUpButton alloc] initWithFrame: frame
                                          pullsDown: NO];

  frame = NSMakeRect(10, 42, 394, 18);
  descriptionField = [[NSTextField alloc] initWithFrame: frame];
  [descriptionField setStringValue: @""];
  [descriptionField setEditable: NO];
  [descriptionField setSelectable: NO];
  [descriptionField setBordered: NO];
  [descriptionField setBezeled: NO];
  [descriptionField setBackgroundColor: [NSColor controlBackgroundColor]];
  [[self contentView] addSubview: descriptionField];
  RELEASE(descriptionField);


  frame = NSMakeRect(281, 8, 56, 24);
  cancelButton = [[NSButton alloc] initWithFrame: frame];
  [cancelButton setButtonType: NSMomentaryPushButton];
  [cancelButton setTitle: _(@"Cancel")];
  [[self contentView] addSubview: cancelButton];
  RELEASE(cancelButton);

  frame = NSMakeRect(348, 8, 56, 24);
  okButton = [[NSButton alloc] initWithFrame: frame];
  [okButton setButtonType:NSMomentaryPushButton];
  [okButton setKeyEquivalent: @"\r"];
  [okButton setImagePosition: NSImageRight];
  [okButton setImage: [NSImage imageNamed: @"common_ret"]];
  [okButton setAlternateImage: [NSImage imageNamed: @"common_retH"]];
  [okButton setTitle: _(@"OK")];
  [[self contentView] addSubview:okButton];
  RELEASE(okButton);

  frame = NSMakeRect(10, 8, 56, 24);
  helpButton = [[NSButton alloc] initWithFrame: frame];
  [helpButton setButtonType: NSMomentaryPushButton];
  [helpButton setKeyEquivalent: @"h"];
  [helpButton setTitle: _(@"Help")];
  [[self contentView] addSubview:helpButton];
  RELEASE(helpButton);

  [categoryButton setNextKeyView: bundleButton];
  [bundleButton setNextKeyView: locationField];
  [locationField setNextKeyView: okButton];
  [okButton setNextKeyView: cancelButton];
  [cancelButton setNextKeyView: helpButton]; 
  [helpButton setNextKeyView: categoryButton];
}

- (void) dealloc
{
  RELEASE(itemButton); /* Not release from initWithFrame: */
  [super dealloc];
}

- (NSTextField *) locationField
{
  return locationField;
}

- (NSPopUpButton *) categoryButton
{
  return categoryButton;
}

- (NSPopUpButton *) bundleButton
{
  return bundleButton;
}

- (NSPopUpButton *) itemButton
{
  return itemButton;
}

- (NSTextField *) descriptionField
{
  return descriptionField;
}

- (NSButton *) okButton
{
  return okButton;
}

- (NSButton *) cancelButton
{
  return cancelButton;
}

- (NSButton *) helpButton
{
  return helpButton;
}

@end
