andrewm@0: /* andrewm@0: ============================================================================== andrewm@0: andrewm@0: This is an automatically generated GUI class created by the Introjucer! andrewm@0: andrewm@0: Be careful when adding custom code to these files, as only the code within andrewm@0: the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded andrewm@0: and re-saved. andrewm@0: andrewm@0: Created with Introjucer version: 3.1.0 andrewm@0: andrewm@0: ------------------------------------------------------------------------------ andrewm@0: andrewm@0: The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions" andrewm@0: Copyright 2004-13 by Raw Material Software Ltd. andrewm@0: andrewm@0: ============================================================================== andrewm@0: */ andrewm@0: andrewm@0: //[Headers] You can add your own extra header files here... andrewm@0: #ifndef TOUCHKEYS_NO_GUI andrewm@0: #include "MappingListComponent.h" andrewm@41: #include "MappingExtendedEditorWindow.h" andrewm@0: //[/Headers] andrewm@0: andrewm@0: #include "MappingListItem.h" andrewm@0: andrewm@0: andrewm@0: //[MiscUserDefs] You can add your own user definitions and misc code here... andrewm@0: //[/MiscUserDefs] andrewm@0: andrewm@0: //============================================================================== andrewm@0: MappingListItem::MappingListItem (MappingListComponent& listComponent) andrewm@0: : factory_(0), listComponent_(listComponent) andrewm@0: { andrewm@0: addAndMakeVisible (bypassToggleButton = new ToggleButton ("Bypass toggle button")); andrewm@0: bypassToggleButton->setButtonText ("Bypass"); andrewm@0: bypassToggleButton->addListener (this); andrewm@0: andrewm@0: addAndMakeVisible (showDetailsButton = new TextButton ("Show details button")); andrewm@0: showDetailsButton->setButtonText ("Details..."); andrewm@0: showDetailsButton->addListener (this); andrewm@0: andrewm@0: addAndMakeVisible (mappingTypeLabel = new Label ("mapping type label", andrewm@0: "MappingType")); andrewm@0: mappingTypeLabel->setFont (Font (18.00f, Font::plain)); andrewm@0: mappingTypeLabel->setJustificationType (Justification::centred); andrewm@0: mappingTypeLabel->setEditable (false, false, false); andrewm@0: mappingTypeLabel->setColour (TextEditor::textColourId, Colours::black); andrewm@0: mappingTypeLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (mappingShortEditorComponent = new MappingEditorComponent()); andrewm@0: mappingShortEditorComponent->setName ("mapping short editor component"); andrewm@0: andrewm@0: addAndMakeVisible (noSettingsLabel = new Label ("no settings label", andrewm@0: "(no settings)")); andrewm@0: noSettingsLabel->setFont (Font (15.00f, Font::plain)); andrewm@0: noSettingsLabel->setJustificationType (Justification::centred); andrewm@0: noSettingsLabel->setEditable (false, false, false); andrewm@0: noSettingsLabel->setColour (TextEditor::textColourId, Colours::black); andrewm@0: noSettingsLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); andrewm@0: andrewm@0: addAndMakeVisible (deleteButton = new TextButton ("delete button")); andrewm@0: deleteButton->setButtonText ("Delete..."); andrewm@0: deleteButton->addListener (this); andrewm@0: andrewm@0: andrewm@0: //[UserPreSize] andrewm@0: //[/UserPreSize] andrewm@0: andrewm@0: setSize (544, 72); andrewm@0: andrewm@0: andrewm@0: //[Constructor] You can add your own custom stuff here.. andrewm@0: //[/Constructor] andrewm@0: } andrewm@0: andrewm@0: MappingListItem::~MappingListItem() andrewm@0: { andrewm@0: //[Destructor_pre]. You can add your own custom destruction code here.. andrewm@0: //[/Destructor_pre] andrewm@0: andrewm@0: bypassToggleButton = nullptr; andrewm@0: showDetailsButton = nullptr; andrewm@0: mappingTypeLabel = nullptr; andrewm@0: mappingShortEditorComponent = nullptr; andrewm@0: noSettingsLabel = nullptr; andrewm@0: deleteButton = nullptr; andrewm@0: andrewm@0: andrewm@0: //[Destructor]. You can add your own custom destruction code here.. andrewm@0: //[/Destructor] andrewm@0: } andrewm@0: andrewm@0: //============================================================================== andrewm@0: void MappingListItem::paint (Graphics& g) andrewm@0: { andrewm@0: //[UserPrePaint] Add your own custom painting code here.. andrewm@0: //[/UserPrePaint] andrewm@0: andrewm@0: g.fillAll (Colours::white); andrewm@0: andrewm@0: g.setColour (Colour (0xffa52a60)); andrewm@0: g.fillPath (internalPath1); andrewm@0: g.setColour (Colours::black); andrewm@0: g.strokePath (internalPath1, PathStrokeType (1.000f)); andrewm@0: andrewm@0: g.setColour (Colour (0xffa52a94)); andrewm@0: g.fillPath (internalPath2); andrewm@0: g.setColour (Colours::black); andrewm@0: g.strokePath (internalPath2, PathStrokeType (0.500f)); andrewm@0: andrewm@0: //[UserPaint] Add your own custom painting code here.. andrewm@0: /*MappingListComponent *parent = static_cast(getParentComponent()); andrewm@0: if(parent->isComponentSelected(this)) { andrewm@0: g.setColour (Colours::lightblue); andrewm@0: g.drawRect (0, 0, 544, 72, 5); andrewm@0: }*/ andrewm@0: //[/UserPaint] andrewm@0: } andrewm@0: andrewm@0: void MappingListItem::resized() andrewm@0: { andrewm@0: bypassToggleButton->setBounds (24, 44, 72, 24); andrewm@0: showDetailsButton->setBounds (456, 8, 80, 24); andrewm@0: mappingTypeLabel->setBounds (8, 4, 104, 40); andrewm@0: mappingShortEditorComponent->setBounds (120, 0, 328, 71); andrewm@0: noSettingsLabel->setBounds (208, 24, 150, 24); andrewm@0: deleteButton->setBounds (456, 44, 80, 20); andrewm@0: internalPath1.clear(); andrewm@0: internalPath1.startNewSubPath (544.0f, 72.0f); andrewm@0: internalPath1.lineTo (0.0f, 72.0f); andrewm@0: internalPath1.closeSubPath(); andrewm@0: andrewm@0: internalPath2.clear(); andrewm@0: internalPath2.startNewSubPath (119.0f, 16.0f); andrewm@0: internalPath2.lineTo (119.0f, 56.0f); andrewm@0: internalPath2.closeSubPath(); andrewm@0: andrewm@0: //[UserResized] Add your own custom resize handling here.. andrewm@0: //[/UserResized] andrewm@0: } andrewm@0: andrewm@0: void MappingListItem::buttonClicked (Button* buttonThatWasClicked) andrewm@0: { andrewm@0: //[UserbuttonClicked_Pre] andrewm@0: if(factory_ == 0) andrewm@0: return; andrewm@0: //[/UserbuttonClicked_Pre] andrewm@0: andrewm@0: if (buttonThatWasClicked == bypassToggleButton) andrewm@0: { andrewm@0: //[UserButtonCode_bypassToggleButton] -- add your button handler code here.. andrewm@0: bool bypass = bypassToggleButton->getToggleState(); andrewm@0: factory_->setBypassed(bypass); andrewm@0: //[/UserButtonCode_bypassToggleButton] andrewm@0: } andrewm@0: else if (buttonThatWasClicked == showDetailsButton) andrewm@0: { andrewm@0: //[UserButtonCode_showDetailsButton] -- add your button handler code here.. andrewm@41: // Create an extended editor window andrewm@41: MappingExtendedEditorWindow *window = listComponent_.extendedEditorWindowForFactory(factory_); andrewm@41: if(window != 0) { andrewm@41: window->setVisible(true); andrewm@41: window->toFront(true); andrewm@41: } andrewm@41: else if(factory_->hasExtendedEditor()) andrewm@41: listComponent_.openExtendedEditorWindow(factory_); andrewm@0: //[/UserButtonCode_showDetailsButton] andrewm@0: } andrewm@0: else if (buttonThatWasClicked == deleteButton) andrewm@0: { andrewm@0: //[UserButtonCode_deleteButton] -- add your button handler code here.. andrewm@0: // Display an alert to confirm the user wants to delete this mapping andrewm@0: AlertWindow::showOkCancelBox (AlertWindow::QuestionIcon, andrewm@0: "Delete mapping", andrewm@0: "Are you sure you want to delete this mapping?", andrewm@0: String::empty, andrewm@0: String::empty, andrewm@0: 0, andrewm@0: ModalCallbackFunction::forComponent (alertBoxResultChosen, this)); andrewm@0: //[/UserButtonCode_deleteButton] andrewm@0: } andrewm@0: andrewm@0: //[UserbuttonClicked_Post] andrewm@0: //[/UserbuttonClicked_Post] andrewm@0: } andrewm@0: andrewm@0: andrewm@0: andrewm@0: //[MiscUserCode] You can add your own definitions of your custom methods or any other code here... andrewm@0: andrewm@0: // Called when user clicks a result in the alert box to confirm deletion andrewm@0: void MappingListItem::alertBoxResultChosen(int result, MappingListItem *item) andrewm@0: { andrewm@0: if(result != 0) { andrewm@0: item->deleteMapping(); andrewm@0: } andrewm@0: } andrewm@0: andrewm@0: // Delete this mapping factory andrewm@0: void MappingListItem::deleteMapping() andrewm@0: { andrewm@0: listComponent_.deleteMapping(factory_); andrewm@0: } andrewm@0: andrewm@0: // Set the mapping factory and create any editor components it uses andrewm@0: void MappingListItem::setMappingFactory(MappingFactory *factory) andrewm@0: { andrewm@0: factory_ = factory; andrewm@0: andrewm@0: if(factory_->hasBasicEditor()) { andrewm@0: // Has a short editor: make one and add it to the window, using the same bounds andrewm@0: // as before andrewm@20: const juce::Rectangle& bounds = mappingShortEditorComponent->getBounds(); andrewm@0: mappingShortEditorComponent = factory_->createBasicEditor(); andrewm@0: addAndMakeVisible(mappingShortEditorComponent); andrewm@0: mappingShortEditorComponent->setBounds(bounds); andrewm@0: noSettingsLabel->setVisible(false); andrewm@0: } andrewm@0: else { andrewm@0: noSettingsLabel->setVisible(true); andrewm@0: mappingShortEditorComponent->setVisible(false); andrewm@0: } andrewm@0: andrewm@0: if(factory_->hasExtendedEditor()) { andrewm@0: showDetailsButton->setEnabled(true); andrewm@0: } andrewm@0: else { andrewm@0: showDetailsButton->setEnabled(false); andrewm@0: } andrewm@0: andrewm@0: synchronize(); andrewm@0: } andrewm@0: andrewm@0: void MappingListItem::synchronize() andrewm@0: { andrewm@0: if(factory_ == 0) andrewm@0: return; andrewm@0: andrewm@0: // Update the label and the bypass button andrewm@0: mappingTypeLabel->setText(factory_->factoryTypeName().c_str(), dontSendNotification); andrewm@0: if(factory_->bypassed() != MappingFactory::kBypassOff) andrewm@0: bypassToggleButton->setToggleState(true, dontSendNotification); andrewm@0: else andrewm@0: bypassToggleButton->setToggleState(false, dontSendNotification); andrewm@0: andrewm@0: // Update the short and long components if present andrewm@0: if(mappingShortEditorComponent != 0) andrewm@0: mappingShortEditorComponent->synchronize(); andrewm@0: } andrewm@0: //[/MiscUserCode] andrewm@0: andrewm@0: andrewm@0: //============================================================================== andrewm@0: #if 0 andrewm@0: /* -- Introjucer information section -- andrewm@0: andrewm@0: This is where the Introjucer stores the metadata that describe this GUI layout, so andrewm@0: make changes in here at your peril! andrewm@0: andrewm@0: BEGIN_JUCER_METADATA andrewm@0: andrewm@0: andrewm@0: andrewm@0: s 544 72 l 0 72 x andrewm@0: s 119 16 l 119 56 x andrewm@0: andrewm@0: andrewm@0: andrewm@0: andrewm@0: andrewm@0: END_JUCER_METADATA andrewm@0: */ andrewm@0: #endif andrewm@0: andrewm@0: andrewm@0: //[EndFile] You can add extra defines here... andrewm@0: #endif // TOUCHKEYS_NO_GUI andrewm@0: //[/EndFile]