Click Here
home features news forums classifieds faqs links search
6155 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
22 crawler(s) on-line.
 95 guest(s) on-line.
 0 member(s) on-line.



You are an anonymous user.
Register Now!

/  Forum Index
   /  Amiga Development
      /  What to look at if I want to do an texteditor
Register To Post

Goto page ( 1 | 2 | 3 Next Page )
PosterThread
jonssonj 
What to look at if I want to do an texteditor
Posted on 1-Feb-2012 15:34:40
#1 ]
Regular Member
Joined: 1-Mar-2004
Posts: 299
From: Sweden, Bjärred

Hello all!

I would like to learn how to do an texteditor from scratch. Where do I begin reading?, what part of the amiga operating system do I need to use?

f.eg.

Do I need to use the rastport of windows?
How do I get the cursor in a window?
Is there a cursor that blinks that you can get from the ROM library?
How do I do to get the sliders of the window to work correctly?
How do I save the text that scrolls out of the window?
How do I have different fonts in the same row/line of text?
How do I do to have different colours on the same row/line of text?

Thanks for any help you can give me!
BR
JJ

_________________
A1 X1000 is here !!!

 Status: Offline
Profile     Report this post  
thomas 
Re: What to look at if I want to do an texteditor
Posted on 1-Feb-2012 16:53:33
#2 ]
Super Member
Joined: 28-May-2003
Posts: 1155
From: Germany

Quote:

Do I need to use the rastport of windows?


Every drawing operation involves a rastport. If you want to draw directly into a window, you use the window's rastport. If you draw to an off-screen bitmap you create your own temorary rastport and then blit the temporary bitmap into the window's rastport.

Quote:

How do I get the cursor in a window?
Is there a cursor that blinks that you can get from the ROM library?


The only way to get a cursor from the system that I know is to use console.device. But this limits you to a console-like display without different fonts and with very limited colors. And the cursor does not blink.

Better you draw the cursor yourself.

Quote:

How do I do to get the sliders of the window to work correctly?


Not sure what you want to know here. If you use BOOPSI scrollers, you can set Total, Visible and Top attributes. And you can let it send you messages when the user moves the bar.

If you use old-fashioned struct Gadget, you need to calculate and set BODY and POT fields of the PropInfo structure appropriately.

Quote:

How do I save the text that scrolls out of the window?


Usually one stores the entire text in an internal buffer and then draws only the part of the buffer which is visible.


Quote:

How do I have different fonts in the same row/line of text?
How do I do to have different colours on the same row/line of text?


You draw each section seperately and set font and color before you draw a section.


_________________
Email: thomas-rapp@web.de
Home: thomas-rapp.homepage.t-online.de

 Status: Offline
Profile     Report this post  
ChrisH 
Re: What to look at if I want to do an texteditor
Posted on 1-Feb-2012 18:51:29
#3 ]
Elite Member
Joined: 30-Jan-2005
Posts: 6679
From: Unknown

@jonssonj
If you want to draw "everything" yourself (i.e. not using any pre-defined GUI elements except for menu & window/screen border/titlebar) then you only need to look at graphics.library . You can define font & colour, draw text, draw lines, scroll areas, etc.

Well, first you need to open a window (and maybe a screen), so you will need intuition.library too.

For input, I guess you need to do a little bit of Intuition event handling for keyboard & mouse, but this is pretty easy. See intuition.library .

If you want to define your own menus, then I think intuition.library also covers you there, although menus are best left till later as IMHO they are overly complex & error prone.

And even later, you can look at adding more windows, for proper GUI stuff like preferences.

For loading & saving files you can avoid GUI stuff, and just use the asl.library .

Quote:
How do I save the text that scrolls out of the window?

You DON'T. What you should be doing is drawing your text based upon the text stored in memory & a value indicating how far you have scrolled. Later on you can add optimisations that avoid redrawing the whole window, by using the blitter to scroll the already-visible part.


P.S. If you draw text with a solid background colour (it's actually quite hard to not do this) then you get anti-aliasing for free on OS4. Your "cursor" could simply be 1 character in your text, but drawn with a different background colour.

Last edited by ChrisH on 01-Feb-2012 at 06:55 PM.
Last edited by ChrisH on 01-Feb-2012 at 06:53 PM.

_________________

 Status: Offline
Profile     Report this post  
ChrisH 
Re: What to look at if I want to do an texteditor
Posted on 1-Feb-2012 19:00:18
#4 ]
Elite Member
Joined: 30-Jan-2005
Posts: 6679
From: Unknown

@jonssonj
Or alternatively you could use the PortablE language which comes with easy ways to handle graphics (and text!), as well as GUIs. No need to worry the Amiga's somewhat disorganised API, well, not unless you want to do it that way!

Last edited by ChrisH on 01-Feb-2012 at 07:00 PM.

_________________

 Status: Offline
Profile     Report this post  
Belxjander 
Re: What to look at if I want to do an texteditor
Posted on 1-Feb-2012 19:00:52
#5 ]
Cult Member
Joined: 4-Jan-2005
Posts: 557
From: Chiba prefecture Japan

@jonssonj

are you opening only a Window with the text in it?

What sort of access to any features will you have and what sort of features do you want?

I would personally look at doing a set of buffered string handling functions and then work out
how you want to display the text from the strings so show where and what string you are editing.

What are you working with? and how is it stored?

these are the type of questions that come to mind for me at least...

Hope it helps

 Status: Offline
Profile     Report this post  
tonyw 
Re: What to look at if I want to do an texteditor
Posted on 1-Feb-2012 21:55:53
#6 ]
Elite Member
Joined: 8-Mar-2003
Posts: 3240
From: Sydney (of course)

If you can be satisfied with a single font, then you could use the texteditor.gadget to display your text. It's only a display, of course, you still have to invent your own method of storing all the lines of text and displaying only those that are on screen.

Frankly, I think the nitty-gritty of the display is nothing compared to the rest of the program - receiving input from keyboard, mouse and GUI inputs, maintaining the current text database, deciding how you are going to handle changes in window size. For instance, does text wrap or is it cut off at the right hand edge? If it wraps, you then have an extra line to display between the line on each side and you have to insert that new partial line into the database.

If you are serious about the job, you could start by designing and implementing the database first. You can always display the content using existing gadgets and classes. Then, later, you could write all the WYSIWYG functions to display it nicely.


_________________
cheers
tony

Hyperion Support Forum: http://forum.hyperion-entertainment.biz/index.php

 Status: Offline
Profile     Report this post  
jonssonj 
Re: What to look at if I want to do an texteditor
Posted on 1-Feb-2012 22:12:33
#7 ]
Regular Member
Joined: 1-Mar-2004
Posts: 299
From: Sweden, Bjärred

@thomas

Ok, thanks for trying to clearify all my questions. So I have got a few more questions now.

Quote:
Quote: Do I need to use the rastport of windows? Every drawing operation involves a rastport. If you want to draw directly into a window, you use the window's rastport. If you draw to an off-screen bitmap you create your own temorary rastport and then blit the temporary bitmap into the window's rastport.


Is it a good technique to draw to an off-screen bitmap first and then blit this to the windows rastport? is it this that is called double buffering?

In this case, do I create my own bitmap AND my own rastport? Or can I blit my bitmap directly to the windows rastport?

Quote:
Quote: How do I get the cursor in a window? Is there a cursor that blinks that you can get from the ROM library? The only way to get a cursor from the system that I know is to use console.device. But this limits you to a console-like display without different fonts and with very limited colors. And the cursor does not blink. Better you draw the cursor yourself.


So, can I use threaded programming when doing the cursor that blinks? Is there support for threaded programming on the Amiga? Is it possible to have different threads that listens to user input, one thread that handles the cursor and one thread that listens to system events? Or is this a bad idea?


Quote:
Quote: How do I do to get the sliders of the window to work correctly? Not sure what you want to know here. If you use BOOPSI scrollers, you can set Total, Visible and Top attributes. And you can let it send you messages when the user moves the bar. If you use old-fashioned struct Gadget, you need to calculate and set BODY and POT fields of the PropInfo structure appropriately.


I want to learn how to use the sliders in a correct way. How do I get the right size of the sliders so that they mirrors the content of the window. If I have 300 rows of text the sliders should be one size but the should be smaller if I have 3000 rows of text. BOOPSI scrollers, is that reaction GUI?


Quote:
Quote: How do I save the text that scrolls out of the window? Usually one stores the entire text in an internal buffer and then draws only the part of the buffer which is visible.


Ok, that sounds logically of course. So, what's the best way of storing the text? In my mind and when reading your answers it seems that I would need to store each character with all of its attributes. Maybe a linked list with the color, font, size and so on?

When drawing the text to my bitmap, is it the function graphics.library/Text() That I'm suppose to use? or is it some other function like the PrintIText() function, example below:

myIText.FrontPen = myTEXTPEN;
myIText.BackPen = myBACKGROUNDPEN;
myIText.DrawMode = JAM2;
myIText.LeftEdge = MYTEXT_LEFT;
myIText.TopEdge = MYTEXT_TOP;
myIText.ITextFont = &myTextAttr;
myIText.IText = "Hello, World. ";
myIText.NextText = NULL;

/* Draw the text string at 10,10 */
PrintIText(win->RPort,&myIText,10,10);


Would the program be to slow if I used the PrintIText function on a offscreen bitmap and rastport and then blitted this offscreen rastport to the windows rastport?


@ChrisH

Quote:
If you draw text with a solid background colour (it's actually quite hard to not do this) then you get anti-aliasing for free on OS4. Your "cursor" could simply be 1 character in your text, but drawn with a different background colour.


That was a really good idea, maybe. But I would still need to get the thing blinking and have to save the character behind in some way.

PortableE does not interest me at the moment. I can't describe why, but I just love the c-programming language.... :)


@Belxjander

Quote:
are you opening only a Window with the text in it?


Yes, that was my thought, to begin with. Just a simple window where a user can enter text in different colors, fonts and sizes and of course some way of saving the text and loading the text. This seems to be enough right now.... :)

Quote:
What sort of access to any features will you have and what sort of features do you want?


At the moment this is only a way for me to program on the Amiga. I know how to program in the c-language, but I don't know how to do serious stuff on the Amiga, with the GUI and so on. I thought that by doing a simple texteditor I can learn very much.

Quote:
I would personally look at doing a set of buffered string handling functions and then work out how you want to display the text from the strings so show where and what string you are editing.


Can you elaborate what you mean by "buffered" string handling? I thought of saving the text in some sort of linked list.

Quote:
What are you working with? and how is it stored?


I just try to do a simple texteditor and for the moment. How I'm gonna store the text in files, I don't know right now. Maybe I could save it in a simple xml format or something like that. If there is no xml parser for Amiga then I will just have to implement a simple xml parser. That!!!, I feel I could handle... :)

_________________
A1 X1000 is here !!!

 Status: Offline
Profile     Report this post  
RuDeE 
Re: What to look at if I want to do an texteditor
Posted on 1-Feb-2012 22:26:04
#8 ]
Regular Member
Joined: 26-Jul-2003
Posts: 154
From: Haugesund, Norway

@jonssonj

Quote:
Is it a good technique to draw to an off-screen bitmap first and then blit this to the windows rastport? is it this that is called double buffering? In this case, do I create my own bitmap AND my own rastport? Or can I blit my bitmap directly to the windows rastport?


This is double buffering yes, or buffered painting. It's a good idea to do this to avoid flickering. You render everything you want to into an off screen bitmap and then blit the whole thing to your window when you're done.

I have not too much experience with Amiga API but if you have done some Windows programming I guess you can compare the rasterport to what is called a device context in Windows. You need to create a "memory" rasterport to set up a context in which you can do your off-screen drawing.

_________________
God is a man with a grey beard. His name is Jay Glenn Miner.

 Status: Offline
Profile     Report this post  
Trixie 
Re: What to look at if I want to do an texteditor
Posted on 2-Feb-2012 6:51:39
#9 ]
Amiga Developer Team
Joined: 1-Sep-2003
Posts: 2119
From: Czech Republic

@jonssonj

Quote:
BOOPSI scrollers, is that reaction GUI?

Not necessarily. ReAction is a GUI toolkit built on top of Intuition's BOOPSI system; if you're not planning to use the toolkit for your editor's GUI, then you won't use a ReAction scroller. Intuition comes with its own BOOPSI scroller class - the propgclass. It is fully documented in the ROM Kernel Reference Manual: Libraries, chapter 12.

@thomas

Quote:
If you use old-fashioned struct Gadget, you need to calculate and set BODY and POT fields of the PropInfo structure appropriately.

If he's making a text editor, he'll probably want to place the scroller inside the window border, like editors normally have it. For that I recommend using the BOOPSI scroller, it's much better integrated with windows than the old Intuition prop gadget.

Last edited by Trixie on 02-Feb-2012 at 06:59 AM.
Last edited by Trixie on 02-Feb-2012 at 06:54 AM.

_________________
The Rear Window blog

AmigaOne X5000/020 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition

 Status: Offline
Profile     Report this post  
puppy 
Re: What to look at if I want to do an texteditor
Posted on 2-Feb-2012 10:22:03
#10 ]
Member
Joined: 22-Oct-2003
Posts: 13
From: Spain

@jonssonj

Encoding is a must !!! (utf8 bom, no bom, iso ...)

 Status: Offline
Profile     Report this post  
RNS-Amiga-Scientist 
Re: What to look at if I want to do an texteditor
Posted on 2-Feb-2012 10:32:56
#11 ]
Member
Joined: 12-Nov-2010
Posts: 84
From: Warsaw, Poland

@jonssonj

I personally am writing a text editor called Assistant, so I can clarify various things for you:

Quote:
Do I need to use the rastport of windows?

Yes, and use WFLG_GIMMEZEROZERO flag windows. Use ClearEOL() and ClearScreen() to clear end-of-line and the rest of the screen. These are functions from graphics.library great to use with text-editors.

Quote:
How do I get the cursor in a window?

You type in letter with SetAPen() and SetBPen() or use SetDrMd() with COMPLEMENT.

Quote:
How do I save the text that scrolls out of the window?

You save the text in buffers that is logic part of the text (the displayed is physic part). The best method to store buffers in text editors is to store it in list of strings.

Quote:
How do I have different fonts in the same row/line of text?

That's tricky! Then you want to make Word or WordWorth type program. You must write proper function that covers that. It requires more effort than simple text editor (not word processor).

Quote:
How do I do to have different colours on the same row/line of text?

That's simple. Write the text with Text() and the inner cursor of RastPort will move you to the end of the word/words. You change colors with SetAPen() and SetBPen() then write the rest of the line.

I hope I helped, please write if I did so :)

Last edited by RNS-Amiga-Scientist on 02-Feb-2012 at 10:34 AM.
Last edited by RNS-Amiga-Scientist on 02-Feb-2012 at 10:33 AM.

 Status: Offline
Profile     Report this post  
salass00 
Re: What to look at if I want to do an texteditor
Posted on 2-Feb-2012 11:58:11
#12 ]
Elite Member
Joined: 31-Oct-2003
Posts: 2707
From: Finland

@RNS-Amiga-Scientist

Quote:

Yes, and use WFLG_GIMMEZEROZERO flag windows. Use ClearEOL() and ClearScreen() to clear end-of-line and the rest of the screen. These are functions from graphics.library great to use with text-editors.


WFLG_GIMMEZEROZERO windows use more memory than normal windows so don't use if you can avoid it. ClearEOL() and ClearScreen() type functions should not be used in non-GZZ windows as they do not respect window borders and even if you are using a GZZ window you might not want to be using the entire window contents for text display (better to use functions such as EraseRect() or RectFill() that allow to specify exactly what area to clear IMHO).

 Status: Offline
Profile     Report this post  
RNS-Amiga-Scientist 
Re: What to look at if I want to do an texteditor
Posted on 2-Feb-2012 12:21:49
#13 ]
Member
Joined: 12-Nov-2010
Posts: 84
From: Warsaw, Poland

@salass00

I've read that GimmeZeroZero windows are more difficult to handle by the AmigaOS, but it's not a big problem. On the other hand ClearEOL() and ClearScreen() had been written especially for text-editors and should be used only in them. EraseRect() and RectFill() require specifying places to clear, while both of the previously mentioned functions does not.

Also note that if he uses dedicated functions he doesn't need to make use of double-buffering, while if he doesn't he will require it to avoid flashing of the document.

Regards.

Last edited by RNS-Amiga-Scientist on 02-Feb-2012 at 12:25 PM.

 Status: Offline
Profile     Report this post  
jonssonj 
Re: What to look at if I want to do an texteditor
Posted on 2-Feb-2012 15:52:44
#14 ]
Regular Member
Joined: 1-Mar-2004
Posts: 299
From: Sweden, Bjärred

@all

Thanks for all help.

If you have more thoughts of good practice or other things that I have to consider, then I will be very happy if you can input it here to this thread.

I will try to do some example code to open an intuition window and use the Text() function, just to see how it works. If I use the Intuition window, then it is fully documented in the RKRM?

Is the RKRM online somewhere?

/JJ

_________________
A1 X1000 is here !!!

 Status: Offline
Profile     Report this post  
Wanderer 
Re: What to look at if I want to do an texteditor
Posted on 2-Feb-2012 16:07:04
#15 ]
Cult Member
Joined: 16-Aug-2008
Posts: 654
From: Germany

@jonssonj

Here are my 2 cents: (yes, I have written a texteditor before (TuiTED), you may check it out and see if this is what you are aiming at)

Quote:

Do I need to use the rastport of windows?

Yes, the rastport is the drawing context that is needed for any gfx operation, such as drawing lines, boxes or text.

Quote:

How do I get the cursor in a window?

Two suggestions:
1. draw an inverted rectangle RecFill(rp,...)
or an inverted line using Move(rp,...) and Draw(rp,...).
You can set the rastport to "invert" mode with SetDrMd(rp,-1).
Set it back to blocky by 0 (JAM1) or transparent 1 (JAM2).

2. Draw the character you are located at with a different forground
and background pen (SetAPen/SetBPen).
Pro: you can use any color you like
Con: you have to take care about the color, invert is easier and
doesnt require to draw the character, only a box/line)

Quote:

Is there a cursor that blinks that you can get from the ROM library?

No. You want to react to IDCMP_INTUITICK message, that comes
ticking in about 5Hz or something. Every N ticks, you change the state
of the cursor anmd redraw it.

Quote:

How do I do to get the sliders of the window to work correctly?

I assume you have created the sliders. Well actually what you
want are "Scrollers" , not sliders.
Scrollers usually have a "Top", "Visible" and "Total" value.
Top is the first visible line
Visible are the lines visible on your Textbox Widgets (you need to estimate this yoruself)
Total are the total amount of lines in your textbuffer.

Quote:

How do I save the text that scrolls out of the window?

The text is stored entirely in one textbuffer. You draw on the window
the part of the text buffer that is visible on demand.
I would not introduce a concept of a second buffer that holds visible text.

You need to access the text fast, line by line. I recommend to have an array
of pointers to a string.

Quote:

How do I have different fonts in the same row/line of text?

You need some formatting information along with the text.
In TuiTED, the formatting infromation is stored directly in the text of the line.
That's ok, but sometimes makes things complicated.
I recommend to store the information in a second buffer.

You implement then your own, "rich" version of "Text(rp,...), that also takes the formatting information into account and draws the text piece-wise, everytime the formatting changes (color, font, style) you need to set this infromation to the rastport and then call Text() that draws the piece until the next change happens.
Dont draw character by character, that will be sloooooow. Draw every chunk that has the same formatting in one call to Text(). So things are fast with few formattings, and get only slow if heavy formatting is done (which is rare).

Quote:

How do I do to have different colours on the same row/line of text?

Same as question above.

SetAPen() sets the forground color
SetBPen() sets the background color
SetDrMd() sets the drawing mode
Text() writes some text to the window
TextLength() estimates the pixel length of a chunk of text
RectFill() draws a rectangle
SetFont() sets the font to the rastport
SetSoftStyle() sets the style of the font (bold, italic, etc.)
Move() sets some kind of invisible "turtle" to the rastport
Draw() draws a line from the last "turtle" point to this one

When you scroll in your Textbox, you can either redraw everything or you can use ScrollWindowRaster() and refresh only what is scorlled-in. Scrolling makes only sense of course, if the scroll event scrolls less that a visbile page.

Ah, and one last secret that does some magic to the refresh:
Set the window layers backfill hook to NULL. AmigaOS will then NOT fill damaged areas with the current background color (usually pen #0). If you are taking always care of refreshing, you avoid flickering this way completely.

That is pretty much all you need, apart from you window and event handling.

No multithreading required. That makes things only complicated.

Some last recommendations:

- Don't use GimmeZeroZero Windows. They are evil.
- You dont need double buffering, if you carefully refresh your textbox and dont use transparency. (means drawing background, and then draw the text as forground)
When you use text with background (blocky mode), you draw forground and background in an atomic operation and you wont see gfx artefacts while refreshing.

Last edited by Wanderer on 02-Feb-2012 at 04:17 PM.
Last edited by Wanderer on 02-Feb-2012 at 04:15 PM.
Last edited by Wanderer on 02-Feb-2012 at 04:10 PM.

_________________
--
Author of
HD-Rec, Sweeper, Samplemanager, ArTKanoid, Monkeyscript, Toadies, AsteroidsTR, TuiTED, PosTED, TKPlayer, AudioConverter, ScreenCam, PerlinFX, MapEdit, AB3 Includes and many more...
Homepage: http://www.hd-rec.de

 Status: Offline
Profile     Report this post  
jonssonj 
Re: What to look at if I want to do an texteditor
Posted on 3-Feb-2012 6:30:26
#16 ]
Regular Member
Joined: 1-Mar-2004
Posts: 299
From: Sweden, Bjärred

@all

I think this community is so great... Thanks all for all your thoughts.

I have now done an example on opening a window, but I realise that you can do it in several ways.

First I did it like this:


#include
#include
#include

#include
#include

struct IntuitionBase *IntuitionBase;
struct Window *my_window;
struct NewWindow my_new_window=
{
50, /* LeftEdge x position of the window. */
25, /* TopEdge y positio of the window. */
150, /* Width 150 pixels wide. */
100, /* Height 100 lines high. */
0, /* DetailPen Text should be drawn with colour reg. 0 */
1, /* BlockPen Blocks should be drawn with colour reg. 1 */
NULL, /* IDCMPFlags No IDCMP flags. */

WFLG_SMART_REFRESH | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_SIZEGADGET | ACTIVATE,

NULL, /* FirstGadget No Custom Gadgets. */
NULL, /* CheckMark Use Intuition's default CheckMark (v). */
"MY WINDOW", /* Title Title of the window. */
NULL, /* Screen Connected to the Workbench Screen. */
NULL, /* BitMap No Custom BitMap. */
80, /* MinWidth We do not need to care about these */
50, /* MinHeight since we havent supplied the window with */
~0, /* MaxWidth a Sizing Gadget. */
~0, /* MaxHeight */
WBENCHSCREEN /* Type Connected to the Workbench Screen. */
};

main()
{
IntuitionBase = (struct IntuitionBase *)
OpenLibrary( "intuition.library", 0 );

if( IntuitionBase == NULL )
exit(-1);

my_window = (struct Window *) OpenWindow( &my_new_window );
CloseLibrary( IntuitionBase );

exit();
}




But then I found the OpenWindowTags() function. Which one should I use?

BR
JJ

_________________
A1 X1000 is here !!!

 Status: Offline
Profile     Report this post  
Trixie 
Re: What to look at if I want to do an texteditor
Posted on 3-Feb-2012 6:42:05
#17 ]
Amiga Developer Team
Joined: 1-Sep-2003
Posts: 2119
From: Czech Republic

@jonssonj

Quote:
But then I found the OpenWindowTags() function. Which one should I use?

Definitely this one! Forget about OpenWindow() and filling the NewWindow structure, this is real stone age.

Also, see PM.

Last edited by Trixie on 03-Feb-2012 at 06:46 AM.

_________________
The Rear Window blog

AmigaOne X5000/020 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition

 Status: Offline
Profile     Report this post  
jonssonj 
Re: What to look at if I want to do an texteditor
Posted on 3-Feb-2012 7:25:43
#18 ]
Regular Member
Joined: 1-Mar-2004
Posts: 299
From: Sweden, Bjärred

@Trixie

Ok.

I tried to do the following:



#include stdio.h>
#include stdlib.h>

#include intuition/intuition.h>
#include proto/intuition.h>
#include proto/exec.h>
#include proto/dos.h>

struct IntuitionBase *IntuitionBase;

struct Window *my_window;
struct GfxBase *GfxBase;


main() {

IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 40);
if ( IntuitionBase == NULL )
exit(-1);

my_window = (struct Window *) OpenWindowTags(NULL,
WA_Left, 50,
WA_Top, 25,
WA_Width, 150,
WA_Height, 100,
WA_DetailPen, 0,
WA_BlockPen, 1,
WA_IDCMP, NULL,
WA_Flags, WA_SmartRefresh | WA_DragBar | WA_DepthGadget | WA_CloseGadget | WA_SizeGadget | WA_Activate,
WA_Gadgets, NULL,
WA_Title, (ULONG) "My Window",
WA_MinWidth, 80,
WA_MinHeight, 80,
WA_MaxWidth, ~0,
WA_MaxHeight, ~0
);
// my_window = (struct Window *) OpenWindow ( &my_new_window);


if(my_window == NULL) {
CloseLibrary ((struct Library *) IntuitionBase);

exit(-2);
}

Delay(50 * 30);

CloseWindow (my_window);

CloseLibrary((struct Library *) IntuitionBase);


}


But when I try to use the sizegadget and resize my window the left border disappears like this:


[img align=left]http://www.facebook.com/media/set/?set=a.10150525981177894.370716.704312893&type=1&l=af3f596067[/img]

What have I done wrong, I have tried to find the error myself, but I can't find any errors in the code. Thanks for all help that you can give on this.

BR
JJ

_________________
A1 X1000 is here !!!

 Status: Offline
Profile     Report this post  
jonssonj 
Re: What to look at if I want to do an texteditor
Posted on 3-Feb-2012 7:44:18
#19 ]
Regular Member
Joined: 1-Mar-2004
Posts: 299
From: Sweden, Bjärred

@jonssonj

Ok, I think I found the error, I did like this instead:

my_window = (struct Window *) OpenWindowTags(NULL,
WA_Left, 50,
WA_Top, 25,
WA_Width, 150,
WA_Height, 100,
WA_IDCMP, NULL,

WA_SmartRefresh, TRUE,
WA_DragBar, TRUE,
WA_DepthGadget, TRUE,
WA_CloseGadget, TRUE,
WA_SizeGadget, TRUE,
WA_Activate, TRUE,
WA_SizeBRight, TRUE,
//WA_SizeBBottom, TRUE,

WA_Gadgets, NULL,
WA_Title, (ULONG) "My Window",
WA_MinWidth, 80,
WA_MinHeight, 80,
WA_WBenchWindow);

and now it works.

BR
JJ

_________________
A1 X1000 is here !!!

 Status: Offline
Profile     Report this post  
Trixie 
Re: What to look at if I want to do an texteditor
Posted on 3-Feb-2012 16:02:32
#20 ]
Amiga Developer Team
Joined: 1-Sep-2003
Posts: 2119
From: Czech Republic

@jonssonj

Remember that storing your text in memory involves more that just putting it in an array or a sequence of strings: apart from formatting you'll also need to handle your edits, otherwise you won't be able to implement any sort of UNDO. Before you get to this, I recommend you to study this paper, it will make you much wiser

_________________
The Rear Window blog

AmigaOne X5000/020 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition

 Status: Offline
Profile     Report this post  
Goto page ( 1 | 2 | 3 Next Page )

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle