Search in sources :

Example 41 with TableRow

use of android.widget.TableRow in project drmips by brunonova.

the class DrMIPSActivity method refreshAssembledCodeTable.

/**
	 * Refreshes the contents of the code table.
	 */
private void refreshAssembledCodeTable() {
    while (// remove all rows except header
    tblAssembledCode.getChildCount() > 1) tblAssembledCode.removeViewAt(1);
    AssembledInstruction instruction;
    TableRow row;
    TextView address, assembled, code;
    String codeLine;
    CPU cpu = getCPU();
    for (int i = 0; i < cpu.getInstructionMemory().getNumberOfInstructions(); i++) {
        instruction = cpu.getInstructionMemory().getInstruction(i);
        row = new TableRow(this);
        row.setOnClickListener(assembledCodeRowOnClickListener);
        address = new TextView(this);
        address.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, i * (Data.DATA_SIZE / 8)), cmbAssembledCodeFormat.getSelectedItemPosition()) + " ");
        address.setTextAppearance(this, android.R.style.TextAppearance_Medium);
        address.setTypeface(Typeface.MONOSPACE);
        assembled = new TextView(this);
        assembled.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, instruction.getData().getValue()), cmbAssembledCodeFormat.getSelectedItemPosition()) + " ");
        assembled.setTextAppearance(this, android.R.style.TextAppearance_Medium);
        assembled.setTypeface(Typeface.MONOSPACE);
        code = new TextView(this);
        codeLine = instruction.getLineNumber() + ": ";
        for (String label : instruction.getLabels()) codeLine += label + ": ";
        codeLine += instruction.getCodeLine();
        code.setText(codeLine);
        code.setTextAppearance(this, android.R.style.TextAppearance_Medium);
        code.setTypeface(Typeface.MONOSPACE);
        row.addView(address);
        row.addView(assembled);
        row.addView(code);
        tblAssembledCode.addView(row);
    }
    refreshAssembledCodeTableValues();
}
Also used : TableRow(android.widget.TableRow) CPU(brunonova.drmips.simulator.CPU) TextView(android.widget.TextView) Data(brunonova.drmips.simulator.Data) AssembledInstruction(brunonova.drmips.simulator.AssembledInstruction)

Example 42 with TableRow

use of android.widget.TableRow in project drmips by brunonova.

the class DrMIPSActivity method refreshDataMemoryTableValues.

/**
	 * Refreshes the values of the registers table.
	 */
public void refreshDataMemoryTableValues() {
    CPU cpu = getCPU();
    if (cpu.hasDataMemory()) {
        TextView address, value;
        TableRow row;
        for (int i = 0; i < cpu.getDataMemory().getMemorySize(); i++) {
            row = (TableRow) tblDataMemory.getChildAt(i + 1);
            address = (TextView) row.getChildAt(0);
            value = (TextView) row.getChildAt(1);
            address.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, i * (Data.DATA_SIZE / 8)), cmbDataMemoryFormat.getSelectedItemPosition()) + " ");
            value.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, cpu.getDataMemory().getDataInIndex(i)), cmbDataMemoryFormat.getSelectedItemPosition()));
            // Highlight memory positions being accessed
            int index = cpu.getDataMemory().getAddress().getValue() / (Data.DATA_SIZE / 8);
            boolean read = cpu.getDataMemory().getMemRead().getValue() == 1;
            boolean write = cpu.getDataMemory().getMemWrite().getValue() == 1;
            if (write && i == index) {
                if (read)
                    row.setBackgroundColor(Util.getThemeColor(this, R.attr.rwColor));
                else
                    row.setBackgroundColor(Util.getThemeColor(this, R.attr.writeColor));
            } else if (read && i == index)
                row.setBackgroundColor(Util.getThemeColor(this, R.attr.readColor));
            else
                // remove background color
                row.setBackgroundResource(0);
        }
        tblDataMemory.requestLayout();
    }
}
Also used : TableRow(android.widget.TableRow) CPU(brunonova.drmips.simulator.CPU) TextView(android.widget.TextView) Data(brunonova.drmips.simulator.Data)

Example 43 with TableRow

use of android.widget.TableRow in project drmips by brunonova.

the class DlgCodeHelp method setContents.

private void setContents(View rootView) {
    DrMIPSActivity activity = (DrMIPSActivity) getActivity();
    TableLayout tblInstructions = (TableLayout) rootView.findViewById(R.id.tblInstructions);
    TableLayout tblPseudos = (TableLayout) rootView.findViewById(R.id.tblPseudos);
    TableRow row;
    TextView inst, desc;
    tblInstructions.removeAllViews();
    tblPseudos.removeAllViews();
    CPU cpu = activity.getCPU();
    for (Instruction i : cpu.getInstructionSet().getInstructions()) {
        row = new TableRow(activity);
        inst = new TextView(activity);
        inst.setText(i.getUsage() + " ");
        row.addView(inst);
        desc = new TextView(activity);
        desc.setText("# " + (i.hasDescription() ? i.getDescription() : "-"));
        row.addView(desc);
        tblInstructions.addView(row);
    }
    for (PseudoInstruction i : cpu.getInstructionSet().getPseudoInstructions()) {
        row = new TableRow(activity);
        inst = new TextView(activity);
        inst.setText(i.getUsage() + " ");
        row.addView(inst);
        desc = new TextView(activity);
        desc.setText("# " + (i.hasDescription() ? i.getDescription() : "-"));
        row.addView(desc);
        tblPseudos.addView(row);
    }
}
Also used : PseudoInstruction(brunonova.drmips.simulator.PseudoInstruction) TableRow(android.widget.TableRow) CPU(brunonova.drmips.simulator.CPU) TextView(android.widget.TextView) PseudoInstruction(brunonova.drmips.simulator.PseudoInstruction) Instruction(brunonova.drmips.simulator.Instruction) DrMIPSActivity(brunonova.drmips.android.DrMIPSActivity) TableLayout(android.widget.TableLayout)

Aggregations

TableRow (android.widget.TableRow)43 TextView (android.widget.TextView)25 View (android.view.View)21 TableLayout (android.widget.TableLayout)14 Button (android.widget.Button)8 ImageView (android.widget.ImageView)8 CPU (brunonova.drmips.simulator.CPU)7 MediumTest (android.test.suitebuilder.annotation.MediumTest)6 ViewGroup (android.view.ViewGroup)4 Question (org.eyeseetea.malariacare.data.database.model.Question)4 SuppressLint (android.annotation.SuppressLint)3 ListView (android.widget.ListView)3 ScrollView (android.widget.ScrollView)3 Option (org.eyeseetea.malariacare.data.database.model.Option)3 AOptionQuestionView (org.eyeseetea.malariacare.views.question.AOptionQuestionView)3 IImageQuestionView (org.eyeseetea.malariacare.views.question.IImageQuestionView)3 IMultiQuestionView (org.eyeseetea.malariacare.views.question.IMultiQuestionView)3 IQuestionView (org.eyeseetea.malariacare.views.question.IQuestionView)3 NumberRadioButtonMultiquestionView (org.eyeseetea.malariacare.views.question.multiquestion.NumberRadioButtonMultiquestionView)3 DynamicStockImageRadioButtonSingleQuestionView (org.eyeseetea.malariacare.views.question.singlequestion.DynamicStockImageRadioButtonSingleQuestionView)3