Forum > General

Text justification problem when converting from graph unit to wingraph unit

(1/1)

dculp:
I'm converting a console program that uses the graph unit to one that uses wingraph.

Compatibility problem -
In the graphh.inc unit the vertical text justification consts are defined as -

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---       BottomText = 0;       TopText    = 2; 
However, in wingraph.pas these are defined as -

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---        BottomText = word(1);        TopText = word(0); 
I'm leery of redefining these directly in the above units.

I'm using a global conditional define Use_WinGraph in the following form -

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---        {$ifdef Use_WinGraph}                WinGraph statements here        {$else}                graph statements here        {$endif} 
(I'm using this define, in part, so that I can revert to using the graph unit in case wingraph causes any problems that can't be easily resolved -- i.e., I just won't define Use_WinGraph.)

I could search through all of my graphic source code for BottomText and TopText and apply the above conditional define. However, is there a better way (also in case I find similar problems with other vars or consts)?

Thanks,
Don C.

sky_khan:
I think you can redefine those constants in your own unit like below and they will change according to your conditional defines.

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  graph,wingraph; const{$IFDEF USE_Wingraph}  BottomText = wingraph.BottomText;  TopText = wingraph.TopText;{$ELSE}  BottomText = graph.BottomText;  TopText = graph.TopText;{$ENDIF} var  VerticalAlign : integer;begin  VerticalAlign:=BottomText;  writeln('Align:',VerticalAlign);end. 

Navigation

[0] Message Index

Go to full version