bool pawsSelectorBox::Setup(iDocumentNode* node)
{
    ///////////////////////////////////////////////////////////////////////
    // Create the available list box
    ///////////////////////////////////////////////////////////////////////
    csRef<iDocumentNode> availableNode = node->GetNode("available");
    int width = availableNode->GetAttributeValueAsInt("width");
    int rowHeight = availableNode->GetAttributeValueAsInt("rowheight");

    available = new pawsListBox;
    AddChild(available);

    available->SetRelativeFrame(0 , 0, GetActualWidth(width), defaultFrame.Height());
    available->PostSetup();
    available->Show();
    available->UseTitleRow(false);
    available->SetID(AVAILABLE_BOX);
    //available->UseBorder();

    csString widgetDef("<widget name=\"Text\" factory=\"pawsTextBox\" ></widget>");
    available->SetTotalColumns(1);
    available->SetColumnDef(0,
                            width-20 , rowHeight,
                            widgetDef);

    ///////////////////////////////////////////////////////////////////////
    // Create the selected list box
    ///////////////////////////////////////////////////////////////////////
    csRef<iDocumentNode> selectedNode = node->GetNode("selected");
    width = selectedNode->GetAttributeValueAsInt("width");
    rowHeight = selectedNode->GetAttributeValueAsInt("rowheight");

    selected = new pawsListBox;
    AddChild(selected);

    selected->SetRelativeFrame(defaultFrame.Width()-width , 0, width, defaultFrame.Height());
    selected->PostSetup();
    selected->Show();
    selected->SetName("Selected");
    selected->UseTitleRow(false);
    selected->SetID(SELECTED_BOX);
    //selected->UseBorder();

    csString selectedDef("<widget name=\"Text\" factory=\"pawsTextBox\" ></widget>");

    selected->SetTotalColumns(1);
    selected->SetColumnDef(0,
                           width-20 , rowHeight,
                           selectedDef);

    ///////////////////////////////////////////////////////////////////////
    // Create the addbutton
    ///////////////////////////////////////////////////////////////////////
    csRef<iDocumentNode> addNode = node->GetNode("addbutton");
    if(addNode.IsValid())
    {
        add = new pawsButton;
        AddChild(add);

        // Puts the button at the edge of the text box widget
        add->SetRelativeFrame(GetActualWidth(addNode->GetAttributeValueAsInt("x")),  GetActualHeight(addNode->GetAttributeValueAsInt("y")), 16,16);

        //get some replacement resources for the addbutton up/down
        csString upAddImageName = addNode->GetAttributeValue("buttonup");
        csString downAddImageName = addNode->GetAttributeValue("buttondown");
        if(upAddImageName.IsEmpty())
            upAddImageName = "Right Arrow";
        if(downAddImageName.IsEmpty())
            downAddImageName = "Right Arrow";

        add->SetUpImage(upAddImageName);
        add->SetDownImage(downAddImageName);

        add->SetID(SELECTOR_ADD_BUTTON);

        add->PostSetup();
    }

    ///////////////////////////////////////////////////////////////////////
    // Create the removebutton
    ///////////////////////////////////////////////////////////////////////
    csRef<iDocumentNode> removeNode = node->GetNode("removebutton");
    if(removeNode.IsValid())
    {
        remove = new pawsButton;
        AddChild(remove);

        // Puts the button at the edge of the text box widget
        remove->SetRelativeFrame(GetActualWidth(removeNode->GetAttributeValueAsInt("x")),  GetActualHeight(removeNode->GetAttributeValueAsInt("y")), 16,16);

        //get some replacement resources for the removebutton up/down
        csString upRemoveImageName = removeNode->GetAttributeValue("buttonup");
        csString downRemoveImageName = removeNode->GetAttributeValue("buttondown");
        if(upRemoveImageName.IsEmpty())
            upRemoveImageName = "Left Arrow";
        if(downRemoveImageName.IsEmpty())
            downRemoveImageName = "Left Arrow";

        remove->SetUpImage(upRemoveImageName);
        remove->SetDownImage(downRemoveImageName);

        remove->SetID(SELECTOR_REMOVE_BUTTON);

        remove->PostSetup();
    }

    return true;
}
Beispiel #2
0
bool pawsComboBox::PostSetup() 
{
    bool ok = false;

    ///////////////////////////////////////////////////////////////////////
    // Create the drop arrow button that will cause the list box to drop.
    ///////////////////////////////////////////////////////////////////////
    arrow = new pawsButton;
    AddChild( arrow );

    // Puts the button at the edge of the text box widget
    arrow->SetRelativeFrame( defaultFrame.Width()-18, 4, 18, 16 );
    arrow->SetUpImage(downButton);
    arrow->SetDownImage(downButtonPressed);
    arrow->SetID( SHOW_LIST );
    
    ok = arrow->PostSetup();    
    
    
    ///////////////////////////////////////////////////////////////////////
    // Create the textbox that has the current selected choice
    ///////////////////////////////////////////////////////////////////////    
    itemChoice = new pawsTextBox;
    itemChoice->SetBackground("Scaling Field Background");
    AddChild( itemChoice );

    // Puts the button at the edge of the text box widget
    itemChoice->SetRelativeFrame( 0 , 4, defaultFrame.Width()-23, defaultFrame.Height() );
    ok = ok && itemChoice->PostSetup();

    itemChoice->SetText(text);
    itemChoice->SetID( SHOW_LIST );
    
    
    ///////////////////////////////////////////////////////////////////////
    // Create the drop down list box
    ///////////////////////////////////////////////////////////////////////   
    listChoice = new pawsListBox;
	AddChild( listChoice );

    if (fliptotop)
    {
        listChoice->SetRelativeFrame( 0 , 0, defaultFrame.Width(), rows*GetActualHeight(rowHeight)+15);
    }
    else
    {
        listChoice->SetRelativeFrame( 0 , defaultFrame.Height(), defaultFrame.Width(), rows*GetActualHeight(rowHeight)+15);
    }

    listChoice->Hide();
    listChoice->UseTitleRow( false ); 
	listChoice->SetBackground("Scaling Widget Background");
	listChoice->SetID( id );
    listChoice->SetBackgroundAlpha(listalpha);
    listChoice->UseBorder("line");
    listChoice->SetAlwaysOnTop(true);
    listChoice->SetName("ComboListBox");
    csString widgetDef("<widget name=\"Text\" factory=\"pawsTextBox\" ></widget>");
    listChoice->SetTotalColumns( 1 );
    if(useScrollBar)
    {
        ok = ok && listChoice->PostSetup();
        listChoice->SetColumnDef( 0, defaultFrame.Width()-32, rowHeight, widgetDef );
    }
    else
    {
        listChoice->SetColumnDef( 0, defaultFrame.Width()-10, rowHeight, widgetDef );
    }

    listChoice->SetSortingFunc(0, &textBoxSortFunc);
    if(!sorted)
        listChoice->SetSortedColumn(-1);
    return ok;
}