/* * ======================================================== * * MPCC * Copyright 2024, Mahrouss Logic, all rights reserved. * * ======================================================== */ package org.elmahrouss; import javafx.collections.ObservableList; import javafx.scene.Node; import javafx.scene.control.Label; import javafx.scene.layout.*; import javafx.scene.paint.Color; /* * Editor view class */ public class CodeEditorView extends Pane { private Pane linePane; private Label codeText; private boolean readOnly; private HBox codeBox; private String fileName = "untitled.c"; private CodeEditorController codeEditorController; CodeEditorView() { super(); this.readOnly = readOnly; codeText = new Label(); codeText.setStyle("-fx-font-size: 20"); codeText.setTextFill(Color.color(1, 1, 1)); codeText.setWrapText(true); codeText.setTranslateX(70); codeText.setTranslateY(30); linePane = new Pane(); linePane.setStyle("-fx-background-color: #" + CodeEditorTheme.LINE_THEME); linePane.setMinSize(52, AppSettings.HEIGHT); linePane.setMaxSize(52, AppSettings.HEIGHT); this.setStyle("-fx-background-color: #" + CodeEditorTheme.BACKGROUND_THEME); this.setMinSize(AppSettings.WIDTH, AppSettings.HEIGHT); this.setMaxSize(AppSettings.WIDTH, AppSettings.HEIGHT); codeBox = new HBox(); codeBox.getChildren().add(codeText); this.getChildren().addAll(linePane, codeBox); } public boolean isReadOnly() { return readOnly; } public void setReadOnly(Boolean readOnly) { this.readOnly = readOnly; } public String getFilename() { return fileName; } public void setFilename(String fileName) { if (readOnly) return; this.fileName = fileName; } public String getContents() { if (this.codeText == null) return ""; return codeText.getText(); } public void setContents(String content) { if (this.codeText == null) return; this.codeText.setText(content); } CodeEditorController getController() { return codeEditorController; } void setController(CodeEditorController ctrl) { codeEditorController = ctrl; } }