Skip to content

Commit e024586

Browse files
committed
refactor
1 parent 4614cdc commit e024586

20 files changed

+81
-285
lines changed
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package haxe.ui.backend;
22

3+
import cs.system.drawing.Size;
34
import cs.system.windows.forms.Application;
45
import cs.system.windows.forms.Form;
5-
import haxe.ui.Preloader.PreloadItem;
6-
import cs.system.drawing.Size;
76

8-
class AppBase {
7+
class AppImpl extends AppBase {
98
private var _form:Form;
109
private var _onEnd:Void->Void;
1110

@@ -14,12 +13,12 @@ class AppBase {
1413
Application.SetCompatibleTextRenderingDefault(false);
1514
}
1615

17-
private function build() {
16+
private override function build() {
1817
_form = new Form();
1918
_form.Text = Toolkit.backendProperties.getProp("haxe.ui.winforms.form.title", "");
2019
}
2120

22-
private function init(onReady:Void->Void, onEnd:Void->Void = null) {
21+
private override function init(onReady:Void->Void, onEnd:Void->Void = null) {
2322
_onEnd = onEnd;
2423

2524
var formAutoSize = Toolkit.backendProperties.getPropBool("haxe.ui.winforms.form.autosize", true);
@@ -37,20 +36,16 @@ class AppBase {
3736
onReady();
3837
}
3938

40-
private function getToolkitInit():ToolkitOptions {
39+
private override function getToolkitInit():ToolkitOptions {
4140
return {
4241
form: _form
4342
};
4443
}
4544

46-
public function start() {
45+
public override function start() {
4746
Application.Run(_form);
4847
if (_onEnd != null) {
4948
_onEnd();
5049
}
5150
}
52-
53-
private function buildPreloadList():Array<PreloadItem> {
54-
return null;
55-
}
5651
}
Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
package haxe.ui.backend;
22

3-
import haxe.io.Bytes;
4-
import haxe.ui.assets.ImageInfo;
5-
import haxe.ui.assets.FontInfo;
63
import cs.system.drawing.Image;
74
import cs.system.io.MemoryStream;
5+
import haxe.io.Bytes;
6+
import haxe.ui.assets.ImageInfo;
87

9-
class AssetsBase {
10-
public function new() {
11-
12-
}
13-
14-
private function getTextDelegate(resourceId:String):String {
15-
return null;
16-
}
17-
18-
private function getImageInternal(resourceId:String, callback:ImageInfo->Void) {
8+
class AssetsImpl extends AssetsBase {
9+
private override function getImageInternal(resourceId:String, callback:ImageInfo->Void) {
1910
imageFromBytes(Resource.getBytes(resourceId), callback);
2011
}
2112

22-
private function getImageFromHaxeResource(resourceId:String, callback:String->ImageInfo->Void) {
13+
private override function getImageFromHaxeResource(resourceId:String, callback:String->ImageInfo->Void) {
2314
imageFromBytes(Resource.getBytes(resourceId), function(imageInfo) {
2415
callback(resourceId, imageInfo);
2516
});
2617
}
2718

28-
public function imageFromBytes(bytes:Bytes, callback:ImageInfo->Void) {
19+
public override function imageFromBytes(bytes:Bytes, callback:ImageInfo->Void) {
2920
if (bytes == null) {
3021
callback(null);
3122
}
@@ -39,12 +30,4 @@ class AssetsBase {
3930
}
4031
callback(imageInfo);
4132
}
42-
43-
private function getFontInternal(resourceId:String, callback:FontInfo->Void) {
44-
callback(null);
45-
}
46-
47-
private function getFontFromHaxeResource(resourceId:String, callback:String->FontInfo->Void) {
48-
callback(resourceId, null);
49-
}
5033
}

haxe/ui/backend/BackendBase.hx

Lines changed: 0 additions & 5 deletions
This file was deleted.

haxe/ui/backend/BackendImpl.hx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package haxe.ui.backend;
2+
3+
class BackendImpl {
4+
public static var id:String = "winforms";
5+
}

haxe/ui/backend/CallLaterBase.hx renamed to haxe/ui/backend/CallLaterImpl.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package haxe.ui.backend;
22

3-
class CallLaterBase {
3+
class CallLaterImpl {
44
public function new(fn:Void->Void) {
55
fn();
66
}

haxe/ui/backend/ComponentBase.hx renamed to haxe/ui/backend/ComponentImpl.hx

Lines changed: 15 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,20 @@ import cs.system.windows.forms.Panel;
1212
import haxe.ui.backend.winforms.StyleHelper;
1313
import haxe.ui.containers.Box;
1414
import haxe.ui.core.Component;
15-
import haxe.ui.core.ImageDisplay;
16-
import haxe.ui.core.TextDisplay;
17-
import haxe.ui.core.TextInput;
1815
import haxe.ui.events.MouseEvent;
1916
import haxe.ui.events.UIEvent;
2017
import haxe.ui.styles.Style;
21-
import haxe.ui.geom.Rectangle;
2218

23-
class ComponentBase {
19+
class ComponentImpl extends ComponentBase {
2420
private var _eventMap:Map<String, UIEvent->Void> = new Map<String, UIEvent->Void>();
2521

2622
public var control:Control;
2723

2824
public function new() {
25+
super();
2926
}
3027

31-
public function handleCreate(native:Bool) {
28+
public override function handleCreate(native:Bool) {
3229
var className:String = Type.getClassName(Type.getClass(this));
3330
var nativeComponentClass:String = Toolkit.nativeConfig.query('component[id=${className}].@class', 'System.Windows.Forms.Panel', null);
3431

@@ -44,15 +41,15 @@ class ComponentBase {
4441
}
4542
}
4643

47-
private function handlePosition(left:Null<Float>, top:Null<Float>, style:Style) {
44+
private override function handlePosition(left:Null<Float>, top:Null<Float>, style:Style) {
4845
if (control == null) {
4946
return;
5047
}
5148

5249
control.Location = new Point(Std.int(left), Std.int(top));
5350
}
5451

55-
private function handleSize(width:Null<Float>, height:Null<Float>, style:Style) {
52+
private override function handleSize(width:Null<Float>, height:Null<Float>, style:Style) {
5653
if (control == null) {
5754
return;
5855
}
@@ -66,7 +63,7 @@ class ComponentBase {
6663
control.Size = new Size(Std.int(width), Std.int(height));
6764
}
6865

69-
private function handleReady() {
66+
private override function handleReady() {
7067
if (Std.is(control, cs.system.windows.forms.TrackBar)) { // super crappy hack, trackbars _always_ have a grey background... if you can believe that!
7168
var parent = findParent(cs.system.windows.forms.TabControl);
7269
if (parent != null) {
@@ -75,92 +72,17 @@ class ComponentBase {
7572
}
7673
}
7774

78-
private function handleClipRect(value:Rectangle) {
79-
}
80-
81-
public function handlePreReposition() {
82-
}
83-
84-
public function handlePostReposition() {
85-
}
86-
87-
private function handleVisibility(show:Bool) {
88-
}
89-
90-
//***********************************************************************************************************
91-
// Text related
92-
//***********************************************************************************************************
93-
private var _textDisplay:TextDisplay;
94-
public function createTextDisplay(text:String = null):TextDisplay {
95-
if (_textDisplay == null) {
96-
_textDisplay = new TextDisplay();
97-
}
98-
if (text != null) {
99-
_textDisplay.text = text;
100-
}
101-
return _textDisplay;
102-
}
103-
104-
public function getTextDisplay():TextDisplay {
105-
return createTextDisplay();
106-
}
107-
108-
public function hasTextDisplay():Bool {
109-
return (_textDisplay != null);
110-
}
111-
112-
private var _textInput:TextInput;
113-
public function createTextInput(text:String = null):TextInput {
114-
if (_textInput == null) {
115-
_textInput = new TextInput();
116-
}
117-
if (text != null) {
118-
_textInput.text = text;
119-
}
120-
return _textInput;
121-
}
122-
123-
public function getTextInput():TextInput {
124-
return createTextInput();
125-
}
126-
127-
public function hasTextInput():Bool {
128-
return (_textInput != null);
129-
}
130-
131-
//***********************************************************************************************************
132-
// Image related
133-
//***********************************************************************************************************
134-
private var _imageDisplay:ImageDisplay;
135-
public function createImageDisplay():ImageDisplay {
136-
if (_imageDisplay == null) {
137-
_imageDisplay = new ImageDisplay();
138-
}
139-
return _imageDisplay;
140-
}
141-
142-
public function getImageDisplay():ImageDisplay {
143-
return createImageDisplay();
144-
}
145-
146-
public function hasImageDisplay():Bool {
147-
return (_imageDisplay != null);
148-
}
149-
150-
public function removeImageDisplay() {
151-
if (_imageDisplay != null) {
152-
_imageDisplay = null;
153-
}
75+
private override function handleVisibility(show:Bool) {
15476
}
15577

15678
//***********************************************************************************************************
15779
// Display tree
15880
//***********************************************************************************************************
159-
private function handleSetComponentIndex(child:Component, index:Int) {
81+
private override function handleSetComponentIndex(child:Component, index:Int) {
16082

16183
}
16284

163-
private function handleAddComponent(child:Component):Component {
85+
private override function handleAddComponent(child:Component):Component {
16486
if (Std.is(this.control, cs.system.windows.forms.TabControl)) {
16587
var tabControl = cast(this.control, cs.system.windows.forms.TabControl);
16688

@@ -191,20 +113,20 @@ class ComponentBase {
191113
return child;
192114
}
193115

194-
private function handleAddComponentAt(child:Component, index:Int):Component {
116+
private override function handleAddComponentAt(child:Component, index:Int):Component {
195117
return child;
196118
}
197119

198-
private function handleRemoveComponent(child:Component, dispose:Bool = true):Component {
120+
private override function handleRemoveComponent(child:Component, dispose:Bool = true):Component {
199121
control.Controls.Remove(child.control);
200122
return child;
201123
}
202124

203-
private function handleRemoveComponentAt(index:Int, dispose:Bool = true):Component {
125+
private override function handleRemoveComponentAt(index:Int, dispose:Bool = true):Component {
204126
return null;
205127
}
206128

207-
private function applyStyle(style:Style) {
129+
private override function applyStyle(style:Style) {
208130
if (control == null) {
209131
return;
210132
}
@@ -249,7 +171,7 @@ class ComponentBase {
249171
//***********************************************************************************************************
250172
// Events
251173
//***********************************************************************************************************
252-
private function mapEvent(type:String, listener:UIEvent->Void) {
174+
private override function mapEvent(type:String, listener:UIEvent->Void) {
253175
switch (type) {
254176
case MouseEvent.CLICK:
255177
if (_eventMap.exists(type) == false) {
@@ -270,7 +192,7 @@ class ComponentBase {
270192
}
271193
}
272194

273-
private function unmapEvent(type:String, listener:UIEvent->Void) {
195+
private override function unmapEvent(type:String, listener:UIEvent->Void) {
274196
switch (type) {
275197
case MouseEvent.CLICK:
276198
_eventMap.remove(type);

haxe/ui/backend/ComponentSurface.hx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package haxe.ui.backend;
2+
3+
class ComponentSurface {
4+
public function new() {
5+
}
6+
}

haxe/ui/backend/EventBase.hx

Lines changed: 0 additions & 13 deletions
This file was deleted.

haxe/ui/backend/EventImpl.hx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package haxe.ui.backend;
2+
3+
class EventImpl extends EventBase {
4+
}

haxe/ui/backend/ImageDisplayBase.hx

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)