Default DrawStyle of Non-Material Design vs Material Design Controls

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
User avatar
Posts: 28
Joined: Tue Nov 24, 2015 9:20 pm

Default DrawStyle of Non-Material Design vs Material Design Controls

Post by MarcusLancaster » Thu Jan 30, 2020 2:56 am

Hi all.

We're working with the latest version of LANSA on a new project and have a couple of questions regarding the default appearance of Material Design vs non-Material Design controls. For the sake of simplicity in this post I'm going to use push buttons as an example.

With non-Material Design push buttons, when we drag and drop a #PRIM_PHBN from the controls palette onto a web page, by default the appearance of the button can be set if a DrawStyle with name #PushButton has been defined in the associated Theme. In this way, whenever we drag on a button we pick up the same appearance (with borders, mouseover effects etc etc). Note that the ThemeDrawStyle for these button is always blanks; the connection between the control and the default DrawStyle appears to be based on a "behind the scenes" cross reference ( ... e_name.htm). We can always "override" the default by entering a specific ThemeDrawStyle.

However with Material Design buttons (for example #PRIM_MD.RaisedButton) a different "default" approach appears to be used. Depending on the particular button chosen, a different ThemeDrawSyle is included. For example if the PRIMARY button is dragged onto a web page the default ThemeDrawStyle is "MediumTitle". If the Theme happens to contain a DrawStyle named "MediumTitle", then that will be used. If the specific button's ThemeDrawStyle is blanked out, then the #PushButton DrawStyle is not automatically picked up... so we're assuming that the "behind the scenes" connection between a #PRIM_PHBN is not there for a #PRIM_MD.RaisedButton.

So, my first question is... is that expected behaviour?

Therefore to create a "default" appearance for a #PRIM_MD.RaisedButton we could create a DrawStyle "MediumTitle" in the Theme as we know that this will always be used when we drag on the PRIMARY button from the controls palette. But we've noticed that "MediumTitle" is used elsewhere. For example #PRIM_MD.AppDrawer uses "MediumTitle" as its default ThemeDrawStyle. So if we were to define our "MediumTitle" DrawStyle as per our requirement for push button appearance, we would have to create another DrawStyle for any AppDrawers.

However some of the MD controls use combinations of DrawStyles. The #PRIM_MD.FlatButton has a default ThemeDrawStyle of "Borders1+BorderTheme500+ForegroundMediumPrimary" so it would become more complex to create our own override DrawStyle (as we would have to override 3 different DrawStyles and there is therefore a higher chance that these are used elsewhere and we would adveresely effect other controls).

I guess the simplest answer here is to create a new reusable, encapsulating a #PRIM_MD.RaisedButton (or #PRIM_MD.FlatButton, etc) and then we could set the ThemeDrawStyle to be a specific new DrawStyle that we have created in the Theme for that particular type of control. But then whenever we need to use a button we would have to go to the Repository, rather than the Controls palette to pick up the button. Also it doesn't appear that a #PRIM_MD component can be used as an ancestor so the reusable would have to be a #PRIM_PANL and therefore would not by default publish all relevant properties, events and methods.

Sorry for the long explanation... the question here is are we missing something? Is there a simple way to create a "default" Material Design button appearance which is always applied, i.e something similar to that which we see when working with non-Material Design controls?

Any suggestions, advice etc would be most appreciated.

Cheers for now.


Posts: 687
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: Default DrawStyle of Non-Material Design vs Material Design Controls

Post by jyoung » Thu Jan 30, 2020 3:43 am

I think this comes down to how Material Deign works.
Checkout the Material Design color palettes at ... e-palettes

You basically have 2 colors; primary and secondary. These three colors also have variants i.e. medium, dark and light.

From the MD docs:
Your app’s primary and secondary colors, and their variants, help create a color theme that is harmonious, ensures accessible text, and distinguishes UI elements and surfaces from one another
Since MD is all about creating a "harmonious" UI all the MD components build off the Theme.

However you can still define your own drawstyles in a custom Theme.

If you want to deviate from that theme, i.e. have a button that does not partake in the MD theme, just us the default button and add attach your custom drawstyle.

I don't think I would go so far as to create a new RP just to encapsulate the button, I would rather spend some time on the Theme getting the primary and secondary colors right and when I need to, creating my own custom drawstyles.

So to answer you question of
Is there a simple way to create a "default" Material Design button appearance which is always applied, i.e something similar to that which we see when working with non-Material Design controls?
Yes, create a custom theme, define your primary and secondary colors, and set your Page's theme to your custom theme. You can also have the IDE use your custom theme so that the design will look like the actual page.

For example, I have a theme where my primary and secondary colors are blue and purple. The buttons look like this in the IDE.
theme.png (5.76 KiB) Viewed 922 times
The page itself is basic

Code: Select all

begin_com role(*EXTENDS #PRIM_WEB) Theme(#MGSTheme)

define_com class(#PRIM_MD.RaisedButton) name(#Button) DisplayPosition(1) Left(387) Parent(#COM_OWNER) TabPosition(1) ThemeDrawStyle('DangerTitle') Top(264) Caption('Danger')
define_com class(#PRIM_MD.RaisedButton) name(#Button1) Caption('Neutral') DisplayPosition(2) Left(256) Parent(#COM_OWNER) TabPosition(2) Top(264) ThemeDrawStyle('NeutralTitle')
define_com class(#PRIM_MD.RaisedButton) name(#Button2) Caption('Secondary') DisplayPosition(3) Left(384) Parent(#COM_OWNER) TabPosition(3) ThemeDrawStyle('MediumAccent') Top(216)
define_com class(#PRIM_MD.RaisedButton) name(#Button3) Caption('Primary') DisplayPosition(4) Left(256) Parent(#COM_OWNER) TabPosition(4) ThemeDrawStyle('MediumTitle') Top(216)
define_com class(#PRIM_MD.Icon) name(#Icon3) DisplayPosition(5) Icon('fa-envelope-o') Left(272) Parent(#COM_OWNER) TabPosition(5) Top(384) ThemeDrawStyle('ForegroundSecondary') Hint('Email PDF')
define_com class(#PRIM_MD.Icon) name(#Icon1) DisplayPosition(6) Icon('fa-check') Left(320) Parent(#COM_OWNER) TabPosition(6) Top(384) ThemeDrawStyle('ForegroundSecondary')
define_com class(#PRIM_MD.Icon) name(#Icon2) DisplayPosition(7) Icon('fa-close') Left(376) Parent(#COM_OWNER) TabPosition(7) Top(381) ThemeDrawStyle('ForegroundSecondary')

evtroutine handling(#Com_owner.Initialize)


and the Theme is defined as

Code: Select all

begin_com role(*EXTENDS #PRIM_THM) BaseTheme(MaterialDesignBlue) Theme500Color(0:118:192) Theme700Color(0:82:136) Theme100Color(0:150:214) ThemeAccentMediumColor(102:57:180)

define_com class(#PRIM_THM.DrawStyle) name(#PopupTitleBar) Style(#Style1)
define_com class(#PRIM_VS.Style) name(#Style1) BackgroundBrush(#Brush1) ForegroundBrush(#Brush2)
define_com class(#PRIM_VS.SolidBrush) name(#Brush2) Color(255:255:255)
define_com class(#PRIM_VS.SolidBrush) name(#Brush1) Color(Theme700)

define_com class(#PRIM_THM.DrawStyle) name(#DangerTitle) Style(#Style2)
define_com class(#PRIM_VS.Style) name(#Style2) BackgroundBrush(#Brush3) ForegroundBrush(#Brush4)
define_com class(#PRIM_VS.SolidBrush) name(#Brush4) Color(255:255:255)
define_com class(#PRIM_VS.SolidBrush) name(#Brush3) Color(ThemeErrorMedium)

define_com class(#PRIM_THM.DrawStyle) name(#NeutralTitle) Style(#Style3)
define_com class(#PRIM_VS.Style) name(#Style3) BackgroundBrush(#Brush5) ForegroundBrush(#Brush6)
define_com class(#PRIM_VS.SolidBrush) name(#Brush6) Color(ThemeText)
define_com class(#PRIM_VS.SolidBrush) name(#Brush5) Color(194:194:194)

define_com class(#PRIM_THM.DrawStyle) name(#DrawStyle1)


When I drag a Primary Button on the page, it shows up as blue, a Secondary Button shows up as purple.

Hope this helps,

Posts: 176
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: Default DrawStyle of Non-Material Design vs Material Design Controls

Post by dannyoorburg » Thu Jan 30, 2020 9:54 am

Hi Marcus,

it sounds like the default appearance you're after has more to do with shape than color, as color is pretty well defined by the theme.

Just out of curiosity, what exactly are you after?


User avatar
Posts: 28
Joined: Tue Nov 24, 2015 9:20 pm

Re: Default DrawStyle of Non-Material Design vs Material Design Controls

Post by MarcusLancaster » Thu Jan 30, 2020 8:50 pm

Hi guys.

Thanks for the code snip Joe and the follow up Danny.

I can see exactly what you're suggesting Joe, and it does indeed help :-)

The problem we have is that the requirement is to be able to set not just the base colour, but also set the mouseover colour, border/corner style etc. In your example there is a change in colour when mouseover occurs... but its very subtle (looks like it slightly darkens) and I can't see a way to control how subtle (or not) the mouseover colour is, or how to set a completely different (i.e non-harmonious) colour. But even if there is a way to do that... we would also need to adjust the borders.

The only way I can see to do this is to define a full blown DrawStyle in the Theme (as you suggest and have done for DangerTitle and NeutralTitle)... but to use those DrawStyles I have to drag an PRIM_MD button onto the form and then manually set the ThemeDrawStyle for each button. If use a lot of these buttons, then it requires an additional step for each button - granted not a huge amount of work, but definitely something extra for the developer to remember to do.

So really the question boils down to is there a way to make a specific custom DrawStyle the default ThemeDrawStyle for a PRIM_MD button as it is dragged onto a form, like we can with non-MD buttons?

If not that's absolutely fine - but didn't want to go down one particular route if there was a cool default/shortcut feature that we were missing.

Cheers for now and thanks once again :-)


Post Reply