Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

52
LINES

< > BotCompany Repo | #1030781 // Set Font Size For All Modules

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 1059K of libraries. Click here for Pure Java version (6455L/30K).

!7

cmodule2 FixFonts > DynEnabled {
  switchable int fontSize = 16;
  
  transient RSTOverQ rstUpdateAllModules = dm_rstOverModuleQ(this, r updateAllModules_impl);
  
  start {
    dm_onAnyModuleVisualized(mod -> {
      //print("Module " + mod + " visualized: " + dm_vis(mod));
      dm_q(r { updateModule(mod) });
    });
    dm_onFieldChangeAndNow(ll("fontSize", "enabled"), r updateAllModules);
    
    dm_vmBus_onMessage updateLayoutNow(voidfunc(JComponent c) {
      updateComponent(c);
    });
    
    dm_vmBus_answerToMessage formSafetyMargin(() -> 20);
  }
  
  visualize {
    JComponent c = super.visualize();
    addToControlArea(dm_intSpinnerWithLabel fontSize(1, 100));
    ret jfullcenter(c);
  }
  
  void updateAllModules { rstUpdateAllModules.trigger(); }
  
  void updateAllModules_impl {
    if (!enabled) ret;
    L mods = lambdaFilter dm_isShowing(dm_moduleIDs());
    if (empty(mods)) ret;
    time {
      print("Setting font size of " + nModules(mods) + " to " + fontSize + "...");
      for (O mod : mods)
        updateModule(mod);
    }
  }
  
  void updateModule(O mod) {
    if (!enabled) ret;
    updateComponent(dm_vis(mod));
  }
  
  void updateComponent(JComponent c) {
    if (c != null) swing {
      setAllStandardFontSizesRecursively(c, fontSize, c2 ->
        !eq(shortClassName(c2), "RSyntaxTextArea"));
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030781
Snippet name: Set Font Size For All Modules
Eternal ID of this version: #1030781/29
Text MD5: d7a80caf6e55aa6c2aeabf2f1438f194
Transpilation MD5: 59c4b320fd6a9f6f1acf5d61e7cecb65
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-04-05 23:14:50
Source code size: 1409 bytes / 52 lines
Pitched / IR pitched: No / No
Views / Downloads: 207 / 4145
Version history: 28 change(s)
Referenced in: [show references]