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

47
LINES

< > BotCompany Repo | #1030803 // Extra Frame [additional frame for a module]

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

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

!7

cmodule2 ExtraFrame {
  S mainModuleID;
  transient JComponent visualization;
  bool deleteOnMainReload; // delete when main module is reloaded
  bool deleteOnReboot; // delete when OS is rebooted
  bool usePreferredSizeInitially;
  int minimumSizePlusY = 100; // fix the god damn window-too-small bug?
  
  visual visualization;
  
  start {
    componentFieldsToKeep = litset("visualization");
    
    if (deleteOnReboot && dm_isBooting())
      dm_deleteModule();
    
    // delete this module when main module is deleted
    dm_vmBus_onMessage_enter moduleDeleted(voidfunc(O mod) {
      if (dm_sameModule(mod, mainModuleID))
        dm_deleteModule();
    });
    
    dm_vmBus_onMessage_enter moduleReloaded(voidfunc(O mod) {
      if (deleteOnMainReload && dm_sameModule(mod, mainModuleID))
        dm_deleteModule();
    });
    
    // react to frame being disposed of by code
    dm_vmBus_onMessage_enter disposingInternalFrame(voidfunc(O frame) {
      if (frame == dm_frame(module()))
        dm_deleteModule();
    });
  }
  
  JComponent _getReloadData() { ret visualization; }
  void _setReloadData(JComponent data) { this.visualization = data; }
  
  bool _usePreferredSizeInitially() { ret usePreferredSizeInitially; }
  
  Pt minimumSize() {
    if (visualization == null) null;
    Dimension d = getMinimumSize(visualization);
    ret Pt(d.width, d.height+minimumSizePlusY);
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1030803
Snippet name: Extra Frame [additional frame for a module]
Eternal ID of this version: #1030803/13
Text MD5: e978fc6c580270f6055799944f2fbfb6
Transpilation MD5: 706e050ddfa8c1a6ef36edf3defc450c
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-03-29 13:40:11
Source code size: 1451 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 194 / 561
Version history: 12 change(s)
Referenced in: #1030804 - dm_showExtraFrame