# Aros/Developer/Zune/CustomClasses

* Navbar for the Aros wikibook
* Aros User
* Aros User Docs
* Aros User FAQs
* Aros User Applications
* Aros User DOS Shell
* Aros/User/AmigaLegacy
* Aros Dev Docs
* Aros Developer Docs
* Porting Software from AmigaOS/SDL
* For Zune Beginners
* Zune .MUI Classes
* For SDL Beginners
* Aros Developer BuildSystem
* Specific platforms
* Aros x86 Complete System HCL
* Aros x86 Audio/Video Support
* Aros x86 Network Support
* Aros Intel AMD x86 Installing
* Aros Storage Support IDE SATA etc
* Aros Poseidon USB Support
* x86-64 Support
* Motorola 68k Amiga Support
* Linux and FreeBSD Support
* Windows Mingw and MacOSX Support
* Android Support
* Arm Raspberry Pi Support
* PPC Power Architecture
* misc
* Aros Public License

## What is a Zune custom class?

A Zune custom class is a newly created Zune class based on an existing one. A custom class may provide improvements or changes to the one it's based upon, thus extending Zune.
Zune custom classes are identified by the suffix ".mcc".
AROS' Zune classes (including supplied custom classes) are located at SYS:Classes/Zune.
Mui Custom Classes (MCC) some of which are closed sources.
Examples of open sourced ones...
* Betterstring 11.15
* Date.mcc
* HTMLview 13.4
* Mailtext 19.9
* NList 20.121
* NListtree 18.28.
* NListview 19.76.
* NBitmap 15.6.
* NBalance 15.2.
* Speedbar 19.4.
* SpeedCFG 11.0.
* SpeedbarVirt 19.4.
* Speedbutton 19.4.
* TextEditor 15.27.
* TheBar 26.2.
* TheBarVirt 26.2.
* TheButton 26.2.
* TWFmultiLED.mcc 12.8
* URLText 19.7.
http://www.jens-langner.de/dev

## Using custom classes

Here is an example how a private class is defined:
Some custom classes are supplied with AROS. Others can be installed into AROS. Others can be loaded from disk.
Custom classes usage in your application is mostly straightforward (just like any built-in class). The only prerequisite might be including the appropriate #include-file.
For example: If you've been using the (built-in) "Text" class/object of Zune...
...you may use the custom class "TextEditor" exactly the same way, just add the proper include-file and adjust the attribute (MUIA_...) to match the new class:
Another example is the "NListview"/"NList" class, which is an enhanced replacement of the (built-in) "Listview"/"List" class. In this case even the custom classes' attributes match the original classes' ones.
Of course it all depends on the way a custom class is built - it might introduce completely new attributes or method. In any case it is strongly recommended to obtain a custom classes' developer documentation of attributes and methods.
If you have a custom class,and this should have an extra attribute, which needs to trigger via a Notify-method. You simply need to forward the OM_SET message to your superclass.
If you want the app to be able to check the attribute via a Notify that is setup at progstart. Than you want to set the attribute inside the class, and the app should react according to that notify.

## References
### BetterString

Can scrollback buffers be achieved with betterstring.mcc? Yes, simply subclass it and add an eventhandler with priority above zero, and react on the arrow up/down keys. My idea for an API would be a method a la MUIM_BetterString_Freeze, which would add the contents of the current buffer to the history. Normally one would then setup a notify to let MUIA_String_Acknowledge trigger this method. Additionally there should be a tag to force moving to a certain buffer.
If you do create a buffer-system, please let the Freeze-method verify that the buffer has changed, and only add it if so - there's nothing as irritating as the unix shell which keeps adding repeated commands to the history, so that one has to press arrow-up a zillion times before getting to the previous *different* command...

### NList

It is more powerful, as it supports horizontal scroll, clickable titles, re-arranging of columns, re-layout of columns etc. - but most consider it more complex and not as fast plus it has a few flaws.
creating your list like so
That will give you a four column list, each column separated by a vertical bar. Add or remove 'BAR,' entries to the desired number of columns. If you have enabled the titles (a good idea for multi-column lists) then you should also ensure that your display hook sets the titles for each column.
For sorting you must supply MUIA_NList_CompareHook (or overload MUIM_NList_Compare) to get proper comparison. The default comparison method works only for single column lists with plain string pointers.
How to tell if a certain entry is in the visible part of the NList then? You can calculate the visible entries using: MUIA_NList_Horiz_DeltaFactor, MUIA_NList_Horiz_First & MUIA_NList_Horiz_Visible.
If you are using custom data structures:
* Display method/hook is required.
* Compare method/hook is required if you are using sorting.
* Construct/Destruct is optional, to temporary copy these structures or whatever you want.
If Construct/Destruct are missing NList.mcc will pass entry which you inserted directly to f.e. Display/Compare/Destruct.
Procedure with variable amount of parameters in aros, and some damn macro... here is a valid and working procedures, resolves some problems with "End" macro, and implementation of DoSuperNew
or in a more portable manner
I intentionally ignore __stackparm in the prototype because it has no meaning for PPC and x86-64 at the moment, and it never had it for i386 and m68k. When the preprocessor expands macros on i386 (or any other architecture which puts all arguments on stack). The code is turned into this:
If you declare the function static, gcc's optimizer looks at this and decides that the function uses only its first tag1 argument. And calls like:
are turned into: DoSuperNew(cl, o, MUIA_Foo)
Which in fact cause undefined behavior. In most cases FindTagItem browses the stack's contents until it hits zero longword occasionally appeared somewhere, so you notice almost nothing. In some cases this can cause memory-trashing and illegal address accesses.
Perhaps a more future-proof solution would be to use va_start and va_end macros. On architecture, we talk about va_list is simply a pointer to current argument (i. e. in our example it will be &tag1 right after va_start).

### NBitmap
## Creating a custom class

Most likely, when creating a custom class, the existing classes functionality will be extended, like providing a new appearance, handling keys, etc. Zune provides an interface to do so. The newly created class can be "private" to your application, or "public" and thus available to other applications like any existing (built-in or public custom) class.
To create you own custom class...
available on Aminet - look for DisKo
If you want to make your new custom class publicly available, e. g. to be included in AROS, it is necessary to register a class base address / class ID - to avoid conflicts with other developers developing a public custom class.

### Example

fixed the bug in NFloattext.mcc which caused the class to ignore MUIA_Font (together with the rest of taglist). If you write your own varargs stub which uses AROS_SLOWSTACKTAGS macros inside itself, DO NOT declare it static!