Die Programmiersprache Ruby

Blog| Forum| Wiki  

Text-Editor mit FXRuby

Ein einfacher Text-Editor mit FXRuby (ähnlich TkEditor), den man leicht erweitern kann. Er enthält ein Textfeld (Scrollbars tauchen automatisch auf, sobald man sie benötigt) und ein einfaches Menu.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'fox16'
include Fox

class EditorFenster < FXMainWindow
  def initialize(pApp)
    @app = pApp
  
    super(pApp, "Fox Editor", nil, nil, DECOR_ALL, 20, 20, 800, 600)
  
    @menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP | LAYOUT_FILL_X)
    createMenu()
    
    createText()
  end
  
  def create
    super
    show(PLACEMENT_SCREEN)
  end
  
  def createMenu
    #menu: file
    menuFile = FXMenuPane.new(self)
    menuFileQuit = FXMenuCommand.new( menuFile, "&Beenden\tAlt-F4", nil, @app, FXApp::ID_QUIT)
    FXMenuTitle.new( @menubar, "&Datei", nil, menuFile)
  end
  
  def createText
    textfield = FXText.new(self, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y)
  end
end


app = FXApp.new("Fox Editor", "")
winEditor = EditorFenster.new(app)
app.create
app.run