<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>ReloadSystems</title>
	<link>http://blog.reloadsystems.net</link>
	<description>Personal page of Michael Cowan</description>
	<pubDate>Fri, 03 Oct 2008 10:19:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.3</generator>
	<language>en</language>
			<item>
		<title>Introduction to Motif</title>
		<link>http://blog.reloadsystems.net/2006/06/03/4/</link>
		<comments>http://blog.reloadsystems.net/2006/06/03/4/#comments</comments>
		<pubDate>Sat, 03 Jun 2006 21:21:55 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>Motif</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2006/06/03/4/</guid>
		<description><![CDATA[  This afternoon I started writing a GUI frontend for an encryption toolkit I've been working on. I decided to use Motif (a toolkit I rather like for its portability and speed) and it occured to me that its not something you hear about much anymore. So I decided to write this simple introduction to [...] ]]></description>
			<content:encoded><![CDATA[<p> This afternoon I started writing a GUI frontend for an encryption toolkit I've been working on. I decided to use Motif (a toolkit I rather like for its portability and speed) and it occured to me that its not something you hear about much anymore. So I decided to write this simple introduction to Motif coding using my Linux GUI as an example. The main purpose of this tutorial is to illustrate many of the fundamental steps of nearly every Motif program. This document will get updated as I work on the front end, which will continue in the New Year.</p>
<p>An obvious place to start is the header files. Motif header files are found in the #include &lt;Xm/...&gt; subdirectories, with every Motif program using &lt;Xm/Xm.h&gt;. Each Motif widget has its own header file, which we have to include e.g. #include &lt;Xm/PushB.h&gt;. The Motif libraries need to be linked against when using these headers which is done with the -lXm and -lX11 compiler flags. Quite often gcc will complain when using these flags if the libraries are not where it expects. This can usually be fixed by adding a flag something like -L/usr/X11R6/lib.</p>
<p>Every Motif program is based around six basic steps:</p>
<ul>
<li>Initialize toolkit</li>
<li>Create widgets</li>
<li>Manage widgets</li>
<li>Setup callbacks</li>
<li>Realize the widgets</li>
<li>Enter event handling loop</li>
</ul>
<p>Initializing the toolkit can be done using XtInitialize(). This connects the program to the X display, sets up resources and creates a top level window. Usually after creating the top level window a form widget is created to place other widgets on. This can be done using XmCreateForm(). Example code:<br />
<div class="syntax_hilite">
<div id="c-5">
<div class="c"><span style="color: #993333;">int</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> *argv<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
Widget&nbsp; &nbsp;top_level, form;<br />
top_level= XtInitialize<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">"test"</span>, <span style="color: #000000; font-weight: bold;">NULL</span>, <span style="color: #cc66cc;">0</span>, &amp;argc, argv<span style="color: #66cc66;">&#41;</span>;<br />
form = XmCreateForm<span style="color: #66cc66;">&#40;</span>top_level, <span style="color: #ff0000;">"form"</span>, <span style="color: #000000; font-weight: bold;">NULL</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>form<span style="color: #66cc66;">&#41;</span>;<br />
...</div>
</div>
</div>
<p></p>
<p>Creating other interactive widgets (buttons, text boxes etc) can also be done in different ways but I prefer using a specific function for each widget. These functions come in the form XmCreate() and take four arguments. These arguments are the parent widget, name of the created widget, widget argument list (or NULL) and the number of arguments in the list (or zero). The widget argument list is an array containing a list of Motif resource names and corresponding value. Each entry of the list is generated using XtSetArg() Example code:</p>
<div class="syntax_hilite">
<div id="c-6">
<div class="c">...<br />
<span style="color: #202020;">Widget</span>&nbsp; &nbsp;button_plugin;<br />
Arg&nbsp; &nbsp; &nbsp; args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#93;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNheight, <span style="color: #cc66cc;">35</span><span style="color: #66cc66;">&#41;</span>;<br />
button_plugin = XmCreatePushButton<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"Push Me"</span>, args, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br />
XtAddCallback<span style="color: #66cc66;">&#40;</span>button_plugin, XmNactivateCallback,<br />
<span style="color: #66cc66;">&#40;</span>XtCallbackProc<span style="color: #66cc66;">&#41;</span>browse_call, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>button_plugin<span style="color: #66cc66;">&#41;</span>;<br />
...</div>
</div>
</div>
<p></p>
<p>To make a widget appear in the GUI you have to manage it using XtManageChild(). As you can see from my code I tend to manage each widget as I create it. The reason for this is purely a coding convienience. Similarly you can XtUnmanageChild() to remove a widget from a dialog.</p>
<p>The previous example also demonstrated the use of XtAddCallback() to add a callback control for a widget. The function is very self explanatory, except for the last argument which is client data which may be passed to the callback function.</p>
<p>Once you have created all your widgets and handling etc the program needs to realise the top level widget and enter the event handling loop. This is done with XtMainLoop(). Example code:</p>
<div class="syntax_hilite">
<div id="c-7">
<div class="c">...<br />
<span style="color: #202020;">XtRealizeWidget</span><span style="color: #66cc66;">&#40;</span>top_level<span style="color: #66cc66;">&#41;</span>;<br />
XtMainLoop<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span>;<br />
<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></p>
<p>And thats it! Its pretty stright forward when you break it all down. Next update will show positioning of widgets, creating file dialogs and a closer look at callbacks.<br />
My complete source for my GUI so far is shown below.</p>
<div class="syntax_hilite">
<div id="c-8">
<div class="c"><span style="color: #808080; font-style: italic;">/*<br />
*&nbsp; &quot;xet.c&quot; Version 0.1<br />
*<br />
*&nbsp; Copyright (C) 2005 Michael Cowan.<br />
*&nbsp; http://www.phatindustries.net<br />
*&nbsp; All Rights Reserved<br />
*<br />
*/</span></p>
<p><span style="color: #808080; font-style: italic;">/*<br />
*&nbsp; Exits the program.<br />
*/</span><br />
<span style="color: #993333;">void</span> quit_call<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Quitting program<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
exit<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></p>
<p><span style="color: #808080; font-style: italic;">/*<br />
*&nbsp; Displays 'About' dialog.<br />
*/</span><br />
<span style="color: #993333;">void</span> about_call<span style="color: #66cc66;">&#40;</span>Widget button, <span style="color: #993333;">char</span> *text,<br />
XmPushButtonCallbackStruct *cbs<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></p>
<p>Widget dialog, remove;<br />
XmString xm_string;<br />
Arg args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;</p>
<p>xm_string = XmStringCreateLocalized<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Created by Mike for PhatIndustries, 2005<span style="color: #000099; font-weight: bold;">\n</span>"</span><br />
<span style="color: #ff0000;">"http://www.phatindustries.net<span style="color: #000099; font-weight: bold;">\n</span>"</span><span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNmessageString, xm_string<span style="color: #66cc66;">&#41;</span>;</p>
<p>dialog = XmCreateInformationDialog<span style="color: #66cc66;">&#40;</span>button, <span style="color: #ff0000;">"About"</span>, args, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>XmStringFree<span style="color: #66cc66;">&#40;</span>xm_string<span style="color: #66cc66;">&#41;</span>;</p>
<p>remove = XmMessageBoxGetChild<span style="color: #66cc66;">&#40;</span>dialog, XmDIALOG_HELP_BUTTON<span style="color: #66cc66;">&#41;</span>;<br />
XtUnmanageChild<span style="color: #66cc66;">&#40;</span>remove<span style="color: #66cc66;">&#41;</span>;<br />
remove = XmMessageBoxGetChild<span style="color: #66cc66;">&#40;</span>dialog, XmDIALOG_CANCEL_BUTTON<span style="color: #66cc66;">&#41;</span>;<br />
XtUnmanageChild<span style="color: #66cc66;">&#40;</span>remove<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtManageChild<span style="color: #66cc66;">&#40;</span>dialog<span style="color: #66cc66;">&#41;</span>;<br />
XtPopup<span style="color: #66cc66;">&#40;</span>XtParent<span style="color: #66cc66;">&#40;</span>dialog<span style="color: #66cc66;">&#41;</span>, XtGrabNone<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #66cc66;">&#125;</span></p>
<p><span style="color: #808080; font-style: italic;">/*<br />
*&nbsp; Closes widget.<br />
*/</span><br />
<span style="color: #993333;">void</span> dialog_cancel<span style="color: #66cc66;">&#40;</span>Widget widget, XtPointer client_data,<br />
XmFileSelectionBoxCallbackStruct *selection<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
XtUnmanageChild<span style="color: #66cc66;">&#40;</span>widget<span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span></p>
<p><span style="color: #808080; font-style: italic;">/*<br />
*&nbsp; Handles file selection from a file select dialog.<br />
*/</span><br />
<span style="color: #993333;">void</span> browse_select<span style="color: #66cc66;">&#40;</span>Widget widget, XtPointer client_data,<br />
XmFileSelectionBoxCallbackStruct *selection<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></p>
<p><span style="color: #993333;">char</span> *filename;</p>
<p>XmStringGetLtoR<span style="color: #66cc66;">&#40;</span>selection-&gt;value, XmSTRING_DEFAULT_CHARSET, &amp;filename<span style="color: #66cc66;">&#41;</span>;</p>
<p><a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Filename: %s<span style="color: #000099; font-weight: bold;">\n</span>"</span>, filename<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtUnmanageChild<span style="color: #66cc66;">&#40;</span>widget<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #66cc66;">&#125;</span></p>
<p><span style="color: #808080; font-style: italic;">/*<br />
*&nbsp; Displays file selection dialog - no file filter<br />
*/</span><br />
<span style="color: #993333;">void</span> browse_call<span style="color: #66cc66;">&#40;</span>Widget cascade_button, <span style="color: #993333;">char</span> *text,<br />
XmPushButtonCallbackStruct *cbs<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></p>
<p>Widget dialog, remove;<br />
XmString mask;<br />
Arg args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>;</p>
<p>dialog = XmCreateFileSelectionDialog<span style="color: #66cc66;">&#40;</span>cascade_button, <span style="color: #ff0000;">"select"</span>, <span style="color: #000000; font-weight: bold;">NULL</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>XtAddCallback<span style="color: #66cc66;">&#40;</span>dialog, XmNokCallback, browse_select, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;<br />
XtAddCallback<span style="color: #66cc66;">&#40;</span>dialog, XmNcancelCallback, dialog_cancel, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #808080; font-style: italic;">// Remove HELP button</span><br />
remove = XmSelectionBoxGetChild<span style="color: #66cc66;">&#40;</span>dialog, XmDIALOG_HELP_BUTTON<span style="color: #66cc66;">&#41;</span>;<br />
XtUnmanageChild<span style="color: #66cc66;">&#40;</span>remove<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtManageChild<span style="color: #66cc66;">&#40;</span>dialog<span style="color: #66cc66;">&#41;</span>;<br />
XtPopup<span style="color: #66cc66;">&#40;</span>XtParent<span style="color: #66cc66;">&#40;</span>dialog<span style="color: #66cc66;">&#41;</span>, XtGrabNone<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #66cc66;">&#125;</span></p>
<p><span style="color: #808080; font-style: italic;">/*<br />
*&nbsp; Main entry point.<br />
*/</span><br />
main<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> argc, <span style="color: #993333;">char</span> *argv<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></p>
<p>Widget&nbsp; &nbsp;top_level, pane, form;<br />
Widget&nbsp; &nbsp;menu_bar, menu_quit, menu_about;<br />
Widget&nbsp; &nbsp;label_plugin, text_plugin, button_plugin;<br />
Widget&nbsp; &nbsp;label_hash, text_hash, button_hash;<br />
Widget&nbsp; &nbsp;label_wordlist, text_wordlist, button_wordlist;<br />
Widget&nbsp; &nbsp;toggle_bf, text_bf;<br />
Widget&nbsp; &nbsp;label_output, text_output;</p>
<p>XmString xmLabel;<br />
Arg&nbsp; &nbsp; &nbsp; args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#93;</span>;</p>
<p><span style="color: #993333;">int</span>&nbsp; &nbsp; &nbsp; nWidgetHeight = <span style="color: #cc66cc;">32</span>;<br />
<span style="color: #993333;">int</span>&nbsp; &nbsp; &nbsp; nLabelWidth&nbsp; &nbsp;= <span style="color: #cc66cc;">60</span>;<br />
<span style="color: #993333;">int</span>&nbsp; &nbsp; &nbsp; nTextWidth&nbsp; &nbsp; = <span style="color: #cc66cc;">400</span>;</p>
<p><span style="color: #808080; font-style: italic;">// Initialize</span><br />
top_level= XtInitialize<span style="color: #66cc66;">&#40;</span>argv<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #ff0000;">"test"</span>, <span style="color: #000000; font-weight: bold;">NULL</span>, <span style="color: #cc66cc;">0</span>, &amp;argc, argv<span style="color: #66cc66;">&#41;</span>;<br />
form = XmCreateForm<span style="color: #66cc66;">&#40;</span>top_level, <span style="color: #ff0000;">"form"</span>, <span style="color: #000000; font-weight: bold;">NULL</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>form<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #808080; font-style: italic;">// Create menu, buttons and callbacks</span><br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
menu_bar = XmCreateMenuBar<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"main_list"</span>, args, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>menu_bar<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNmnemonic, <span style="color: #ff0000;">'A'</span><span style="color: #66cc66;">&#41;</span>;;<br />
menu_about = XmCreateCascadeButton<span style="color: #66cc66;">&#40;</span>menu_bar, <span style="color: #ff0000;">"About"</span>, args, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br />
XtAddCallback<span style="color: #66cc66;">&#40;</span>menu_about, XmNactivateCallback,<br />
<span style="color: #66cc66;">&#40;</span>XtCallbackProc<span style="color: #66cc66;">&#41;</span>about_call, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>menu_about<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNmnemonic, <span style="color: #ff0000;">'Q'</span><span style="color: #66cc66;">&#41;</span>;<br />
menu_quit = XmCreateCascadeButton<span style="color: #66cc66;">&#40;</span>menu_bar, <span style="color: #ff0000;">"Quit"</span>, args, <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;<br />
XtAddCallback<span style="color: #66cc66;">&#40;</span>menu_quit, XmNactivateCallback, quit_call, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>menu_quit<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #808080; font-style: italic;">// Create 'Plugin' row</span><br />
xmLabel = XmStringCreateSimple<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Plugin:"</span><span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNwidth, nLabelWidth<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, menu_bar<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>, XmNlabelString, xmLabel<span style="color: #66cc66;">&#41;</span>;<br />
label_plugin = XmCreateLabel<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"label"</span>, args, <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>;<br />
XmStringFree<span style="color: #66cc66;">&#40;</span>xmLabel<span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>label_plugin<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, menu_bar<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
button_plugin = XmCreatePushButton<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"..."</span>, args, <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>;<br />
XtAddCallback<span style="color: #66cc66;">&#40;</span>button_plugin, XmNactivateCallback,<br />
<span style="color: #66cc66;">&#40;</span>XtCallbackProc<span style="color: #66cc66;">&#41;</span>browse_call, <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>button_plugin<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNwidth, nTextWidth<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, menu_bar<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>, XmNleftWidget, label_plugin<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#93;</span>, XmNrightWidget, button_plugin<span style="color: #66cc66;">&#41;</span>;<br />
text_plugin = XmCreateText<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"text"</span>, args, <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>text_plugin<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #808080; font-style: italic;">// Create 'Hash' Row</span><br />
xmLabel = XmStringCreateSimple<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Hashs:"</span><span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNwidth, nLabelWidth<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_plugin<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>, XmNlabelString, xmLabel<span style="color: #66cc66;">&#41;</span>;<br />
label_hash = XmCreateLabel<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"label"</span>, args, <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>;<br />
XmStringFree<span style="color: #66cc66;">&#40;</span>xmLabel<span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>label_hash<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_plugin<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
button_hash = XmCreatePushButton<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"..."</span>, args, <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>button_hash<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNwidth, nTextWidth<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_plugin<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>, XmNleftWidget, label_hash<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#93;</span>, XmNrightWidget, button_hash<span style="color: #66cc66;">&#41;</span>;<br />
text_hash = XmCreateText<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"text"</span>, args, <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>text_hash<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #808080; font-style: italic;">// Create Options</span><br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNwidth, <span style="color: #cc66cc;">25</span><span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_hash<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
text_bf = XmCreateText<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"text"</span>, args, <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>text_bf<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_hash<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNrightWidget, text_bf<span style="color: #66cc66;">&#41;</span>;<br />
toggle_bf = XmCreateToggleButton<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"Brute Force"</span>, args, <span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>toggle_bf<span style="color: #66cc66;">&#41;</span>;</p>
<p>xmLabel = XmStringCreateSimple<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Word List:"</span><span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNwidth, nLabelWidth<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_hash<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>, XmNlabelString, xmLabel<span style="color: #66cc66;">&#41;</span>;<br />
label_wordlist = XmCreateLabel<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"label"</span>, args, <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>;<br />
XmStringFree<span style="color: #66cc66;">&#40;</span>xmLabel<span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>label_wordlist<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_hash<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>, XmNrightWidget, toggle_bf<span style="color: #66cc66;">&#41;</span>;<br />
button_wordlist = XmCreatePushButton<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"..."</span>, args, <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>button_wordlist<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nWidgetHeight<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_hash<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNleftWidget, label_wordlist<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#93;</span>, XmNrightWidget, button_wordlist<span style="color: #66cc66;">&#41;</span>;<br />
text_wordlist = XmCreateText<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"text"</span>, args, <span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>text_wordlist<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #808080; font-style: italic;">// Create 'Output' row</span><br />
xmLabel = XmStringCreateSimple<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Output:"</span><span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNlabelString, xmLabel<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, text_wordlist<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
label_output = XmCreateLabel<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"label"</span>, args, <span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#41;</span>;<br />
XmStringFree<span style="color: #66cc66;">&#40;</span>xmLabel<span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>label_output<span style="color: #66cc66;">&#41;</span>;</p>
<p>XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span>, XmNwidth, nTextWidth<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>, XmNheight, nTextWidth<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#93;</span>, XmNtopAttachment, XmATTACH_WIDGET<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#93;</span>, XmNtopWidget, label_output<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#93;</span>, XmNleftAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#93;</span>, XmNrightAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #66cc66;">&#93;</span>, XmNbottomAttachment, XmATTACH_FORM<span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">7</span><span style="color: #66cc66;">&#93;</span>, XmNwordWrap, <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #66cc66;">&#41;</span>;<br />
XtSetArg<span style="color: #66cc66;">&#40;</span>args<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#93;</span>, XmNeditMode, XmMULTI_LINE_EDIT<span style="color: #66cc66;">&#41;</span>;<br />
text_output = XmCreateText<span style="color: #66cc66;">&#40;</span>form, <span style="color: #ff0000;">"text"</span>, args, <span style="color: #cc66cc;">9</span><span style="color: #66cc66;">&#41;</span>;<br />
XtManageChild<span style="color: #66cc66;">&#40;</span>text_output<span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #808080; font-style: italic;">// Display top level widget and enter GUI loop</span><br />
XtRealizeWidget<span style="color: #66cc66;">&#40;</span>top_level<span style="color: #66cc66;">&#41;</span>;<br />
XtMainLoop<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</p>
<p><span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span>;</p>
<p><span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></p>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2006/06/03/4/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Burning Xbox 360 games in Linux</title>
		<link>http://blog.reloadsystems.net/2007/02/02/burning-xbox-360-games-in-linux/</link>
		<comments>http://blog.reloadsystems.net/2007/02/02/burning-xbox-360-games-in-linux/#comments</comments>
		<pubDate>Fri, 02 Feb 2007 22:48:08 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>XBOX 360</category>
	<category>Linux</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/02/02/burning-xbox-360-games-in-linux/</guid>
		<description><![CDATA[  After recently flashing my Xbox 360 DVD drive, I set about burning images using my Fedora Core 6 linux box. There are many guides available on how to burn games (mostly for Windows) but there is so much mystery and superstition surrounding the process, that it is hard to seperate fact from fiction and [...] ]]></description>
			<content:encoded><![CDATA[<p> After recently flashing my Xbox 360 DVD drive, I set about burning images using my Fedora Core 6 linux box. There are many guides available on how to burn games (mostly for Windows) but there is so much mystery and superstition surrounding the process, that it is hard to seperate fact from fiction and come up with suitable Linux equivalents. Well, one week and nine very expensive coasters later I have my solution.</p>
<p>You will need ...</p>
<ul>
<li>Dual layer DVD burner and DVD+R media</li>
<li>A downloaded image (and ss.bin etc if required)</li>
<li><a target="_blank" href="http://fy.chalmers.se/~appro/linux/DVD+RW/tools/">growisofs</a></li>
<li><a target="_blank" href="http://reloadsystems.net/download/imgbpatch.jar">imgbpatch.jar</a></li>
</ul>
<p>The first hurdle comes when you realise that not all images are created the same way. Most noticable is a rip that is not pre patched with the security sector (ss.bin). <span style="font-weight: bold">It should be noted however, that most images already contain the security sector and this step should be skipped. </span>To merge ss.bin and game.iso into a file called IMAGE.000, the following command can be used:</p>
<div class="syntax_hilite">
<div id="code-13">
<div class="code">dd if=/dev/zero of=blank.<span style="">iso</span> bs=<span style="color:#800000;">2048</span> count=<span style="color:#800000;">129823</span> &amp;&amp; cat blank.<span style="">iso</span> ss.<span style="">bin</span> game.<span style="">iso</span>&gt; IMAGE.<span style="color:#800000;">000</span></div>
</div>
</div>
<p></p>
<p>This will create an image consisting of 265877504 blank bytes, the security sector and finally the game image. The final size of IMAGE.000 should be 7572881408 bytes.</p>
<p>To actually burn the image, the iso must be made compatable with growisofs. This is something that CloneCD users do not need to do and is a cause of great confusion for those using other software. Again, many images are already pre prepared and do not require patching but unlike the merge doing so with a pre patched image will not break it. This is carried out using a neat little java app called imgbpatch.jar (catchy, isn't it?). To use it the following command can be used:</p>
<div class="syntax_hilite">
<div id="code-14">
<div class="code">java -jar imgbpatch.<span style="">jar</span> IMAGE.<span style="color:#800000;">000</span></div>
</div>
</div>
<p></p>
<p>Now you have a workable image, the next step is the burn which is carried out using growisofs. There are a lot of threads around that claim only a Pioneer 111D with Verbatim +R media will work, which I have found to be complete hocus pocus. I use both LiteOn and Samsung drives with Memorex and Mr. DVD media and not had any problems.<br />
The burn command is a very neat one and carries out everything you need. The important things are the speed (slow, to increase the chances of a solid burn), the line break (1913760 for 360 games) and the DVD compatability flag (burns DVD+R data as DVD-ROM to increase the media's compatability with non PC hardware). To do all this the following command is used:</p>
<div class="syntax_hilite">
<div id="code-15">
<div class="code">growisofs -use-the-force-luke=dao -use-the-force-luke=break:<span style="color:#800000;">1913760</span>&nbsp; -dvd-compat -speed=<span style="color:#800000;">2</span> -Z /dev/dvd=IMAGE.<span style="color:#800000;">000</span></div>
</div>
</div>
<p></p>
<p>Of course /dev/dvd can be replaced with any DVD DL drive and IMAGE.000 with any image filename. Not all DVD burners will support the speed setting but it should still slow things down e.g. on my LiteOn drive, a setting of 2 results is 4x speed!?! The burn process can take anywhere up to about 40mins.</p>
<p>Another handy ability is being able to verify the burn. An MD5SUM of the DVD can be calculated using the following command:</p>
<div class="syntax_hilite">
<div id="code-16">
<div class="code">dd if=IMAGE.<span style="color:#800000;">000</span> bs=<span style="color:#800000;">2048</span> count=<span style="color:#800000;">3697696</span> | md5sum</div>
</div>
</div>
<p></p>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/02/02/burning-xbox-360-games-in-linux/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Sound Issues on the Nokia 6288 Causing Crash</title>
		<link>http://blog.reloadsystems.net/2007/03/06/sound-issues-on-the-nokia-6288-crashing-device/</link>
		<comments>http://blog.reloadsystems.net/2007/03/06/sound-issues-on-the-nokia-6288-crashing-device/#comments</comments>
		<pubDate>Tue, 06 Mar 2007 15:19:56 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>Mobile/Cellular Devices</category>
	<category>Nokia 6288</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/03/06/sound-issues-on-the-nokia-6288-crashing-device/</guid>
		<description><![CDATA[  I have been working a lot with the Nokia 6288 this week, fixing bugs reported when using 6280 builds. Despite being very similar devices, the 6288 consistently reported crash bugs when running 6280 builds with sound enabled.
This is nothing unusual. Most manufactures seem to change there interpretation of the MMAPI regularly and is a [...] ]]></description>
			<content:encoded><![CDATA[<p> I have been working a lot with the <a href="http://www.nokia.co.uk/link?cid=PLAIN_TEXT_29635">Nokia 6288</a> this week, fixing bugs reported when using <a href="http://www.nokia.co.uk/link?cid=PLAIN_TEXT_82306">6280</a> builds. Despite being very similar devices, the 6288 consistently reported crash bugs when running 6280 builds with sound enabled.</p>
<p>This is nothing unusual. Most manufactures seem to change there interpretation of the <a href="http://java.sun.com/products/mmapi/">MMAPI </a>regularly and is a constant source of irritation for developers. However a crash bug related to audio is very serious and required some investigation.</p>
<p>The application used a typical sound implementation that uses a single Player and a byte array of sound data. When a sound is required, the Player instance releases any previously loaded sound, loads the required sound and finally plays it.</p>
<p>QA reported that the crash would occur most frequently immediately before a sound was played and in particular if sounds were played very close together. Because the bug did not occur on every played sound, this immediately points the finger at either the prefetch phase or a failed deallocation, most likely due to time constraints.</p>
<p>I tested this theory by placing a minimum time gap between each time the player is called, with a delay longer than that of the sound being played. This seemed to work for a while but ended up only delaying how long it would take for the crash to appear, rather than remove it. Besides, this would hardly be a suitable fix!</p>
<p>After some investigation, it was found that the problem lay in the Player.stop() function. It seemed that calling Player.stop() immediately after Player.start() caused the crash, and the closer the two were the more likely the bug was to arise.</p>
<p>The fix is equally simple. By simply calling Player.setMediaTime(0) before Player.stop(), the Player is left in a suitable state to be deallocated and closed.</p>
<p>A simple example is shown below:</p>
<div class="syntax_hilite">
<div id="j2me-18">
<div class="j2me"><span style="color: #3F7F5F; font-style: italic;">// Free up the player resources from previous play instance</span><br />
<span style="color: #7F0055; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> player != <span style="color: #7F0055; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; player.<span style="color: #000000;">setMediaTime</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; player.<span style="color: #000000;">stop</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; player.<span style="color: #000000;">deallocate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; player.<span style="color: #000000;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; player = <span style="color: #7F0055; font-weight: bold;">null</span>;<br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #3F7F5F; font-style: italic;">// Then create the player as usual</span><br />
player = Manager.<span style="color: #000000;">createPlayer</span><span style="color: #000000;">&#40;</span> ... <span style="color: #000000;">&#41;</span>;<br />
player.<span style="color: #000000;">realize</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
player.<span style="color: #000000;">prefetch</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
player.<span style="color: #000000;">start</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p>Since writing, it has been found that the following devices are also affected<br />
<a href="http://www.nokia.co.uk/link?cid=PLAIN_TEXT_49430">Nokia 5300</a></p>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/03/06/sound-issues-on-the-nokia-6288-crashing-device/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Split Images Using createImage() on Sagem My600v</title>
		<link>http://blog.reloadsystems.net/2007/03/14/split-images-using-createimage-on-sagem-my600v/</link>
		<comments>http://blog.reloadsystems.net/2007/03/14/split-images-using-createimage-on-sagem-my600v/#comments</comments>
		<pubDate>Wed, 14 Mar 2007 15:44:07 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>Mobile/Cellular Devices</category>
	<category>Sagem My600v</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/03/14/split-images-using-createimage-on-sagem-my600v/</guid>
		<description><![CDATA[  I've been working a lot with a game developed by a company who are trying there hand at J2ME for the first time. Despite having a tight code review document, the game still somehow managed to show up on my desk using methods that are known to cause issues with portability. Image.createImage(Image, int, int, [...] ]]></description>
			<content:encoded><![CDATA[<p> I've been working a lot with a game developed by a company who are trying there hand at J2ME for the first time. Despite having a tight code review document, the game still somehow managed to show up on my desk using methods that are known to cause issues with portability. Image.createImage(Image, int, int, int, int, int) is one of these methods ... and as it turns out, the Sagem My600v is one of the devices affected.</p>
<p>The observed issue is that the method will incorrectly parse a sprite sheet and return an unexpected image. In the case of this application the sprite sheet was an image containing three rows of three ball, all equispaced. When any ball other than that from the top row is required, the function returns the ball from the top row directly above it. This would suggest that the y value either defaults to zero or to the value that was used when the function was first called. Either way, it doesn't work and shouldn't be used to increase portability.</p>
<p>A more portable method is to use a typical clipping implementation. This would involve loading a sprite sheet at initialization time and when one of the sprites is required, set the clip area at the correct size and render the entire image at an offset that positions the required sprite to be drawn in the clipping area.</p>
<div class="syntax_hilite">
<div id="j2me-20">
<div class="j2me"><span style="color: #3F7F5F; font-style: italic;">// Calculate the top left corner of the clip</span><br />
<span style="color: #7F0055; font-weight: bold;">int</span> x = <span style="color: #000000;">&#40;</span>getWidth<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> &gt;&gt; <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span> - <span style="color: #000000;">&#40;</span> spriteWidthOnSheet &gt;&gt; <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span>;<br />
<span style="color: #7F0055; font-weight: bold;">int</span> y = <span style="color: #000000;">&#40;</span> spriteHeightOnSheet &gt;&gt; <span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span>;<br />
<span style="color: #3F7F5F; font-style: italic;">// Set clip according to images dimensions</span><br />
g.<span style="color: #000000;">setClip</span><span style="color: #000000;">&#40;</span> x, y, spriteWidthOnSheet, spriteHeightOnSheet <span style="color: #000000;">&#41;</span>;<br />
<span style="color: #3F7F5F; font-style: italic;">// Shift x and y values to position the image so the correct ball is shown</span><br />
x -= spritePositionOnSheetX;<br />
y -= spritePositionOnSheetY;<br />
<span style="color: #3F7F5F; font-style: italic;">// Render the image</span><br />
g.<span style="color: #000000;">drawImage</span><span style="color: #000000;">&#40;</span> spriteSheetImage, x, y , <span style="color: #000000;">0</span> <span style="color: #000000;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/03/14/split-images-using-createimage-on-sagem-my600v/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Thou Shalt Always Kill</title>
		<link>http://blog.reloadsystems.net/2007/03/29/thou-shalt-always-kill/</link>
		<comments>http://blog.reloadsystems.net/2007/03/29/thou-shalt-always-kill/#comments</comments>
		<pubDate>Thu, 29 Mar 2007 09:46:41 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>Uncategorized</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/03/29/thou-shalt-always-kill/</guid>
		<description><![CDATA[  Thou shalt not steal if there is a direct victim.
Thou shalt not worship Pop Idols or follow Lost Prophets.
Thou shalt not take the names of Johnny Cash, Joe Strummer, Johnny Hartman, Desmond Decker, Jim Morrison, Jimi Hendrix or Syd Barret in vain.
Thou shalt not think that any male over the age of 30 that [...] ]]></description>
			<content:encoded><![CDATA[<p> Thou shalt not steal if there is a direct victim.<br />
Thou shalt not worship Pop Idols or follow Lost Prophets.<br />
Thou shalt not take the names of Johnny Cash, Joe Strummer, Johnny Hartman, Desmond Decker, Jim Morrison, Jimi Hendrix or Syd Barret in vain.<br />
Thou shalt not think that any male over the age of 30 that plays with a child that is not their own is a pedophile … some people are just nice.<br />
Thou shalt not read NME.<br />
Thou shalt not stop liking a band just because they’ve become popular.<br />
Thou shalt not question Stephen Fry.<br />
Thou shalt not judge a book by it’s cover.<br />
Thou shalt not judge Lethal Weapon by Danny Glover.<br />
Thou shalt not buy Coca-Cola products. Thou shalt not buy Nestle products.<br />
Thou shalt not go into the woods with your boyfriend’s best friend, take drugs and cheat on him.<br />
Thou shalt not fall in love so easily.<br />
Thou shalt not use poetry, art or music to get into girls’ pants. Use it to get into their heads.<br />
Thou shalt not watch Hollyoakes.<br />
Thou shalt not attend an open mic and leave before it’s done just because you’ve finished your shitty little poem or song you self-righteous prick.<br />
Thou shalt not return to the same club or bar week in, week out just ’cause you once saw a girl there that you fancied but you’re never gonna fucking talk to.<br />
Thou shalt not put musicians and recording artists on ridiculous pedestals no matter how great they are or were.<br />
The Beatles… Were just a band.<br />
Led Zeppelin… Just a band.<br />
The Beach Boys… Just a band.<br />
The Sex Pistols… Just a band.<br />
The Clash… Just a band.<br />
Crass… Just a band.<br />
Minor Threat… Just a band.<br />
The Cure… Just a band.<br />
The Smiths… Just a band.<br />
Nirvana… Just a band.<br />
The Pixies… Just a band.<br />
Oasis… Just a band.<br />
Radiohead… Just a band.<br />
Bloc Party… Just a band.<br />
The Arctic Monkeys… Just a band.<br />
The Next Big Thing.. JUST A BAND.<br />
Thou shalt give equal worth to tragedies that occur in non-English speaking countries as to those that occur in English speaking countries.<br />
Thou shalt remember that guns, bitches and bling were never part of the four elements and never will be.<br />
Thou shalt not make repetitive generic music, thou shalt not make repetitive generic music, thou shalt not make repetitive generic music, thou shalt not make repetitive generic music.<br />
Thou shalt not pimp my ride.<br />
Thou shalt not scream if you wanna go faster.<br />
Thou shalt not move to the sound of the wickedness.<br />
Thou shalt not make some noise for Detroit.<br />
When I say “Hey” thou shalt not say “Ho”.<br />
When I say “Hip” thou shalt not say “Hop”.<br />
When I say, he say, she say, we say, make some noise… kill me.<br />
Thou shalt not quote me happy.<br />
Thou shalt not shake it like a Polaroid picture.<br />
Thou shalt not wish you girlfriend was a freak like me.<br />
Thou shalt spell the word “Pheonix” P-H-E-O-N-I-X not P-H-O-E-N-I-X, regardless of what the Oxford English Dictionary tells you.<br />
Thou shalt not express your shock at the fact that Sharon got off with Bradley at the club last night by saying “Is it”.<br />
Thou shalt think for yourselves.<br />
And thou shalt always… Thou shalt always kill!</p>
<p style="text-align: right;"><a href="http://www.danlesac.co.uk/">dan le sac vs scroobius pip</a></p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/03/29/thou-shalt-always-kill/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Two 360 Cooling Modifications with a Talismoon Whisper Fan, Arctic Silver and a Soldering Iron</title>
		<link>http://blog.reloadsystems.net/2007/07/16/two-360-cooling-modifications-with-a-talismoon-whisper-fan-arctic-silver-and-a-soldering-iron/</link>
		<comments>http://blog.reloadsystems.net/2007/07/16/two-360-cooling-modifications-with-a-talismoon-whisper-fan-arctic-silver-and-a-soldering-iron/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 14:24:27 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>XBOX 360</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/07/16/two-360-cooling-modifications-with-a-talismoon-whisper-fan-arctic-silver-and-a-soldering-iron/</guid>
		<description><![CDATA[  For a short time play.com were selling core xbox 360's for £149.99 delivered - so, sticking to my if it ain't broke, take it apart and fix it philosophy, I took the opportunity to have a second x360 to experiment with more than I normally would with my main gaming machine.
When the console arrived [...] ]]></description>
			<content:encoded><![CDATA[<p> For a short time <a href="http://www.play.com/">play.com</a> were selling core xbox 360's for £149.99 delivered - so, sticking to my <strong>if it ain't broke, take it apart and fix it</strong> philosophy, I took the opportunity to have a second x360 to experiment with more than I normally would with my main gaming machine.</p>
<p>When the console arrived it was immediately identified as having an Hitachi DVD drive with the 78FK bios and I couldn't resist putting to practice the <a href="http://www.xbox-scene.com/xbox1data/sep/EEyyFZpAZkkQIEfzBL.php">recent work by Maximus</a>. Unfortunately I later found that the 360 suffered from stability issues and tended to crash approximately every half hour (an issue unrelated to the flash). My first suspicion was that heat was the problem (it is also known that the <a href="http://www.theinquirer.net/default.aspx?article=27930">power supply</a> or even <a href="http://www.igniq.com/2006/03/more-xbox-360-crashes-reported.html">live updates</a> have been causing some people issues) and with my warranty still warm and lying in tatters on the floor, I set about looking for third party solutions.</p>
<p>An obvious start is to remove the <a href="http://en.wikipedia.org/wiki/Image:IBMxenon.jpg">poor quality thermal compound</a> that Microsoft use and replace it with a high quality counterpart e.g. <a href="http://www.arcticsilver.com/">Arctic Silver</a>. Secondly a simple drop in replacement for the (in my opinion) under powered fans is an easy upgrade to perform. I choose the <a href="http://www.talismoon.eu/cgi-bin%2Fmultipage/engine.pl?function=viewid&#038;id=RKS00051&#038;cat=XBOX360-TUNING">Talismoon Whisper Fan (in green)</a>.</p>
<p>These simple modifications did show a small improvement in both noise and airflow, however provided only a 2-3 degree drop in CPU and GPU temperature when under heavy load.</p>
<p>Next I decided to modify the stock fans to run at their designed 12v instead of the 6v supplied by the 360. This is done by removing the two positive pins in the fan's plastic power block then connecting the wires together and to a 12v supply. There are plenty of good 12v spots on the 360 motherboard to use but be careful when choosing one to make sure the supply is cut when the 360 is turned off - not all of them do.</p>
<p>This modification had two extreme effects. Firstly the noise from the fans is unbelievably loud. And I don`t mean 'the 360 is so loud in comparison to the PS3' loud, I mean Harrier Jump jet loud. And secondly, the temperature drop is equally unbelievable. At idle both CPU and GPU temperatures were way below room temperature and under load there was not much change. <em>more accurate numbers to follow</em></p>
<p>Unfortunately even this impressive temperature drop in both core and case temperatures had no affect on the stability of my 360. And even more unfortunate for me, it was about this time that my original 360 finally buckled and I got my first taste of the <a href="http://support.microsoft.com/kb/907534">3 lights of death</a>. I think the modified 360 will be going to <a href="http://www.gtelectronics.co.uk">GT electronics</a> in Dundee to get fixed, however I`m tempted to try and bring the RoL 360 back using the heat gun technique ... updates to follow.</p>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/07/16/two-360-cooling-modifications-with-a-talismoon-whisper-fan-arctic-silver-and-a-soldering-iron/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Special Characters Lost When Reading Text on the LG L600v</title>
		<link>http://blog.reloadsystems.net/2007/04/10/special-characters-lost-when-reading-text-on-the-lg-l600v/</link>
		<comments>http://blog.reloadsystems.net/2007/04/10/special-characters-lost-when-reading-text-on-the-lg-l600v/#comments</comments>
		<pubDate>Tue, 10 Apr 2007 15:05:46 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>Mobile/Cellular Devices</category>
	<category>LG L600v</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/04/10/special-characters-lost-when-reading-text-on-the-lg-l600v/</guid>
		<description><![CDATA[  This is a strange device issue I came across today when loading localized text (FR and ES) for an application on the LG L600v.
What was observed on the application was a failure to display any special characters typically seen in French and Spanish text. Instead these (and often the next) characters were missed out.
The [...] ]]></description>
			<content:encoded><![CDATA[<p> This is a strange device issue I came across today when loading localized text (FR and ES) for an application on the <a href="http://www.mobile-review.com/phonemodels/lg/lg-l600v-en.shtml">LG L600v</a>.</p>
<p>What was observed on the application was a failure to display any special characters typically seen in French and Spanish text. Instead these (and often the next) characters were missed out.</p>
<p>The application used an InputStream to create an instance of InputStreamReader and parsed the text into a StringBuffer. </p>
<div class="syntax_hilite">
<div id="j2me-22">
<div class="j2me"><span style="color: #7F0055; font-weight: bold;">InputStream</span> is = <span style="color: #7F0055; font-weight: bold;">null</span>;<br />
<span style="color: #7F0055; font-weight: bold;">InputStreamReader</span> isr = <span style="color: #7F0055; font-weight: bold;">null</span>;<br />
<span style="color: #7F0055; font-weight: bold;">StringBuffer</span> buffer = <span style="color: #7F0055; font-weight: bold;">null</span>;<br />
<span style="color: #7F0055; font-weight: bold;">try</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; is = getClass<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #000000;">getResourceAsStream</span><span style="color: #000000;">&#40;</span> languageFileName <span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; isr = <span style="color: #7F0055; font-weight: bold;">new</span> <span style="color: #7F0055; font-weight: bold;">InputStreamReader</span><span style="color: #000000;">&#40;</span> is <span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; buffer = <span style="color: #7F0055; font-weight: bold;">new</span> <span style="color: #7F0055; font-weight: bold;">StringBuffer</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #7F0055; font-weight: bold;">int</span> ch;<br />
&nbsp; &nbsp; <span style="color: #7F0055; font-weight: bold;">while</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span> ch = isr.<span style="color: #000000;">read</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> != -<span style="color: #000000;">1</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; buffer.<span style="color: #000000;">append</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">char</span><span style="color: #000000;">&#41;</span> ch <span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div>
</div>
</div>
<p>
This already is a little unusual as there is no need to create an instance of InputStreamReader as InputStream provides all the functionality needed. InputStreamReader is only required when a stream of bytes are required to be translated into characters according to a specified character encoding.</p>
<p>Unsurprisingly this is the cause of the issue and by simply removing the InputStreamReader instance the bug is fixed. Another method to add to the list that should not be used for portability!</p>
<p>Since writing, it has been found that the following devices are also affected<br />
<a href="http://www.gsmarena.com/lg_ku950-1914.php">LG KU950</a></p>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/04/10/special-characters-lost-when-reading-text-on-the-lg-l600v/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Configuring a GLUT Development Environment Using Eclipse in Windows</title>
		<link>http://blog.reloadsystems.net/2007/05/25/configuring-a-glut-development-environment-using-eclipse-in-windows/</link>
		<comments>http://blog.reloadsystems.net/2007/05/25/configuring-a-glut-development-environment-using-eclipse-in-windows/#comments</comments>
		<pubDate>Fri, 25 May 2007 13:50:08 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>OpenGL</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/05/25/configuring-a-glut-development-environment-using-eclipse-in-windows/</guid>
		<description><![CDATA[  It's no secret that Eclipse is my IDE of choice these days - It's also not a secret that Linux is my preferred development environment. However recently I found myself requiring to develop an OpenGL application in Windows XP.
After much sole searching I found I just couldn't use Visual Studio Express. Despite being free [...] ]]></description>
			<content:encoded><![CDATA[<p> It's no secret that <a href="http://www.eclipse.org/">Eclipse</a> is my IDE of choice these days - It's also not a secret that <a href="http://www.linux.org/">Linux</a> is my preferred development environment. However recently I found myself requiring to develop an <a href="http://www.opengl.org/">OpenGL</a> application in Windows XP.</p>
<p>After much sole searching I found I just couldn't use <a href="http://msdn.microsoft.com/vstudio/express/">Visual Studio Express</a>. Despite being free I just found it counter productive to install a second (and in my opinion, inferior) IDE to fulfill a single task. So I set about looking for a way to tie Eclipse and <a href="http://www.opengl.org/resources/libraries/glut/glut_downloads.php">GLUT</a> together in a way that would suit me (i'm not going to get into alternatives to GLUT just now - suffice to say this is the OpenGL toolkit I prefer).</p>
<p>The following is a guide to demonstrate how simply Eclipse can be configured for OpenGL development.</p>
<p><strong>1. Install Eclipse</strong><br />
I have assumed that if you are reading this tutorial, then you are already an Eclipse user. If not you can download the latest build on the <a href="http://www.eclipse.org/downloads/">Eclipse download page</a>. At time of writing I am using <a href="http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.2.2-200702121330/eclipse-SDK-3.2.2-win32.zip"> Eclipse SDK 3.2.2</a>.</p>
<p><strong>2. Install Eclipse C/C++ Development Tooling (CDT)</strong><br />
This plugin is accepted by most as the best C/C++ solution for Eclipse, and I agree whole heartedly. Installing the <a href="http://www.eclipse.org/cdt/downloads.php">CDT plugin</a> is the same as most other Eclipse plugins and does not need to get covered here. A plugin installation guide<a href="http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.user/tasks/tasks-34.htm"guide to using the Update Manager</a> can be found in the <a href="http://help.eclipse.org/help32/index.jsp">Eclipse Documentation</a>.</p>
<p><strong>3. Install W32 gcc Compiler and Tools (MinGW and MINSYS)</strong></p>
<ul>
<li>Download the current WinGW and MSYS distribution from <a href="http://sourceforge.net/project/showfiles.php?group_id=2435">the MinGW download page.</a></li>
<li>Run <em>MinGW-x.x.x.exe</em>. I recommend using the current packages and installing at least 'MinGW base tools', 'g++ compiler' and 'MinGW Make'. Be careful not to install to a path containing spaces.</li>
<li>Run <em>MINSYS-x.x.x.exe</em>. When asked, be careful to fill in the path to MinGW correctly using forward slashes (/).</li>
<li>Add the bin directory of both MinGW and MINSYS to the PATH environment variable. e.g:<br />
<code> ';C:\msys\1.0\bin;C:\mingw\bin'.</code></li>
<li>Open a command prompt and test the installation with the following commands:<br />
<code>make --version<br />
g++ --version</code></li>
</ul>
<p><strong>4. Install GLUT for MinGW</strong></p>
<ul>
<li>Download and unzip <a href="http://mywebpage.netscape.com/PtrPck/glutming.zip">glutming.zip</a></li>
<li>Copy <em>glut32.dll</em> to '\Windows\System32' folder. This is the glut library and allows glut built openGL applications to run.</li>
<li>Copy <em>glut.h</em> to '\MinGW\include\GL' folder.</li>
<li>Copy <em>libglut32.a</em> to '\MinGW\lib' folder.</li>
</ul>
<p>FIN</p>
<p><strong>Creating a project</strong></p>
<ol>
<li>Start Eclipse and create a new project of type '<em>Managed Make C++ Project</em>'</li>
<li>Add the GLUT libraries to the project in the Project Properties page (Project -> Properties)</li>
<ul>
<li>Select '<em>C/C++ Build</em>'</li>
<li>Select '<em>Libraries</em>' under '<em>GCC c++ Linker</em>'</li>
<li>Click the add entry icon and add the following entries<br />
<code>glut32<br />
glu32<br />
opengl32</code></li>
<li>Accept the changes and return to the project</li>
</ul>
<li>Create a new source file (File -> New -> Other... -> C++ -> Source File) with the extension '.cpp'</li>
<li>Copy and paste the following source code:<br />
<div class="syntax_hilite">
<div id="j2me-24">
<div class="j2me">#include &lt;windows.<span style="color: #000000;">h</span>&gt;<br />
#include &lt;gl/glut.<span style="color: #000000;">h</span>&gt;</p>
<p><span style="color: #7F0055; font-weight: bold;">void</span> render<span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">void</span><span style="color: #000000;">&#41;</span>&nbsp; &nbsp;<br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; glClear<span style="color: #000000;">&#40;</span>GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glLoadIdentity<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp;<br />
&nbsp; &nbsp; glTranslatef<span style="color: #000000;">&#40;</span>-<span style="color: #000000;">1</span>.5f,<span style="color: #000000;">0</span>.0f,-<span style="color: #000000;">6</span>.0f<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glBegin<span style="color: #000000;">&#40;</span>GL_TRIANGLES<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; glVertex3f<span style="color: #000000;">&#40;</span> <span style="color: #000000;">0</span>.0f, <span style="color: #000000;">1</span>.0f, <span style="color: #000000;">0</span>.0f<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; glVertex3f<span style="color: #000000;">&#40;</span>-<span style="color: #000000;">1</span>.0f,-<span style="color: #000000;">1</span>.0f, <span style="color: #000000;">0</span>.0f<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; glVertex3f<span style="color: #000000;">&#40;</span> <span style="color: #000000;">1</span>.0f,-<span style="color: #000000;">1</span>.0f, <span style="color: #000000;">0</span>.0f<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glEnd<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;&nbsp; &nbsp; </p>
<p>&nbsp; &nbsp; glutSwapBuffers <span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span></p>
<p><span style="color: #7F0055; font-weight: bold;">void</span> reshape<span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">int</span> w, <span style="color: #7F0055; font-weight: bold;">int</span> h<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; glViewport<span style="color: #000000;">&#40;</span><span style="color: #000000;">0</span>, <span style="color: #000000;">0</span>, w, h<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glMatrixMode<span style="color: #000000;">&#40;</span>GL_PROJECTION<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glLoadIdentity<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; gluPerspective<span style="color: #000000;">&#40;</span><span style="color: #000000;">80</span>, <span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">float</span><span style="color: #000000;">&#41;</span>w/<span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">float</span><span style="color: #000000;">&#41;</span>h, <span style="color: #000000;">1</span>.<span style="color: #000000;">0</span>, <span style="color: #000000;">5000</span>.<span style="color: #000000;">0</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glMatrixMode<span style="color: #000000;">&#40;</span>GL_MODELVIEW<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glLoadIdentity<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
<span style="color: #000000;">&#125;</span></p>
<p><span style="color: #7F0055; font-weight: bold;">int</span> main<span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">int</span> argc, <span style="color: #7F0055; font-weight: bold;">char</span>** argv<span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; glutInit<span style="color: #000000;">&#40;</span>&amp;argc, argv<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glutInitDisplayMode<span style="color: #000000;">&#40;</span>GLUT_RGB | GLUT_DOUBLE<span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; glutInitWindowSize<span style="color: #000000;">&#40;</span><span style="color: #000000;">500</span>, <span style="color: #000000;">500</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glutCreateWindow<span style="color: #000000;">&#40;</span><span style="color: #2A00FF;">"GLUT Test"</span><span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; glutDisplayFunc<span style="color: #000000;">&#40;</span>render<span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; glutReshapeFunc<span style="color: #000000;">&#40;</span>reshape<span style="color: #000000;">&#41;</span>;</p>
<p>&nbsp; &nbsp; glutMainLoop<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #7F0055; font-weight: bold;">return</span> <span style="color: #000000;">0</span>;<br />
<span style="color: #000000;">&#125;</span></div>
</div>
</div>
<p>
</li>
<li>Save the file. This <a href="http://blog.reloadsystems.net/2007/07/27/useful-terminology/#AUTOMAGICALLY">automagically</a> triggers the compile process. No errors should be reported and an exe file produced. When run a windows with a white triangle should be seen confirming the installation was a success.</li>
</ol>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/05/25/configuring-a-glut-development-environment-using-eclipse-in-windows/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Left Soft Key Unresponsive After SMS Interrupt on Nokia 5500d</title>
		<link>http://blog.reloadsystems.net/2007/07/16/left-soft-key-unresponsive-after-sms-interrupt-on-nokia-5500d/</link>
		<comments>http://blog.reloadsystems.net/2007/07/16/left-soft-key-unresponsive-after-sms-interrupt-on-nokia-5500d/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 10:14:24 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>Mobile/Cellular Devices</category>
	<category>Nokia 5500d</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/07/16/left-soft-key-unresponsive-after-sms-interrupt-on-nokia-5500d/</guid>
		<description><![CDATA[  This is an old issue I hoped I would never have to deal with again as it is caused by a Nokia application distributed with some of their devices. The application in question is the SMS reader which uses a speech synthesizer to read any unread messages when the user holds the left soft [...] ]]></description>
			<content:encoded><![CDATA[<p> This is an old issue I hoped I would never have to deal with again as it is caused by a Nokia application distributed with some of their devices. The application in question is the SMS reader which uses a speech synthesizer to read any unread messages when the user holds the left soft key.</p>
<p>During compatibility testing an issue was occasionally reported among a variety of applications regarding the left soft key becoming unresponsive. This is normally a very rare bug to find as all key groups (numerical, directional and softkeys) are treated the same in most application and each group either all work, or all don`t. After some investigation by QA a finger was very quickly pointed in the direction of the SMS reader application.</p>
<p>It did not take long to realize that the issue lay in the calling of keyPressed and keyReleased. A small test application later and it became apparent that the underlying OS was hogging the LSK looking for an extended key press so it could start the SMS reader. The result in the JVM was that keyPressed and keyReleased were being called on the same tick, so in the application nothing happened.</p>
<p>The fix is to detect if keyPressed and keyReleased are called on the same tick when the LSK is pressed. If this condition occurs, keyReleased returns to allow the application to detect and handle the key press. A tick counter is something that many applications have and is handy to fix such bugs. An example is shown:</p>
<div class="syntax_hilite">
<div id="j2me-26">
<div class="j2me"><span style="color: #7F0055; font-weight: bold;">int</span> lskPressedTick = <span style="color: #000000;">0</span>;<br />
<span style="color: #7F0055; font-weight: bold;">protected</span> <span style="color: #7F0055; font-weight: bold;">final</span> <span style="color: #7F0055; font-weight: bold;">void</span> keyPressed<span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">int</span> nCode<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #7F0055; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> nCode == Device.<span style="color: #000000;">KEY_LSK</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3F7F5F; font-style: italic;">// -6 on Nokia devices</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; lskPressedTick = tickCounter;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; .<br />
&nbsp; &nbsp; .<br />
&nbsp; &nbsp; .<br />
<span style="color: #000000;">&#125;</span><br />
<span style="color: #7F0055; font-weight: bold;">protected</span> <span style="color: #7F0055; font-weight: bold;">final</span> <span style="color: #7F0055; font-weight: bold;">void</span> keyReleased<span style="color: #000000;">&#40;</span><span style="color: #7F0055; font-weight: bold;">int</span> nCode<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #7F0055; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span> nCode == Device.<span style="color: #000000;">KEY_LSK</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &amp;&amp; lskPressedTick == tickCounter <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7F0055; font-weight: bold;">return</span>;<br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; .<br />
&nbsp; &nbsp; .<br />
&nbsp; &nbsp; .<br />
<span style="color: #000000;">&#125;</span></div>
</div>
</div>
<p></p>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/07/16/left-soft-key-unresponsive-after-sms-interrupt-on-nokia-5500d/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Cross Browser Semi-Transparent DIV</title>
		<link>http://blog.reloadsystems.net/2007/07/20/cross-browser-semi-transparent-div/</link>
		<comments>http://blog.reloadsystems.net/2007/07/20/cross-browser-semi-transparent-div/#comments</comments>
		<pubDate>Fri, 20 Jul 2007 14:51:39 +0000</pubDate>
		<dc:creator>michael_cowan</dc:creator>
		
	<category>CSS</category>
		<guid isPermaLink="false">http://blog.reloadsystems.net/2007/07/20/cross-browser-semi-transparent-div/</guid>
		<description><![CDATA[  I was recently asked to design a new website for a bikes company. They wanted to use a large background image with a semi-transparent (opaque) div box to contain each pages main content. My first thought was to use filters through CSS. Although filters lie outside the scope of both the CSS1 and CSS2 [...] ]]></description>
			<content:encoded><![CDATA[<p> I was recently asked to design a new website for a bikes company. They wanted to use a large background image with a semi-transparent (opaque) div box to contain each pages main content. My first thought was to use filters through CSS. Although filters lie outside the scope of both the <a href="http://www.w3.org/TR/REC-CSS1">CSS1</a> and <a href="http://www.w3.org/TR/REC-CSS2/">CSS2</a> definitions, the mechanism through which they are called is part of CSS. More recently <a href="http://www.w3.org/Style/CSS/current-work">CSS3 </a>has a new property in an attempt to unite browsers. These properties are shown below:</p>
<pre>
Internet Explorer              filter: alpha(opacity=50);
Mozilla                        -moz-opacity: 50%;
CSS3                           opacity: 0.5;
</pre>
<p>For compatibility it is recommended to use all three.</p>
<p>The problem with this is consistency. If a div is created with it's opacity set to 50% using the mentioned methods, different browsers produce different results. Mozilla browsers (rather annoyingly, correctly) apply this opacity to all child elements within the div. So any text, images or even scroll bars are also set to 50% opacity. This is true even if you try to apply an opacity of 100% to these child elements. This is because the 100% you apply to them is 100% of the 50% they currently have. Internet Explorer does not suffer from this and although more desirable, is not consistent with the CSS definition. A new solution needed to be found with the following requirements:</p>
<ul>
<li>Works on both browsers (IE and Mozilla being the most common browsers visiting the site)</li>
<li>Does not suffer from the 'child inheritance' problem</li>
<li>Has no noticeable negative performance impact</li>
</ul>
<p>The solution I came up with lay in the <a href="http://www.w3.org/Graphics/PNG/">PNG </a>image format. I wanted to use a 1x1px image of opacity 30% and tile it across the div as its background. This would give the same result at setting the opacity of the div but without using the CSS properties and having the child inheritance problem. However PNG has it's own issues with support in Internet Explorer which requires a <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;294714">work around</a> supplied by Microsoft. So to set the background image of a div to a PNG file, the following can be used:</p>
<pre>
Mozilla            background-image: url(box_bg.png);
Internet Explorer  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='box_bg.png');
</pre>
<p>A final problem with the Microsoft fix in Internet Explorer is that if the standard (Mozilla) method is also included in a div, then the incorrectly rendered PNG image covers the fixed one. To get past this you can exploit Explorers lack of support for <a href="http://www.w3.org/TR/CSS21/selector.html#attribute-selectors">attribute selectors</a>. This allows you to place the Explorer fix in the div (which Mozilla will ignore as it is an Explorer filter: attribute) and the Mozilla method in an attribute selector for it (which Explorer doesn't support).<br />
The final div CSS is shown below:</p>
<div class="syntax_hilite">
<div id="code-28">
<div class="code">.<span style="">transbox</span> <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; width:&nbsp; 300px;<br />
&nbsp; &nbsp; margin: 10px;<br />
&nbsp; &nbsp; border: 2px solid black;<br />
&nbsp; &nbsp; <span style="color:#008000;">/* Mozilla will ignore this as is it a M$ filter */</span><br />
&nbsp; &nbsp; filter:progid:DXImageTransform.<span style="">Microsoft</span>.<span style="">AlphaImageLoader</span><span style="color:#006600; font-weight:bold;">&#40;</span>enabled=true,sizingMethod=scale src=<span style="color:#CC0000;">'semitransparentpixel.png'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">transbox</span><span style="color:#006600; font-weight:bold;">&#91;</span>class<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; <span style="color:#008000;">/* IE will ignore this as it doesnt support styles with [attributes]*/</span><br />
&nbsp; &nbsp; background-image: url<span style="color:#006600; font-weight:bold;">&#40;</span>semitransparentpixel.<span style="">png</span><span style="color:#006600; font-weight:bold;">&#41;</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<p>Unfortunately this is still far from a prefect solution. Should Internet Explorer support attribute selectors in the future, then we are back to the background cover up problem. We can only hope that Microsoft sorts out its PNG problems before this ... or, perhaps all browsers will finally unite in their interpretation of opacity in CSS3 and allow the designer to decide if child elements inherit their parents transparency. We can only hope.</p>
<p>- FIN -</p>
]]></content:encoded>
			<wfw:commentRSS>http://blog.reloadsystems.net/2007/07/20/cross-browser-semi-transparent-div/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
